#讲道理乌龟吃鱼的嘛?
先上代码,虽然感觉很多地方可以优化
import random
import time
class Tortoise:
x = random.randint(0,10)
y = random.randint(0,10)
def __init__(self):
self.life = 100
print('Tortoise: (%d,%d)'%(self.x,self.y))
print('life : %d'%(self.life))
def move(self):
step = random.randint(1,2)
direction = random.randint(-1,2)
self.life -= step
if direction == 2:
if self.x + step - 10 == 1:
self.x = 9
elif self.x + step - 10 == 2:
self.x = 8
else:
self.x +=</