LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-09-2003, 12:34 PM   #1
Luantum
Member
 
Registered: Oct 2003
Distribution: Slackware 9.1
Posts: 48

Rep: Reputation: 15
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
 
Old 11-09-2003, 03:34 PM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Is this a question, or are you just sharing?
 
Old 11-09-2003, 04:05 PM   #3
Luantum
Member
 
Registered: Oct 2003
Distribution: Slackware 9.1
Posts: 48

Original Poster
Rep: Reputation: 15
Im sharing but I also want some ideas about how to improve.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Serious questions about life ( or better the life of a programmer) alaios Programming 11 10-04-2005 11:37 AM
Windows: 4-5 hour battery life, Gentoo : ~2:30 battery life numerous Linux - Laptop and Netbook 3 01-17-2005 08:39 PM
windows, good battery life -> fedora, bad battery life daedalusq1115 Linux - Laptop and Netbook 1 01-17-2005 06:40 AM
Mandrake Bugs webterractive Linux - Distributions 0 04-11-2004 05:28 PM
Are 9.2 bugs fixed? wiggywag Mandriva 4 11-12-2003 12:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration