예제 #1
0
 public TicTacToe()
 {
     _symbols  = new[] { 'X', 'O' };
     _state    = new BoardState(Width, Height, RowCount, _symbols.Length);
     _renderer = new BoardConsoleRenderer(_symbols, _state);
     _movers   = new IMover[] { new Player(_state, _symbols[0]), new MinMax(_state, 1) };
 }
예제 #2
0
        public Board(IBoardCells boardCells, IBoardWinningRules boardWinningRules, IBoardRenderer boardRenderer)
        {
            _boardCells = boardCells;
            _boardRenderer = boardRenderer;
            _boardWinningRules = boardWinningRules;

            _random = new Random(DateTime.Now.Millisecond); //seed is current time's milliseconds, which is a simple way to get a random number
            _boardSize = _boardCells.Size();
        }
예제 #3
0
        public Board(IBoardCells boardCells, IBoardWinningRules boardWinningRules, IBoardRenderer boardRenderer)
        {
            _boardCells        = boardCells;
            _boardRenderer     = boardRenderer;
            _boardWinningRules = boardWinningRules;

            _random    = new Random(DateTime.Now.Millisecond); //seed is current time's milliseconds, which is a simple way to get a random number
            _boardSize = _boardCells.Size();
        }
예제 #4
0
        /// <summary>
        /// Constructor used for unit testing
        /// </summary>
        /// <param name="board">The board</param>
        /// <param name="renderer">The board renderer</param>
        /// <param name="inputprovider">The input provider</param>
        /// <param name="outputProvider">The output provider</param>
        public GameManager(IBoard board, IBoardRenderer renderer, IInputProvider inputProvider, IOutputProvider outputProvider)
        {
            // validate the inputs

            this.board          = board;
            this.renderer       = renderer;
            this.inputProvider  = inputProvider;
            this.outputProvider = outputProvider;

            // initialize the players list

            // set the game state to waiting to start
        }
 public void SetUp()
 {
     _boardRenderer = new BoardRenderer();
 }
예제 #6
0
 void Start()
 {
     InitBoard();
     _renderer = GetComponent <BoardRenderer2D>();
 }
예제 #7
0
 /// <summary>
 /// Draw the board using a specified renderer
 /// </summary>
 /// <param name="renderer">The board renderer</param>
 public void Draw(IBoardRenderer renderer)
 {
     renderer.Render(this);
 }
예제 #8
0
 public void SetUp()
 {
     _boardRenderer = new BoardRenderer();
 }