Bugs set current field to negative weight too (otherwise collission if both walk in opposite directions)
This commit is contained in:
parent
b7f5febf15
commit
e337739b04
1 changed files with 8 additions and 2 deletions
|
@ -4,6 +4,7 @@ import bot.environment.topology.Point
|
|||
import bot.environment.Board
|
||||
import bot.Game
|
||||
import bot.environment.topology.Grid
|
||||
import bot.util.Log.dbg
|
||||
|
||||
class BugAI extends Tactical {
|
||||
def evaluate(game: Game): Tactic = {
|
||||
|
@ -12,14 +13,19 @@ class BugAI extends Tactical {
|
|||
|
||||
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) ) {
|
||||
weightGrid(point).content += -1000
|
||||
val field = weightGrid(point)
|
||||
field put (field.content - 1000)
|
||||
}
|
||||
|
||||
board.walkableDirs(game.bofaPoint) foreach { dir =>
|
||||
tactic = tactic + {dir -> weightGrid(board.walk(game.bofaPoint)(dir)).content}
|
||||
}
|
||||
|
||||
dbg(s"$weightGrid")
|
||||
|
||||
tactic
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue