Added a new score possibility, not working properly yet !
continuous-integration/drone/push Build is passing Details

test_old_branch
Jules LASCRET 11 months ago
parent 98b840235e
commit 5f2beb825c

@ -410,6 +410,11 @@ namespace QwirkleClassLibrary.Games
int score = cellsPlayed.Count; int score = cellsPlayed.Count;
if (cellsPlayed.Count == 6)
{
score += 6;
}
int cellsX = cellsPlayed[0].GetX; int cellsX = cellsPlayed[0].GetX;
int cellsY = cellsPlayed[0].GetY; int cellsY = cellsPlayed[0].GetY;
@ -462,17 +467,17 @@ namespace QwirkleClassLibrary.Games
int dx = adjacentCell.GetX - cell.GetX; int dx = adjacentCell.GetX - cell.GetX;
int dy = adjacentCell.GetY - cell.GetY; int dy = adjacentCell.GetY - cell.GetY;
score += CalculateLineScore(cell, dx, dy, b, cellsX, cellsY); score += CalculateLineScore(cell, dx, dy, b, cellsX, cellsY, cellsPlayed.Count);
} }
return score; return score;
} }
public int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY) public int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY, int nbCellsPlayed)
{ {
int score = 0; int score = 0;
for (int i = 1; i < 7; i++) for (int i = 1; i < 6; i++)
{ {
var extendedCell = b.GetCell(cell.GetX + i * dx, cell.GetY + i * dy); var extendedCell = b.GetCell(cell.GetX + i * dx, cell.GetY + i * dy);
@ -481,6 +486,11 @@ namespace QwirkleClassLibrary.Games
continue; continue;
} }
if (dx != 0 && cellsY != -1 && nbCellsPlayed + i == 6 || dy != 0 && cellsX != -1 && nbCellsPlayed + i == 6)
{
score += 6;
}
score++; score++;
} }

@ -23,5 +23,5 @@ public interface IPlayer
int CalculateAdjacentScore(Cell cell, Board b, ReadOnlyCollection<Cell> cellsPlayed, int cellsX, int cellsY); int CalculateAdjacentScore(Cell cell, Board b, ReadOnlyCollection<Cell> cellsPlayed, int cellsX, int cellsY);
int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY); int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY, int nbCellsPlayed);
} }
Loading…
Cancel
Save