Beispiel #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) };
 }
        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();
        }
        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();
        }
        /// <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();
 }
 void Start()
 {
     InitBoard();
     _renderer = GetComponent <BoardRenderer2D>();
 }
Beispiel #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);
 }
Beispiel #8
0
 public void SetUp()
 {
     _boardRenderer = new BoardRenderer();
 }