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 TwoDiagonalCornerCells() { Board board = new Board(); board.Cells[0][0] = true; board.Cells[7][7] = true; Assert.AreEqual(49, MaxArea.MaximalRectangle(board.Cells)); }
public void HalfAndMoreOfAllCells() { Board board = new Board(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { board.Cells[i][j] = true; } } Assert.AreEqual(32, MaxArea.MaximalRectangle(board.Cells)); }
public void AllCells() { Board board = new Board(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { board.Cells[i][j] = true; } } Assert.AreEqual(0, MaxArea.MaximalRectangle(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 SingleCornerCell() { Board board = new Board(); board.Cells[0][0] = true; Assert.AreEqual(56, MaxArea.MaximalRectangle(board.Cells)); board.Cells[0][0] = false; board.Cells[7][0] = true; Assert.AreEqual(56, MaxArea.MaximalRectangle(board.Cells)); board.Cells[7][0] = false; board.Cells[0][7] = true; Assert.AreEqual(56, MaxArea.MaximalRectangle(board.Cells)); board.Cells[0][7] = false; board.Cells[7][7] = true; Assert.AreEqual(56, MaxArea.MaximalRectangle(board.Cells)); board.Cells[7][7] = false; }
public void QuarterOfAllCells() { Board board = new Board(); for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { board.Cells[i][j] = true; } } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { board.Cells[i][j] = false; } } Assert.AreEqual(16, MaxArea.MaximalRectangle(board.Cells)); }
public override void GatherPathStats(GamePath gamePath, Board board) { gamePath.MaxArea = (float)MaxArea.MaximalRectangle(board.Cells) / 64; gamePath.FragScore = Fragmentation.GetFragmentationScore(board.Cells); }
public void EmptyMatrix() { Board board = new Board(); Assert.AreEqual(64, MaxArea.MaximalRectangle(board.Cells)); }