public void NewGameWithRobotAsWhite() { OnGameModeChanged?.Invoke(GameMode.HumanToRobot); OnPlayerColorChanged?.Invoke(ChipColor.White); robot.Enable(ChipColor.Black); model.NewGame(); }
//Test robot mode (black) static void Test2() { ReversiModel model = new ReversiModel(); RandomUser robot = new RandomUser(model); model.SwitchMove += (s, ea) => { Console.WriteLine("Switch move {0}", ea.CurrentPlayerColor); }; model.SwitchMove += (s, ea) => { Console.WriteLine(ea.AllowedCells.Count); foreach (Cell cell in ea.AllowedCells) { Console.WriteLine("{0} {1}", cell.X, cell.Y); } }; robot.Enable(Color.White); model.NewGame(); while (true) { int x = int.Parse(Console.ReadLine()); int y = int.Parse(Console.ReadLine()); model.PutChip(x, y); } }
//Simulates human to human game mode static void Test1() { ReversiModel model = new ReversiModel(); model.WrongMove += (s, ea) => { Console.WriteLine("Wrong move"); }; model.SwitchMove += (s, ea) => { Console.WriteLine("Switch move {0}", ea.CurrentPlayerColor); }; model.SwitchMove += (s, ea) => { foreach (Cell cell in ea.AllowedCells) { Console.WriteLine("{0} {1}", cell.X, cell.Y); } }; model.CountChanged += (s, ea) => { Console.WriteLine("count {0} {1}", ea.CountBlack, ea.CountWhite); }; model.NewGame(); while (true) { int x = int.Parse(Console.ReadLine()); int y = int.Parse(Console.ReadLine()); model.PutChip(x, y); } }
/* * Starts new game * -------------------------------------------- * currentBlackHole - black hole of current game * currentPlayerColor - color of this AI in current game */ public void StartGame(Cell currentBlackHole, Color currentPlayerColor) { currentColor = currentPlayerColor; oppositeColor = (currentColor == Color.Black) ? Color.White : Color.Black; GameIsOver = false; blackHole = currentBlackHole; SetStartBoard(); model.NewGame(); }
//Test robot mode (playing for color you want) static void Test3(Color userColor) { ReversiModel model = new ReversiModel(); RandomUser robot = new RandomUser(model); model.NewGameStarted += (s, ea) => { Console.WriteLine("Game started."); }; model.SwitchMove += (s, ea) => { Console.WriteLine("Switch move {0}", ea.CurrentPlayerColor); }; model.SwitchMove += (s, ea) => { Console.WriteLine(ea.AllowedCells.Count); foreach (Cell cell in ea.AllowedCells) { Console.WriteLine("{0} {1}", cell.X, cell.Y); } }; Color robotColor; if (userColor == Color.Black) { robotColor = Color.White; } else { robotColor = Color.Black; } robot.Enable(robotColor); model.NewGame(); while (true) { int x = int.Parse(Console.ReadLine()); int y = int.Parse(Console.ReadLine()); model.PutChip(x, y); } }