Exemplo n.º 1
0
    public float evaluate(PieceColor color, BoardModel board)
    {
        float eval         = 1f;
        float pointSimple  = 1f;
        float pointCapture = 5f;

        int rows = board.board.GetLength(0);
        int cols = board.board.GetLength(1);

        int i;
        int j;

        for (i = 0; i < rows; i++)
        {
            for (j = 0; j < cols; j++)
            {
                PieceModel p = board.board[i, j];
                if (p == null)
                {
                    continue;
                }
                if (p.color != color)
                {
                    continue;
                }
                Move[] moves = p.GetMoves(ref board.board);
                foreach (Move mv in moves)
                {
                    MoveModel m = (MoveModel)mv;
                    if (m.isCapture())
                    {
                        eval += pointCapture;
                    }
                    else
                    {
                        eval += pointSimple;
                    }
                }
            }
        }
        return(eval);
    }
Exemplo n.º 2
0
    public override Move[] getMoves()
    {
        List <Move> moves = new List <Move>();
        int         rows  = board.GetLength(0);
        int         cols  = board.GetLength(1);
        int         i;
        int         j;

        for (i = 0; i < rows; i++)
        {
            for (j = 0; i < cols; j++)
            {
                PieceModel p = board[i, j];
                if (p == null)
                {
                    continue;
                }
                moves.AddRange(p.GetMoves(ref board));
            }
        }
        return(moves.ToArray());
    }
Exemplo n.º 3
0
 public Move[] getPiecesMoves(PieceModel piece)
 {
     return(piece.GetMoves(ref board));
 }