Bugs set current field to negative weight too (otherwise collission if both walk in opposite directions)

This commit is contained in:
Armin Friedl 2017-11-10 20:29:47 +01:00
parent b7f5febf15
commit e337739b04

View file

@ -4,6 +4,7 @@ import bot.environment.topology.Point
import bot.environment.Board import bot.environment.Board
import bot.Game import bot.Game
import bot.environment.topology.Grid import bot.environment.topology.Grid
import bot.util.Log.dbg
class BugAI extends Tactical { class BugAI extends Tactical {
def evaluate(game: Game): Tactic = { def evaluate(game: Game): Tactic = {
@ -12,14 +13,19 @@ class BugAI extends Tactical {
val weightGrid = new Grid(board.width, board.height, 0: Int) val weightGrid = new Grid(board.width, board.height, 0: Int)
board.bugs foreach { weightGrid(_) put -1000 }
for ( bug <- board.bugs; point <- board.walkablePoints(bug.point) ) { for ( bug <- board.bugs; point <- board.walkablePoints(bug.point) ) {
weightGrid(point).content += -1000 val field = weightGrid(point)
field put (field.content - 1000)
} }
board.walkableDirs(game.bofaPoint) foreach { dir => board.walkableDirs(game.bofaPoint) foreach { dir =>
tactic = tactic + {dir -> weightGrid(board.walk(game.bofaPoint)(dir)).content} tactic = tactic + {dir -> weightGrid(board.walk(game.bofaPoint)(dir)).content}
} }
dbg(s"$weightGrid")
tactic tactic
} }
} }