Пример #1
0
        public void BoardGenerator_GenerateBoard_Nominal()
        {
            for (var i = 0; i < 200; i++)
            {
                // Act
                var(solvedBoard, playingBoard) = _boardGenerator.GenerateBoard(_gameConfig);

                // Assert
                foreach (var board in new[] { solvedBoard, playingBoard })
                {
                    Assert.Equal(_height, board.Height);
                    Assert.Equal(_width, board.Width);
                    Assert.Equal(_height * _width, board.Cells.Length);
                    var nonNullCenterCellMovesCount = BoardGenerator.Moves(board.Cells[_height / 2, _width / 2]);
                    Assert.True(nonNullCenterCellMovesCount >= 2);
                    Assert.True(nonNullCenterCellMovesCount <= 3);
                }

                for (var row = 0; row < solvedBoard.Height; row++)
                {
                    for (var col = 0; col < solvedBoard.Width; col++)
                    {
                        Assert.Equal(BoardGenerator.Moves(solvedBoard.Cells[row, col]), BoardGenerator.Moves(playingBoard.Cells[row, col]));
                    }
                }
            }
        }
        public void TestCorrectBoardSize()
        {
            var boardSize    = new Vector2(10, 10);
            var boardOptions = new BoardOptions(boardSize, 10, 10);

            var board = _boardGenerator.GenerateBoard(boardOptions);

            Assert.AreEqual(boardSize, board.Size);
        }
        public void TestSameSeedSameBoard()
        {
            const int seed      = 123456789;
            var       generator = new BoardGenerator();
            var       boardSize = new Vector2(10, 10);

            var board = generator.GenerateBoard(new BoardOptions(boardSize, 10, seed));

            Assert.AreEqual(board, generator.GenerateBoard(new BoardOptions(boardSize, 10, seed)));
        }
        public void Setup()
        {
            _logger = new Logger();

            var user = new User();

            var boardPrinter = new ConsoleBoardPrinter();
            var scoreManager = new ScoreManager();

            _actionParser   = new ActionParser();
            _boardManager   = new BoardManager();
            _boardGenerator = new BoardGenerator();

            // Delete all the scores at the start of each test.
            scoreManager.DeleteAll();

            //Setups the game
            _gameManager = new GameManager(boardPrinter, _boardManager, _boardGenerator, _actionParser, scoreManager, user);

            _boardOptions = new BoardOptions(new Vector2(5, 5), 5);

            _board = _boardGenerator.GenerateBoard(_boardOptions);

            // Generate all positions file
            FileGenerator.GenerateAllPositions(_board);
        }
Пример #5
0
    void InitBoard()
    {
        grid                 = boardRect.GetComponent <GridLayoutGroup>();
        grid.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
        grid.constraintCount = boardColumnCount;

        boardWidth  = boardRect.sizeDelta.x;
        boardHeight = boardRect.sizeDelta.y;

        int numCells = boardColumnCount * boardRowCount;

        for (int i = 0; i < numCells; i++)
        {
            CellSlot cellSlot = Instantiate(cellSlotPrefab, boardRect);
            slotList.Add(cellSlot);
        }

        BoardEditor be = FindObjectOfType <BoardEditor>();

        if (be != null)
        {
            be.LoadSlots();
        }

        BoardGenerator bg = GetComponent <BoardGenerator>();

        if (bg != null)
        {
            bg.GenerateBoard();
        }
    }
Пример #6
0
    void Start()
    {
        boardGenerator.GenerateBoard();
        clearBoardSystem.SetTileGrid(boardGenerator.tileGrid);

        Score = 0;
        Moves = 10;
    }
Пример #7
0
    private void GenerateBoard()
    {
        _boardGenerator = GetComponent <BoardGenerator>();
        _board          = _boardGenerator.GenerateBoard(_boardBlueprint);

        _boardMapper = new BoardMapper();
        _boardMapper.MapNeighbours(_board);
    }
Пример #8
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        BoardGenerator map = target as BoardGenerator;

        map.GenerateBoard();
    }
Пример #9
0
 void Awake()
 {
     TileSwapHandler.AnyPhysicalSwapMade += OnAnyPhysicalSwapMade;
     TileSwapHandler.AnyBoardSwapMade    += OnAnyBoardSwapMade;
     minAmountForMatch = tileBoardVals.GetVariable("minAmountForMatch")
                         as IntegerVariable;
     tiles = boardGenerator.GenerateBoard(this);
     UpdateColumnsAndRows();
 }
        public ActionResult Index()
        {
            var viewModel = new SudokuSolverViewModel()
            {
                Board = BoardGenerator.GenerateBoard().ToStringBoard()
            };

            return(View(viewModel));
        }
