Posts

Showing posts from 2016

Kotlin Language Features Related to Null Handling

Any software engineer with a Java background would find the null handling features in the Kotlin language interesting. Let's summarize this topic with some examples. Nullable types: In Kotlin, types are non-nullable by default. If you want a variable to be able to hold a null value, you need to explicitly declare its type as nullable using the Type? syntax. For example, String? denotes a nullable string, while String represents a non-nullable string. Safe calls (?.): Kotlin introduces the safe call operator (?.) for handling nullable types. It allows you to safely invoke a method or access a property on a nullable object. If the object is null, the expression returns null instead of throwing a NullPointerException. Example: data class Person(val name: String, val age: Int, val address: String?) fun main() {     // Create a person with a nullable address     val person1 = Person("John Doe", 25, "123 Main Street")     val person2 = Person("Jane Doe", 30,

Java Dili ile Genetik Programlama

Bu kısımda örnek bir genetik algoritma kodlaması sunulacaktır ve temel sınıf GeneticAlgorithm sınıfı olacaktır. Bu sınıf veri elemanı olarak algoritmaya ilişkin parametreleri tutmalıdır: public class GeneticAlgorithm {    private int populationSize;        private double mutationRate;        private double crossoverRate;        private int elitismCount;    //... } - mutationRate parametresi, bireysel bir genin rasgele bir biçimde mutasyona uğrama olasılığını ifade etmektedir. - crossoverRate parametresi iki bireyin çiftleşme olasılığını, yani genlerini paylaşarak popülasyona yeni yavru kazandırma olasılıklarını göstermektedir. - elitismCount parametresi popülasyondaki en güçlü bireylerin nesiller boyunca korunması ile ilgidir. Elit bir birey çiftleşmez ve mutasyona uğramaz. İfade edilmesi gereken diğer önemli kavram popülasyondur: public class Population {    private Individual population[];    private double populationFitness;   //.. } Popülasyon, bireyler topl

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

swapLexOrder: Finding lexicographically largest string

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