Is there any Python-based fish simulation project? I've tried
Without much detail on what you want to simulate...
class Fish:
LITTLE, HUGE = range(2)
def __init__(self, name, size=None):
self.name = name
self.size = size
def swim(self):
print "blub..."
def slap(self, who):
"see here[2]"
if self.size:
if self.size == Fish.LITTLE:
print "slap"
else:
print "SLAP"
else:
print "Slap"
class Halibut(Fish):
def license(self, owner):
"See here[1]"
raise YoureALoonyExce ption(owner)
john = Person("John")
michael = Person("Michael ")
michael.hands.l eft = Fish(None, size=Fish.LITTL E)
michael.hands.r ight = Fish(None, size=Fish.LITTL E)
john.fish = Fish(None, size=Fish.HUGE)
michael.hands.l eft.slap(john)
sleep(1)
michael.hands.r ight.slap(john)
for _ in range(2):
sleep(1)
michael.hands.l eft.slap(john)
michael.hands.r ight.slap(john)
sleep(3)
john.fish.slap( michael)
pet = Halibut("Eric")
pet.license(joh n)
Hope this fish simulation meets your needs...
-tkc
[1]
[2]
searching google and pypi, but no luck. No burning need, just seems
like it'd be fun.
like it'd be fun.
class Fish:
LITTLE, HUGE = range(2)
def __init__(self, name, size=None):
self.name = name
self.size = size
def swim(self):
print "blub..."
def slap(self, who):
"see here[2]"
if self.size:
if self.size == Fish.LITTLE:
print "slap"
else:
print "SLAP"
else:
print "Slap"
class Halibut(Fish):
def license(self, owner):
"See here[1]"
raise YoureALoonyExce ption(owner)
john = Person("John")
michael = Person("Michael ")
michael.hands.l eft = Fish(None, size=Fish.LITTL E)
michael.hands.r ight = Fish(None, size=Fish.LITTL E)
john.fish = Fish(None, size=Fish.HUGE)
michael.hands.l eft.slap(john)
sleep(1)
michael.hands.r ight.slap(john)
for _ in range(2):
sleep(1)
michael.hands.l eft.slap(john)
michael.hands.r ight.slap(john)
sleep(3)
john.fish.slap( michael)
pet = Halibut("Eric")
pet.license(joh n)
Hope this fish simulation meets your needs...
-tkc
[1]
[2]