示例#1
0
 public TicTacToeAction(byte x, byte y, TicTacToePlayerType playerType, TicTacToeState state)
 {
     X          = x;
     Y          = y;
     PlayerType = playerType;
     IsAllowed  = state.Board[x, y] == default;
 }
示例#2
0
        private static int[] GetWinMaskFor(TicTacToePlayerType type)
        {
            List <int> mask = new List <int>();

            TicTacToeBoard board;

            for (int i = 0; i < 3; i++)
            {
                board       = new TicTacToeBoard();
                board[i, 0] = type;
                board[i, 1] = type;
                board[i, 2] = type;
                mask.Add(board.Board);
                board       = new TicTacToeBoard();
                board[0, i] = type;
                board[1, i] = type;
                board[2, i] = type;
                mask.Add(board.Board);
            }
            board       = new TicTacToeBoard();
            board[0, 0] = type;
            board[1, 1] = type;
            board[2, 2] = type;
            mask.Add(board.Board);
            board       = new TicTacToeBoard();
            board[0, 2] = type;
            board[1, 1] = type;
            board[2, 0] = type;
            mask.Add(board.Board);

            return(mask.ToArray());
        }
示例#3
0
        public async Task ShowEndState(TicTacToeState state)
        {
            ShowState(state);
            Console.SetCursorPosition(0, USER_CONTROL_ROW);
            TicTacToePlayerType winner = state.Summary.Winner;

            if (winner == TicTacToePlayerType.No)
            {
                Console.WriteLine("Draw!!!!!");
            }
            else
            {
                Console.WriteLine($"{winner} Win !!!!!");
            }
        }