Add decay logic to healing pools (#97)
* adding logic to remove healing pools periodically to prevent extended length games * Fix for the case where ShrinkEveryNTurns is not set
This commit is contained in:
parent
215a0ea998
commit
91106aec09
2 changed files with 25 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package maps
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"github.com/BattlesnakeOfficial/rules"
|
||||
)
|
||||
|
||||
|
|
@ -48,7 +50,17 @@ func (m HealingPoolsMap) SetupBoard(initialBoardState *rules.BoardState, setting
|
|||
}
|
||||
|
||||
func (m HealingPoolsMap) UpdateBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
|
||||
return StandardMap{}.UpdateBoard(lastBoardState, settings, editor)
|
||||
if err := (StandardMap{}).UpdateBoard(lastBoardState, settings, editor); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if lastBoardState.Turn > 0 && settings.RoyaleSettings.ShrinkEveryNTurns > 0 && len(lastBoardState.Hazards) > 0 && lastBoardState.Turn%settings.RoyaleSettings.ShrinkEveryNTurns == 0 {
|
||||
// Attempt to remove a healing pool every ShrinkEveryNTurns until there are none remaining
|
||||
i := rand.Intn(len(lastBoardState.Hazards))
|
||||
editor.RemoveHazard(lastBoardState.Hazards[i])
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var poolLocationOptions = map[rules.Point][][]rules.Point{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue