Пример #1
0
        public override Func <TGame, int, int> GetEvaluator <TGame>(int evalId)
        {
            switch (evalId)
            {
            case 1:
                return((g, p) =>
                {
                    CthelloGame game = g as CthelloGame;
                    return game.CountStonesWeighted(p) - game.CountStonesWeighted(1 - p);
                });

            case 2:
                return((g, p) =>
                {
                    CthelloGame game = g as CthelloGame;
                    int myMoves = game.MovesFor(p).Count();
                    int yourMoves = game.MovesFor(1 - p).Count();
                    if (myMoves < 2 && yourMoves < 2)
                    {
                        return game.CountStonesFor(p) - game.CountStonesFor(1 - p);
                    }
                    else
                    {
                        return (game.CountStonesWeighted(p) + 10 * myMoves) - (game.CountStonesWeighted(1 - p) + 10 * yourMoves);
                    }
                });

            default:
                return((g, p) =>
                {
                    CthelloGame game = g as CthelloGame;
                    return game.CountStonesFor(p) - game.CountStonesFor(1 - p);
                });
            }
        }
Пример #2
0
 protected void OnMoved(CthelloGame game)
 {
     if (Moved != null)
     {
         Moved(this, new GameEventArgs(game));
     }
 }
Пример #3
0
        // Einen Zug ausführen
        public void MakeMove(CthelloMove move)
        {
            CthelloGame newGame = (CthelloGame)_game.MakeMove(move);

            _game = newGame;
            OnMoved(newGame);
        }
Пример #4
0
        public override Game <CthelloMove> MakeMove(CthelloMove move)
        {
            CthelloGame copy = new CthelloGame(this);

            copy.AddMove(move);
            if (!move.Pass)
            {
                copy.MoveAndFlip(move);
            }
            return(copy);
        }
Пример #5
0
        public override Func <TGame, int, int> GetEvaluator <TGame>(int evalId)
        {
            switch (evalId)
            {
            case 1:
                // Nur die gewichteten Steine zählen
                return((g, p) =>
                {
                    CthelloGame game = g as CthelloGame;
                    return game.CountStonesWeighted(p) - game.CountStonesWeighted(1 - p);
                });

            case 2:
                // Gewichtete Steine und Anzahl der möglichen Züge werten.
                return((g, p) =>
                {
                    CthelloGame game = g as CthelloGame;
                    var myMoves = game.MovesFor(p);
                    bool iPass = myMoves.First().Pass;
                    var yourMoves = game.MovesFor(1 - p);
                    bool youPass = yourMoves.First().Pass;
                    if (iPass && youPass)
                    {
                        // Wenn jeder nur noch einen Zug (nämlich "Passe") hat,
                        // ist das Spiel zu Ende und es zählen nur die Steine.
                        return game.CountStonesFor(p) - game.CountStonesFor(1 - p);
                    }
                    else
                    {
                        return (game.CountStonesWeighted(p) + MoveWeight * myMoves.Count()) - (game.CountStonesWeighted(1 - p) + MoveWeight * yourMoves.Count());
                    }
                });

            default:
                // Fallback: Steine zählen
                return((g, p) =>
                {
                    CthelloGame game = g as CthelloGame;
                    return game.CountStonesFor(p) - game.CountStonesFor(1 - p);
                });
            }
        }
Пример #6
0
 public CthelloGame(CthelloGame other)
     : base(other)
 {
     _board = other._board;
 }
Пример #7
0
 public CthelloGame(CthelloGame other)
     : base(other)
 {
     _board = new UInt64[2];
     other._board.CopyTo(_board, 0);
 }
Пример #8
0
 public CthelloMatch(Brain <CthelloMove> player1, Brain <CthelloMove> player2)
     : base(player1, player2)
 {
     _game       = new CthelloGame().Init();
     _nextPlayer = player1;
 }
Пример #9
0
 public GameEventArgs(CthelloGame game)
 {
     Game = game;
 }