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); }
public void NoFragsTest() { Board board = new Board(); Assert.IsTrue(Math.Abs(1F - Fragmentation.GetFragmentationScore(board.Cells)) < 0.0001); Assert.AreEqual(0, Fragmentation.SurroundedSignals(board.Cells)); }
public void SomeFragsTest() { Board board = new Board(); board.Cells[0][0] = true; Assert.IsTrue(Math.Abs(0.966666639F - Fragmentation.GetFragmentationScore(board.Cells)) < 0.0001); Assert.AreEqual(0, Fragmentation.SurroundedSignals(board.Cells)); }
public void MaxFragTest() { Board board = new Board(); for (int x = 0; x < 8; x = x + 2) { for (int y = 0; y < 8; y++) { board.Cells[x + (y % 2)][y] = true; } } Assert.IsTrue(Math.Abs(0F - Fragmentation.GetFragmentationScore(board.Cells)) < 0.0001); Assert.AreEqual(32, Fragmentation.SurroundedSignals(board.Cells)); }
public void MakeAMove(out int shapeId, out string placement, Board board, IDictionary <int, Shape> shapes, IGameDrawer renderer) { placement = ""; shapeId = 0; var candidates = new List <Candidate>(); foreach (var shape in shapes) { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { var newBoard = new Board(board); var curPlacement = "" + (char)(97 + x) + (char)(49 + y); if (newBoard.TryPlace(shape.Value, curPlacement)) { var candidate = new Candidate() { Placement = curPlacement, ShapeId = shape.Key, ScoreGain = (newBoard.Score - shape.Value.Score) - board.Score, CellsGain = newBoard.CellCount() - board.CellCount(), LinesScore = newBoard.LinesScore(), MaxArea = MaxArea.MaximalRectangle(newBoard.Cells), FragScore = Fragmentation.GetFragmentationScore(newBoard.Cells) }; candidates.Add(candidate); } } } } var maxAreaList = from x in candidates orderby x.MaxArea descending, x.FragScore descending select x; var fragScoreList = from x in candidates orderby x.FragScore descending, x.MaxArea descending select x; var maxArea = maxAreaList.First(); var fragScore = fragScoreList.First(); var final = fragScore.MaxArea < 0.32F ? maxArea : fragScore; placement = final.Placement; shapeId = final.ShapeId; }
public void SurroundFragsTest() { Board board = new Board(); board.Cells[1][0] = true; board.Cells[0][1] = true; board.Cells[6][0] = true; board.Cells[7][1] = true; board.Cells[0][6] = true; board.Cells[1][7] = true; board.Cells[6][7] = true; board.Cells[7][6] = true; Assert.IsTrue(Math.Abs(0.7666667F - Fragmentation.GetFragmentationScore(board.Cells)) < 0.0001); Assert.AreEqual(4, Fragmentation.SurroundedSignals(board.Cells)); }
public override void GatherPathStats(GamePath gamePath, Board board) { gamePath.MaxArea = (float)MaxArea.MaximalRectangle(board.Cells) / 64; gamePath.FragScore = Fragmentation.GetFragmentationScore(board.Cells); }