示例#1
0
        private void TestRandomPlay()
        {
            int    numGamesEvenlyScored   = 0;
            int    numGamesUnEvenlyScored = 0;
            Random rand = new Random();

            for (int i = 0; i < 50000; i++)
            {
                int currentPlayer = 0;

                while (fillGrid.Score(0) + fillGrid.Score(1) < fillGrid.SizeX * fillGrid.SizeY)
                {
                    fillGrid.FloodFill(currentPlayer, rand.Next(0, 5));
                    currentPlayer = currentPlayer == 1 ? 0 : 1;
                }

                if (fillGrid.Score(0) + fillGrid.Score(1) == fillGrid.SizeX * fillGrid.SizeY)
                {
                    numGamesEvenlyScored++;
                }

                if (fillGrid.Score(0) + fillGrid.Score(1) > fillGrid.SizeX * fillGrid.SizeY)
                {
                    numGamesUnEvenlyScored++;
                }

                fillGrid.Initialize(20, 20);
            }

            Debug.WriteLine("Evenly Scored Games: " + numGamesEvenlyScored);
            Debug.WriteLine("Unevenly Scored Games: " + numGamesUnEvenlyScored);
        }
示例#2
0
        public void OnInit(InitContext context)
        {
            if (context == InitContext.Activate)
            {
                //Get a reference the to the game board
                tilesGameBoard = Scene.Current.FindComponent <Tilemap>(true);
                camera         = Scene.Current.FindComponent <Camera>(true);

                fillGrid = new FillGridModel();
                fillGrid.Initialize(tilesGameBoard.Size.X, tilesGameBoard.Size.Y);

                UpdateGameBoardColors();

                Debug.WriteLine("Wait...");
            }
        }