Пример #11
0
 private void InitGame()
 {
     IsGameFinished = false;
     Cells          = new Cell[9];
     _board.GenerateBoard();
     Winner    = Cell.CellOwner.None;
     GameState = GamePhase.GameStart;
     StartCoroutine(GameLoop());
 }
Пример #12
0
 // Generate board and place each player's pieces
 public void GenerateBoard()
 {
     if (boardGenerator != null)
     {
         pieceList = boardGenerator.GenerateBoard();
         GeneratePlayerPieces();
         GenerateCompetitorPieces();
     }
 }
Пример #13
0
 public void Test()
 {
     Debug.Log("test");
     //generate 5 boards
     for (int i = 0; i < 5; i++)
     {
         Board b = BoardGenerator.GenerateBoard();
         pm.BoardsInventory.Add(b);
     }
 }
Пример #14
0
    /// <summary>
    /// Render the GUI for this component inspector.
    /// </summary>
    public override void OnInspectorGUI()
    {
        // Draw the default inspect.
        DrawDefaultInspector();

        // Draw the button to generate a new board.
        if (GUILayout.Button("Generate Board"))
        {
            generator.GenerateBoard();
        }
    }
        public void WinInOneMoveAllPositions()
        {
            _boardOptions = new BoardOptions(new Vector2(5, 5), 24);

            using StreamReader sr = File.OpenText(FILENAMEALLPOSITIONS);
            string instruction = string.Empty;

            while ((instruction = sr.ReadLine()) != null)
            {
                _board = _boardGenerator.GenerateBoard(_boardOptions);

                // All the positions of the board are mines.
                foreach (BoardCell boardCell in _board.Cells)
                {
                    boardCell.IsMine = true;
                }

                // Parse the action
                SelectCellAction action = (SelectCellAction)_actionParser.ParseAction(instruction);
                BoardCell        cell   = _board.Cells.FirstOrDefault(x => x.Position == action.CellPosition);

                //The required cell is not a mine
                cell.IsMine = false;

                _boardManager.SelectCell(_board, action.CellPosition);

                bool result = _board.Cells.Count(c => !c.IsMine && c.Status == CellStatus.VISIBLE) ==
                              _board.Cells.Length - _board.MineNumber;

                try
                {
                    Assert.AreEqual(true, result);
                    _logger.Log(string.Format("Win the game in one move {0}", instruction), AutomationTestType.WinInOneMoveAllPositions);
                }
                catch (System.Exception)
                {
                    _logger.Log(string.Format("ASSERT ERROR: We don't win the game in one move {0}", instruction), AutomationTestType.WinInOneMoveAllPositions);
                }
            }
        }
Пример #16
0
    void InitialiseBoard()
    {
        currentBoard = BoardGenerator.GenerateBoard();

        for (int x = 0; x < currentBoard.tiles.GetLength(0); x++)
        {
            string line = "";
            for (int y = 0; y < currentBoard.tiles.GetLength(1); y++)
            {
                line += (x + y) % 2 == 0 ? "[#]" : "[_]";
            }
            Debug.Log(line);
        }
    }
Пример #17
0
        private CompressionResult GetSource(Stopwatch stopwatch)
        {
            stopwatch.Restart();

            var data = BoardGenerator.GenerateBoard();

            stopwatch.Stop();

            return new CompressionResult
            {
                Name = "Source",
                Data = data,
                Time = stopwatch.ElapsedMilliseconds
            };
        }
Пример #18
0
    void Start()
    {
        if (useTemplateNode)
        {
            board = BoardGenerator.CreateUniformBoard(width, height, templateNode);
        }
        else
        {
            board = BoardGenerator.GenerateBoard(width, height);
        }

        display = FindObjectOfType <BoardDisplay>();
        if (display != null)
        {
            display.DrawBoard(board);
        }
    }
Пример #19
0
        public void CanGenerateBoard()
        {
            var randomNumberGenerator = new SweepingRandomNumberGenerator();
            var boardGenerator        = new BoardGenerator(randomNumberGenerator);

            int passes = 0;

            while (randomNumberGenerator.Next())
            {
                var board = boardGenerator.GenerateBoard();

                OutputBoard(board);
                ++passes;
            }

            passes.Should().Be(5);
        }
Пример #20
0
        public void BoardGeneratorGeneratesBoardOfCorrectSize()
        {
            var board = _testObj.GenerateBoard(2, 0);

            Assert.That(board.GetSize(), Is.EqualTo(2));
        }