Esempio n. 1
0
func (self *Ground) Refresh_ground() {
	glog.Info("refresh...")
	// to implement
	for i, cata := range self.catapults {
		glog.Infof("----------------bot%d(%s):----------------", i, cata.name)
		glog.Infof("%v", cata)

	}
}
Esempio n. 2
0
File: main.go Progetto: jiedo/slingo
func main() {
	glog.Infof("This is a Catapults AI War platform.")

	////////////////////////////////////////////////////////////////
	glog.Infof("bots are join in...")

	cata := core.G_battle_ground.New_catapult()
	glog.Infof("bot(%s) in.", ibot.Bot.GetName())
	cata.Bot = ibot.Bot

	glog.Infof("join ok.")

	////////////////////////////////////////////////////////////////
	glog.Infof("now begin...")
	core.G_battle_ground.Start_all_catapults()
	//ibot.bot.Stop()
	glog.Infof("bots are all running now.")

	////////////////////////////////////////////////////////////////
	glog.Infof("begin cycle.")
	for {
		// one cycle
		glog.Infof("cycle.")
		core.G_battle_ground.Step_all_catapults()

		core.G_battle_ground.Update_ground()

		core.G_battle_ground.Refresh_ground()

		time.Sleep(time.Duration(1) * time.Second)
	}
	glog.Infof("end.")
}
Esempio n. 3
0
func (self *Ground) New_catapult() (cata *Catapult) {
	command_chan := make(chan ui.Command)
	instruction_chan := make(chan Instruction)
	glog.Infof("before new: %v", cata)
	cata = &Catapult{}
	glog.Infof("after new: %v", cata)
	cata.command_chan = command_chan
	cata.instruction_chan = instruction_chan
	go cata.interprete()

	self.catapults = append(self.catapults, cata)
	glog.Infof("catapults: %d", len(self.catapults))
	return cata
}
Esempio n. 4
0
func (self *Ground) Update_ground() {
	glog.Info("Update...")
	// to implement
	for i, cata := range self.catapults {
		glog.Infof("----------------bot%d(%s):----------------", i, cata.name)
		glog.Infof("%v", cata)

	}

	for i, ball := range self.balls {
		glog.Infof("----------------ball%d:----------------", i)
		glog.Infof("%v", ball)

	}

}
Esempio n. 5
0
func (self *Ground) Start_all_catapults() {
	for _, cata := range self.catapults {
		cata.name = cata.Bot.GetName()
		glog.Infof("bot(%s) start.", cata.name)
		go cata.Bot.Start(cata.command_chan)
	}
}
Esempio n. 6
0
func (self *Slingo) Start(command_chan chan ui.Command) {
	self.command_chan = command_chan

	for {
		result := self.run(0, 0)
		glog.Infof("running: %v ", result)
		time.Sleep(time.Duration(1) * time.Second)
	}
}