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); }
public IGameState Clone() { var nim = new NimState(_chips) { _playerJustMoved = _playerJustMoved }; return(nim); }
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"); } }