Posts

Showing posts from January, 2016

The WeakReference class, monitoring memory leak and garbage collection in a Java application

Image
 Below is a Stack implementation that uses an internal resizeable array structure.  public class MyStack< T > implements Stack< T > { private static final int CAPACITY = 100 ; private Object[] array ; private int pos = 0 ; public MyStack () { this . array = new Object[ CAPACITY ] ; } @Override public void push ( T item) { if ( pos >= array . length / 2 ) { Object[] newArray = new Object[ pos * 2 ] ; System. arraycopy ( array , 0 , newArray , 0 , array . length ) ; array = newArray ; } array [ pos ++] = item ; } @Override public T pop () { if (isEmpty()) { throw new RuntimeException( "empty stack" ) ; } @SuppressWarnings ( "unchecked" ) T item = ( T ) array [ pos - 1 ] ; pos -= 1 ; return item ; } @Override @SuppressWarnings ( "unchecked" ) public T peek...

Pulse Motorunun İncelenmesi

Pulse sisteminde bir pozisyonun değerlendirilmesi Evaluation sınıfı ile gerçekleşmektedir. class Evaluation { int evaluate(Position position) { int myColor = position. activeColor ; int oppositeColor = opposite(myColor); int value = 0 ; int materialScore = (evaluateMaterial(myColor, position) - evaluateMaterial(oppositeColor, position)) * materialWeight / MAX_WEIGHT; value += materialScore; int mobilityScore = (evaluateMobility(myColor, position) - evaluateMobility(oppositeColor, position)) * mobilityWeight / MAX_WEIGHT; value += mobilityScore; return value; } //... } Burada önce pozisyondaki materyal skoru bulunmaktadır. Örneğin bir piyon fazlası var ise materyal skoru 1 olarak bulunur. Ardından mobilite skoru bulunmaktadır. Örneğin bir fil, çapraz karelerde serbest olarak dolaşabiliyorsa mobilite skoru yüksek olur. Satranç motorları güçlendikçe değerlendirme kriterleri de artmakta ve kod d...

FEN Notasyonu ve UCI Protokolü

FEN NOTASYONU Forsyth-Edwards Notasyonu, satranç pozisyonlarını ASCII karakter seti kullanarak ifade etmeye yarayan bir standarttır. Satranç programcıları için standart bir pozisyon notasyonu çok önemlidir çünkü böylece pozisyon veritabanlarını birbirleri ile paylaşabilirler. Satranç motorlarının test edilmesinde bu veritabanları önemli yer tutar ve yorucu veri girişi işlemlerinden kurtulmayı sağlar. [1] FEN tanımlaması tek satırdan oluşur ve 6 alandan ibarettir: İlk alan, taşların yerleşimini ifade eder. Taşların dizilimi 8. satırdan başlanarak gösterilir. Beyaz taşlar için "PNBRQK" şeklinde büyük harfler kullanılırken, siyah taşlar için küçük harfler kullanılır. İkinci alan aktif rengi ifade etmektedir. Eğer sıra beyazda ise "w" değerini alır. Üçüncü alan rok yapma iznini ifade eder. Eğer her iki taraf da rok yapamıyorsa "-" değerini alır. Eğer beyaz, şah tarafına rok yapabiliyorsa "K", vezir tarafına rok yapabiliyo...

Notes on Parallel Programming

In the past, the performance of microprocessors increased on average, 50% per year. In this period, you could simply wait to buy the next generation of microprocessors that will speed up your applications. But since 2002, single processor performance has slowed down. By 2005, most manufacturers decided to go on in the direction of paralellism. They started to put multiple processors on a single circuit. But this does not magically improve the performance of serial applications. It may be a silly question to ask: why do we need ever increasing performance? But why do they manufacture multi-core hardware? Because as the speed of transistor increase, so does the power consumption. The circuit becomes too hot and is not reliable anymore. And if the integrated circuit industry stop producing new and better products, those companies dissapear. So today, CPU clock speed is not increasing, and manufacturers does not design complex processors. Most of the time, it is not possible to automat...

Popular posts from this blog

Trie Data Structure and Finding Patterns in a Collection of Words

My Crappy Looking Solution to "Binary Tree Common Ancestor" Problem

A Graph Application in Java: Using WordNet to Find Outcast Words