Пример #1
0
    public override Move[] GetMoves()
    {
        List <Move> moves = new List <Move>();
        int         rows  = board.GetLength(0);
        int         cols  = board.GetLength(1);

        //get the moves from all available pieces on the board
        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < cols; j++)
            {
                PieceDraughts p = board[i, j];
                if (p == null)
                {
                    continue;
                }
                moves.AddRange(p.GetMoves(ref board));
            }
        }
        return(moves.ToArray());
    }
Пример #2
0
    private float Evaluate(PieceColor color)
    {
        float eval         = 1f;
        float pointSimple  = 1f;
        float pointSuccess = 5f;
        int   rows         = board.GetLength(0);
        int   cols         = board.GetLength(1);
        int   i;
        int   j;

        for (i = 0; i < rows; i++)
        {
            for (j = 0; j < cols; j++)
            {
                PieceDraughts p = board[i, j];
                if (p == null)
                {
                    continue;
                }
                if (p.color != color)
                {
                    continue;
                }
                Move[] moves = p.GetMoves(ref board);
                foreach (Move mv in moves)
                {
                    MoveDraughts m = (MoveDraughts)mv;
                    if (m.success)
                    {
                        eval += pointSuccess;
                    }
                    else
                    {
                        eval += pointSimple;
                    }
                }
            }
        }
        return(eval);
    }
Пример #3
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++)
            {
                PieceDraughts p = board[i, j];
                if (p == null)
                {
                    continue;
                }
                moves.AddRange(p.GetMoves(ref board));
            }
        }
        return(moves.ToArray());
    }