예제 #1
0
    public void NewGameWithRobotAsWhite()
    {
        OnGameModeChanged?.Invoke(GameMode.HumanToRobot);
        OnPlayerColorChanged?.Invoke(ChipColor.White);

        robot.Enable(ChipColor.Black);
        model.NewGame();
    }
예제 #2
0
        //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);
            }
        }
예제 #3
0
        //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);
            }
        }
예제 #4
0
        /*
         * 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();
        }
예제 #5
0
        //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);
            }
        }