Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion BlockPuzzleConsole/Players/FullEvalPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class FullEvalPlayer : FullEvalPlayerBase
{
public override GamePath SelectBestPath(List<GamePath> paths)
{
var topScorePath = from x in paths orderby x.ScoreGain descending, x.CellCount descending, x.PlacementScore select x;
var topScorePath = from x in paths orderby x.Tsiun descending select x;

return topScorePath.First();
}
Expand All @@ -132,6 +132,53 @@ public override void GatherPathStats(GamePath gamePath, Board board)
{
gamePath.MaxArea = (float)MaxArea.MaximalRectangle(board.Cells)/64;
gamePath.FragScore = Fragmentation.GetFragmentationScore(board.Cells);
gamePath.Tsiun = GetTsiun(board);
}

public int GetTsiun(Board myBoard)
{
int[,] myScore = new int[8, 8];

for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
{
myScore[i, j] = 0;
if (!myBoard.Cells[i][j])
{
if (j > 0 && !myBoard.Cells[i][j - 1])
myScore[i, j] += 2;
if (j < 7 && !myBoard.Cells[i][j + 1])
myScore[i, j] += 2;
if (i > 0 && j > 0 && !myBoard.Cells[i - 1][j - 1])
myScore[i, j]++;
if (i > 0 && !myBoard.Cells[i - 1][j])
myScore[i, j] += 2;
if (j < 7 && i > 0 && !myBoard.Cells[i - 1][j + 1])
myScore[i, j]++;
if (i < 7 && !myBoard.Cells[i + 1][j])
myScore[i, j] += 2;
if (j > 0 && i < 7 && !myBoard.Cells[i + 1][j - 1])
myScore[i, j]++;
if (j < 7 && i < 7 && !myBoard.Cells[i + 1][j + 1])
myScore[i, j]++;
if (j < 6 && !myBoard.Cells[i][j + 2] && !myBoard.Cells[i][j + 1])
myScore[i, j] += 3;
if (j > 1 && !myBoard.Cells[i][j - 2] && !myBoard.Cells[i][j - 1])
myScore[i, j] += 3;
if (i < 6 && !myBoard.Cells[i + 2][j] && !myBoard.Cells[i + 1][j])
myScore[i, j] += 3;
if (i > 1 && !myBoard.Cells[i - 2][j] && !myBoard.Cells[i - 1][j])
myScore[i, j] += 3;
if (j > 1 && j < 6 && !myBoard.Cells[i][j - 1] && !myBoard.Cells[i][j + 1] && !myBoard.Cells[i][j - 2] && !myBoard.Cells[i][j + 2])
myScore[i, j] += 2;
}
}
int Score = 0;
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
Score += myScore[i, j];
return Score;

}
}

Expand All @@ -144,6 +191,7 @@ class GamePath
public int CellCount { get; set; }
public float PlacementScore { get; set; }
public float MaxArea { get; set; }
public int Tsiun { get; set; }
public float FragScore { get; set; }

public IList<Candidate> Moves { get; set; }
Expand Down