예제 #1
0
        public void PlayUctGame(int chips)
        {
            var state = new NimState(chips);

            while (state.GetMoves().Any())
            {
                var temp = state.GetMoves();
                if (temp.Length == 0)
                {
                    break;
                }

                int move = 0;
                if (state.GetPlayerJustMoved() == 1)
                {
                    move = Search(state, 1000);
                }
                else
                {
                    move = Search(state, 100);
                }

                state.DoMove(move);
                Console.WriteLine($"Player {state.GetPlayerJustMoved()} decided to make moves {move}, remaining chip {state.GetRemaingChips()}");
            }

            DisplayResult(state);
        }
예제 #2
0
파일: NimState.cs 프로젝트: davidiwu/mcts
        public IGameState Clone()
        {
            var nim = new NimState(_chips)
            {
                _playerJustMoved = _playerJustMoved
            };

            return(nim);
        }
예제 #3
0
        private static void DisplayResult(NimState state)
        {
            var result = state.GetResult(state.GetPlayerJustMoved());

            if (result == 1 || result == 0)
            {
                Console.WriteLine($"Player {state.GetPlayerJustMoved()} : result {result}");
            }
            else
            {
                Console.WriteLine("Nobody wins");
            }
        }