-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 1.43 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"log"
"github.com/lugobots/lugo4go/v3"
"my-bot/bot"
)
func main() {
connectionStarter, defaultFieldMapper, err := lugo4go.NewDefaultStarter()
if err != nil {
log.Fatalf("failed to load the bot configuration: %s", err)
}
// OPTIONAL
// define your own field mapper! The default number of col/rows are defined by lugo4go.DefaultFieldMapCols and lugo4go.DefaultFieldMapRows
//defaultFieldMapper, err = field.NewMapper(NUM_COLS, NUM_ROWS, connectionStarter.Config.TeamSide)
//if err != nil {
// log.Fatalf("failed to create a field mapper: %s", err)
//}
// create your bot as you wish
// in this example, the bot requires the field mapper, the connection config, and a logger.
myBot := bot.NewBot(
defaultFieldMapper,
connectionStarter.Config,
connectionStarter.Logger,
)
// Here you define the initial position of your bot. It's important to use the field mapper instead of points because
// the field mapper won't be affected when your bot is playing on the away side
initialPosition := bot.DefaultInitialPositions[connectionStarter.Config.Number]
region, err := defaultFieldMapper.GetRegion(initialPosition.Col, initialPosition.Row)
if err != nil {
log.Fatalf("failed to define initial position using field mapper: %s", err)
}
connectionStarter.Config.InitialPosition = region.Center()
// then lets play
if err := connectionStarter.Run(myBot); err != nil {
log.Fatalf("bot stopped: %s", err)
}
}