Exemplo n.º 1
0
    int ChooseOthelloMove(OthelloBoard current)
    {
        List <int> moves = current.GetMoves();

        int ID            = current.GetActivePlayer();
        int bestscore     = -64;        // worst possible score
        int bestmoveindex = 0;

        for (int i = 0; i < moves.Count; i++)
        {
            OthelloBoard clone = (OthelloBoard)current.Clone();
            clone.MakeMove(moves [i]);
            int newscore = clone.CountStones() * ID;
            // Grabbing corners = always good:
            if (moves [i] == 0 || moves [i] == 7 || moves [i] == 56 || moves [i] == 63)
            {
                newscore += 50;
            }
            if (newscore > bestscore)
            {
                bestscore     = newscore;
                bestmoveindex = i;
            }
        }
        return(moves[bestmoveindex]);
    }