75 lines
1.1 KiB
Go
75 lines
1.1 KiB
Go
package lib
|
|
|
|
type myAI struct {
|
|
robots []*myRobot
|
|
scenes []*scene
|
|
callers []ICaller
|
|
}
|
|
|
|
func NewAI() *myAI {
|
|
ai := &myAI{
|
|
// action: NewAction(),
|
|
scenes: make([]*scene, 0),
|
|
}
|
|
|
|
// ai.action = NewAction(ai)
|
|
|
|
ai.init()
|
|
|
|
return ai
|
|
}
|
|
|
|
func (m *myAI) init() {
|
|
//初始化机器人容量
|
|
// 容量限制
|
|
|
|
}
|
|
|
|
//启动时载入所有Caller
|
|
func (m *myAI) LoadCallers() []ICaller {
|
|
return m.callers
|
|
|
|
}
|
|
|
|
// 初始化caller
|
|
func (m *myAI) InitCaller(callers ...ICaller) {
|
|
m.callers = append(m.callers, callers...)
|
|
}
|
|
|
|
// 加入机器人
|
|
func (m *myAI) AddRobots(num int, scene *scene) {
|
|
//
|
|
robot := NewRobot()
|
|
robot.SelScene(scene)
|
|
m.robots = append(m.robots, robot)
|
|
}
|
|
|
|
// 获取场景下的机器人
|
|
func (m *myAI) GetRobots(sceneName string) (robots []*myRobot) {
|
|
for _, robot := range m.robots {
|
|
scene := robot.GetCurrentScene()
|
|
if scene != nil && scene.Name == sceneName {
|
|
robots = append(robots, robot)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (m *myAI) Start() {
|
|
//启动默认数量的机器人
|
|
|
|
r := NewRobot()
|
|
//
|
|
|
|
r.Start()
|
|
|
|
}
|
|
|
|
func (m *myAI) Stop() {
|
|
|
|
}
|
|
|
|
func (m *myAI) ShowResult() {
|
|
|
|
}
|