コード例 #1
0
ファイル: Core.cs プロジェクト: HugoSoszynski/Gomoku
        public static void Turn(Object _object)
        {
            Tuple <uint, uint> tuple;

            try {
                _board.Play(((Tuple <uint, uint>)(_object)).Item1, ((Tuple <uint, uint>)(_object)).Item2, State.Opponent);
            }
            catch (IllegalMoveException e) {
                _serializer.Send("ERROR " + e.Message);
                return;
            }
            tuple = _ia.MakeMove(_board);
            _board.Play(tuple.Item1, tuple.Item2, State.Myself);
            _serializer.Send(tuple.Item1 + "," + tuple.Item2);
        }
コード例 #2
0
        private void DecideMove()
        {
            double bestScore = double.MinValue;

            PossibleMoves = Map.PossibleMoves();
            double currentScore = 0;
            var    depth        = MaxDepth;

            if (PossibleMoves.Count() == 1)
            {
                best     = PossibleMoves.ElementAt(0);
                Finished = true;
                return;
            }
            RemoveUselessMoves();
            var moves = new List <Tuple <uint, uint> >(PossibleMoves);

            foreach (var move in moves)
            {
                Map.Play(move.Item1, move.Item2, State.Myself);
                PossibleMoves.Remove(move);
                currentScore = MinimiseMove(depth, double.MinValue, double.MaxValue, move);
                if (currentScore == double.MaxValue)
                {
                    PossibleMoves.Add(move);
                    Map.Unplay(move.Item1, move.Item2);
                    best     = move;
                    Finished = true;
                    return;
                }
                if (best == null || bestScore < currentScore)
                {
                    best      = move;
                    bestScore = currentScore;
                }
                PossibleMoves.Add(move);
                Map.Unplay(move.Item1, move.Item2);
            }
            Finished = true;
        }