LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bugs Life (https://www.linuxquestions.org/questions/programming-9/bugs-life-114126/)

Luantum 11-09-2003 12:34 PM

Bugs Life
 
PHP Code:

import random


random
.seed()

def Bug(num=1):




    
life 10

    
while life != 0:

        
wait raw_input("Wait... ")

        
luck random.random()
        
luck luck 100
        
#rint luck

        
chance random.random()
        
chance chance 10
        
#rint chance



        
if luck <= 68:
            print 
"Bug %d got food" %(num)
            
life life 1

        
else:
            print 
"Bug %d got no food" %(num)
            
life life 1


        
if chance <= 3:
            print 
"Bug %d got sick" %(num)
            
life life 2
        
else:
            
pass

        
if luck <= 23:
            print 
"Bug %d reproduced and died!     !!!" %(num)
            
life 0
            Bug
(num 1)

        else:
            
pass


Bug
() 


Just some (bad) AI I made in Python. Cut me some slack Im a newbie :)

Luantum

wapcaplet 11-09-2003 03:34 PM

Is this a question, or are you just sharing? :)

Luantum 11-09-2003 04:05 PM

Im sharing but I also want some ideas about how to improve.


All times are GMT -5. The time now is 12:40 AM.