求助...
codecombat吧
全部回复
仅看楼主
level 1
相位转移 楼主
2015年02月13日 03点02分 1
level 1
相位转移 楼主
# Get to the oasis,
# fencing off paths with yaks on them as you go.
loop:
yak = self.findNearestEnemy()
if yak:
ypos = yak.pos
fx = ypos.x
fy = ypos.y
# If the yak is above you, build a fence 10m below it.
#distance = self.distanceTo(yak)
if fy > self.pos.y :
self.buildXY("fence",fx, fy - 10)
# If the yak is below you, build a fence 10m above it.
#else:
#elif yak.pos.y < self.pos.y :
#pass
if fy < self.pos.y:
self.buildXY("fence", fx, fy + 10)
pass
else:
# Move right 10m towards the oasis.
self.moveXY(self.pos.x+10 , self.pos.y)
# pass
2015年02月13日 03点02分 2
level 1
2015年03月03日 12点03分 4
level 1
相位转移 楼主
2015年03月03日 13点03分 5
level 1
这个比较准确,只是把上图 self.buildXY("fence", self.pos.x, yak.pos.y - 10)中的 self.pos.x 改成 yak.pos.x
self.buildXY("fence", self.pos.x, yak.pos.y + 10)中的 self.pos.x 改成 yak.pos.x
2015年03月03日 13点03分 6
1