By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,525 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,525 IT Pros & Developers. It's quick & easy.

Re: Python fish simulation?

P: n/a
Is there any Python-based fish simulation project? I've tried
searching google and pypi, but no luck. No burning need, just seems
like it'd be fun.
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 YoureALoonyException(owner)

john = Person("John")
michael = Person("Michael")
michael.hands.left = Fish(None, size=Fish.LITTLE)
michael.hands.right = Fish(None, size=Fish.LITTLE)
john.fish = Fish(None, size=Fish.HUGE)
michael.hands.left.slap(john)
sleep(1)
michael.hands.right.slap(john)
for _ in range(2):
sleep(1)
michael.hands.left.slap(john)
michael.hands.right.slap(john)
sleep(3)
john.fish.slap(michael)

pet = Halibut("Eric")
pet.license(john)
Hope this fish simulation meets your needs...

-tkc
[1]
http://www.youtube.com/watch?v=pnq96W9jtuw

[2]
http://www.youtube.com/watch?v=i9SSOWORzw4


Nov 10 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.