Esempio n. 1
0
 public override void GatherPathStats(GamePath gamePath, Board board)
 {
     gamePath.MaxArea   = (float)MaxArea.MaximalRectangle(board.Cells) / 64;
     gamePath.FragScore = Fragmentation.GetFragmentationScore(board.Cells);
     //here the gamePath get the result from the addition function
     gamePath.Tsiun = GetMaxArea(board);
 }
Esempio n. 2
0
        private void InnerMakeAMove(Board board, IDictionary <int, Shape> shapes,
                                    IList <GamePath> gamePaths, GamePath startGamePath, IGameDrawer renderer)
        {
            if (shapes.Count == 0)
            {
                gamePaths.Add(startGamePath);
                GatherPathStats(startGamePath, board);
            }

            var placed = false;

            foreach (var shape in shapes)
            {
                for (int x = 0; x < 8; x++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        var curPlacement = "" + (char)(97 + x) + (char)(49 + y);
                        var newBoard     = new Board(board);
                        if (newBoard.TryPlace(shape.Value, curPlacement))
                        {
                            possibleMoves++;
                            placed = true;
                            var gamePath = new GamePath(startGamePath);

                            var candidate = new Candidate()
                            {
                                ShapeId   = shape.Key,
                                Placement = curPlacement,
                            };
                            gamePath.Moves.Add(candidate);

                            GatherStepStats(candidate, gamePath, board, newBoard);

                            var newShapes = new Dictionary <int, Shape>();
                            foreach (var sh in shapes)
                            {
                                if (sh.Key != shape.Key)
                                {
                                    newShapes.Add(sh.Key, sh.Value);
                                }
                            }

                            InnerMakeAMove(newBoard, newShapes, gamePaths, gamePath, renderer);
                        }
                    }
                }
            }
            renderer.ShowUpdateMessage("[" + possibleMoves.ToString("N0") + "]");
            if (!placed)
            {
                gamePaths.Add(startGamePath);
            }
        }
Esempio n. 3
0
        public override void GatherStepStats(Candidate candidate, GamePath gamePath, Board board, Board newBoard)
        {
            var cellsGain = newBoard.CellCount() - board.CellCount();
            var scoreGain = newBoard.Score - board.Score;

            candidate.CellsGain = cellsGain;
            candidate.ScoreGain = scoreGain;

            gamePath.CellsGain      += cellsGain;
            gamePath.ScoreGain      += scoreGain;
            gamePath.CellCount       = newBoard.CellCount();
            gamePath.PlacementScore *= candidate.PlacementScore;
        }
Esempio n. 4
0
        public GamePath(GamePath source) : this()
        {
            if (source != null)
            {
                foreach (var candidate in source.Moves)
                {
                    Moves.Add(candidate);
                }

                CellsGain      = source.CellsGain;
                ScoreGain      = source.ScoreGain;
                CellCount      = source.CellCount;
                PlacementScore = source.PlacementScore;
            }
        }
Esempio n. 5
0
 public override void GatherPathStats(GamePath gamePath, Board board)
 {
     gamePath.MaxArea   = (float)MaxArea.MaximalRectangle(board.Cells) / 64;
     gamePath.FragScore = Fragmentation.GetFragmentationScore(board.Cells);
 }
Esempio n. 6
0
 public abstract void GatherPathStats(GamePath gamePath, Board board);
Esempio n. 7
0
 public abstract void GatherStepStats(Candidate candidate, GamePath gamePath, Board board, Board newBoard);