⚙️ method Bot.SimplePathfind(...)
Last updated:4/16/2026
URL
https://github.com/42core-team/monorepo/blob/dev/bots/go/client_lib/actions.go
Description
Very simple pathfinding logic implementation. It won't help you win, but it can be used to easily get started while you figure out how the game works.
When you call it, it will determine the next move to make. It automatically attacks enemy objects in its way (provided they aren't your units or core) and returns the position to move to. You need to call Bot.Move with the returned position yourself.
It is encouraged that you write your own pathfinder eventually for a good bot using Bot.Move and Bot.Attack, this function is just a util for you to easily get started.
Signature
func (b *Bot) SimplePathfind(unit *game.Object, targetPos game.Position) game.PositionParameters
unit *game.Object: The unit that should movetargetPos game.Position: The position the unit should pathfind towards
Return
game.Position: The next position the unit should move to. CallBot.Movewith this position. Returns the unit's current position if no move is possible.
Examples
teamWarriors := g.ObjectsFilter(func(obj *game.Object) bool {
data := obj.GetUnitData()
return obj.Type == game.ObjectUnit && data != nil && data.TeamID == g.MyTeamID && data.UnitType == game.UnitWarrior
})
for _, warrior := range teamWarriors {
enemyCore := g.EnemyCore()
if enemyCore != nil {
nextPos := b.SimplePathfind(warrior, enemyCore.Pos)
b.Move(warrior, nextPos)
}
}