コード例 #1
0
        public void Play()
        {
            //開始
            Console.WriteLine("Welcome To TicTacToe!!");
            Player winner;

            while (info.isActiveGame)
            {
                board.Display();

                //先行後攻それぞれ打ち続けてもらう
                Player next = info.ObtainNextPlayer();
                Console.WriteLine("現在のターン" + next.mark);
                //TODO: 既に置いてある場合は繰り返す
                var input = next.Play(board.state);
                board = board.ChangeState(input, next);
                info  = info.SwitchNext();
                //勝敗判定
                winner = CalcWinner(board.state);

                if (winner != null)
                {
                    board.Display();
                    Console.WriteLine("Winner: " + winner.mark);
                    break;
                }

                if (board.isFilled())
                {
                    board.Display();
                    Console.WriteLine("あいこです!閉廷!");
                    break;
                }
            }
        }
コード例 #2
0
        public void ChangeSquare(int num)
        {
            //implements the move the player made
            int row    = num / 3;
            int column = num % 3;

            Board.ChangeState(row, column, state);
            // i used num/3 and num%3 becuz i realized from my calculations that those were...
            //...the correct values for rows and columns respectively to change from the 0-8 numbers to the 3x3 grid
        }