[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SigBio] some code that maybe sort of could work as a basis for whack-a-mole
- To: sigbio-l@xxxxxxxxxxxx
- Subject: [SigBio] some code that maybe sort of could work as a basis for whack-a-mole
- From: "Charith Jayasinghe" <cjayasi2@xxxxxxxx>
- Date: Mon, 22 Oct 2007 23:51:22 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; bh=41/lh7MGYGu5oMBkJVOa08/Cwr0UahQuvYC2EhGNFh4=; b=kFt4UEAL9hmgIGp6lGTuTzjgHrR8Am7fh7KGbSpFtIa0xX9nYYRBe6g/nFMJmOaSmFmGMKlMjfrmS8rBUHaWn+TqYoCorTIow94q7rS34u5inj0cmnB3sTYIIzpI506dhCzSuGGz7QqHzGDgeixPFI1gEiT7+9yxM33Jp0a8Muc=
- Reply-to: Cyborg mayhem / SigBio <sigbio-l@xxxxxxxxxxxx>
- Sender: lankafool@xxxxxxxxx
It's just a grid of 9 zeroes, and then at random times (the length of time that it remains all zeroes varies from 1 to 9 seconds randomly) one of them will change to a 1.
then perhaps you could do:
if (grid[x][y]==1):
#code that would graphically display a mole in specific coordinates
Oh, and for mac users, replace the line os.system('CLS'); with
os.system('clear');
-Charith
#! /usr/bin/env python
import random;
import time;
go =0;
cin = 1;
start = time.clock();
while (cin==1):
#print start;
#ab =0;
#for sd in range(0,100):
# ab=ab+1;
#print time.clock();
go =0;
ptime = random.randrange(0,10);
ptime=ptime-.02;
while (go==0):
grid = [[0,0,0],[0,0,0],[0,0,0]];
time.sleep(1);
x = random.randrange(0,3);
y = random.randrange(0,3);
go =1;
if (time.clock()-start>ptime):
grid[x][y]=1;
start = time.clock();
ptime = random.randrange(0,10);
ptime=ptime-.02;
import os;
os.system('CLS');
for sx in range(0,3):
print str(grid[sx])+'\n';