Beispiel #1
1
func (me *ghengis) tilePositions(env *antwar.Tile) map[*antwar.Tile]pos {
	return map[*antwar.Tile]pos{
		env.Here():  me.pos,
		env.North(): pos{me.pos.x, me.pos.y + 1},
		env.East():  pos{me.pos.x + 1, me.pos.y},
		env.South(): pos{me.pos.x, me.pos.y - 1},
		env.West():  pos{me.pos.x - 1, me.pos.y},
	}
}
Beispiel #2
0
func (a *naiveAnt) Decide(env *antwar.Tile, brains []antwar.AntBrain) (decision antwar.Action, bringFood bool) {
	if env.FoodCount() > 0 {
		decision = a.directionHome()
	} else if env.North().FoodCount() > 0 {
		decision = antwar.NORTH
	} else if env.East().FoodCount() > 0 {
		decision = antwar.EAST
	} else if env.South().FoodCount() > 0 {
		decision = antwar.SOUTH
	} else if env.West().FoodCount() > 0 {
		decision = antwar.WEST
	} else {
		decision = a.directionOut()
	}
	a.update(decision)
	bringFood = env.FoodCount() > 0
	return
}