Package eu.semberal.migmang.logic

Source Code of eu.semberal.migmang.logic.Evaluation

package eu.semberal.migmang.logic;

import eu.semberal.migmang.enums.GameColor;
import java.util.Random;

/**
* Class with board evaluation functionality
*
* @author lukas.sembera
*/
public class Evaluation {

    private static Random random;
    private static final int MULTIPLICATION_COEFICIENT = 10000;

    static {
        random = new Random();
    }

    /**
     * Evaluates a position for specific player
     */
    public static int evaluateBoard(Board board, GameColor color) {
        GameColor otherColor = (color == GameColor.White ? GameColor.Black : GameColor.White);
        int ret = 15 - board.getPiecesCount(otherColor);
        ret += board.getPiecesCount(color);
        ret *= MULTIPLICATION_COEFICIENT;
        ret += random.nextInt(MULTIPLICATION_COEFICIENT - 1);
        return ret;
    }
}
TOP

Related Classes of eu.semberal.migmang.logic.Evaluation

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.