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.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)
|
||||||
|
|
||||||
for ( bug <- board.bugs; point <- board.walkablePoints(bug.point) ) {
|
board.bugs foreach { weightGrid(_) put -1000 }
|
||||||
weightGrid(point).content += -1000
|
|
||||||
|
for ( bug <- board.bugs; point <- board.walkablePoints(bug.point) ) {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue