|
|
@ -39,7 +39,6 @@ func NewGenerationScoreCard(height, width int) *GenerationScoreCard {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (genScore *GenerationScoreCard) Calculate(state *GameState) error {
|
|
|
|
func (genScore *GenerationScoreCard) Calculate(state *GameState) error {
|
|
|
|
stateWidth := state.Width()
|
|
|
|
|
|
|
|
stateCells, err := state.Cells()
|
|
|
|
stateCells, err := state.Cells()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -54,14 +53,6 @@ func (genScore *GenerationScoreCard) Calculate(state *GameState) error {
|
|
|
|
xTarget := stateCell.X + neighbor.X
|
|
|
|
xTarget := stateCell.X + neighbor.X
|
|
|
|
yTarget := stateCell.Y + neighbor.Y
|
|
|
|
yTarget := stateCell.Y + neighbor.Y
|
|
|
|
|
|
|
|
|
|
|
|
if xTarget < 0 || yTarget < 0 {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if xTarget+1 > stateWidth || yTarget+1 > stateWidth {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cell := genScore.Get(xTarget, yTarget)
|
|
|
|
cell := genScore.Get(xTarget, yTarget)
|
|
|
|
genScore.Set(xTarget, yTarget, cell.Value+1)
|
|
|
|
genScore.Set(xTarget, yTarget, cell.Value+1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|