Re: [Tutor] RPG game.

2005-05-20 Thread Kooser, Ara S
Could you post the error message?

Ara






Fatti non foste per viver come bruti, ma per seguir virtute e canoscenza
- Dante Alighieri

You were not made to live like brutes, but to pursue virtue and
knowledge


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of . ,
Sent: Friday, May 20, 2005 5:56 AM
To: tutor@python.org
Subject: [Tutor] RPG game.


I'm trying to make an RPG game which is only consisted of texts. But, it

doesn't work!

thanks.


---
import random

print \
  Warrior - damage: 10~60
  Archer - damage: 0~100
  HP of Player: 100
  HP of the monster: 300

wp = raw_input(\n\nSelect between warrior and Archer )

mob = 300
hit = 0
hp = 100
run = 

while True:
while (mob  0):
hit += 1
mob = mob - dmg
hp = hp - atk

if (hp  0):
print \nYour, wp, has died by the monster(, mob, hp)
break

elif wp == warrior:
dmg = random.randrange(50) + 10
atk = random.randrange(10)

elif wp == archer:
dmg = random.randrange(100)
atk - random.randrage(5)

print \n, hit, hits
print HP of, wp,:, hp,/100
print HP of the monster:, mob,/300

print \nYou defeated the monster by, hit,hits,, dmg,damage

run = raw_input(\n\nrun or exit )

if run == exit:
break

elif run == run:
continue
else:
raw_input(\nError)
break

---

_
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


RE: [Tutor] Re: Interesting anomaly with the Eight Queens problem

2005-04-13 Thread Kooser, Ara S
If you go here http://en.wikipedia.org/wiki/Eight_queens_puzzle Down at
the bottom page is a very short python program that gives the solutions
to the eight queens problem in a very neat manner.

Ara




There is something to be learned from a rainstorm. When meeting with a
sudden shower, you try not to get wet and run quickly along the road.
But doing such things as passing under the eaves of houses, you still
get wet. When you are resolved from the beginning, you will not be
perplexed, though you still get the same soaking. - Yamamoto Tsunetomo


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Lee Cullens
Sent: Wednesday, April 13, 2005 11:04 AM
To: [EMAIL PROTECTED]
Cc: tutor@python.org
Subject: Re: [Tutor] Re: Interesting anomaly with the Eight Queens
problem


John

The type of problem you mention and the extent of positioning you go to 
could result in an incomplete solution.  In very general terms one 
would need to place the first Queen then find an appropriate position 
for the second, and each of the remaining Queens in turn until either 
there are no appropriate positions to be found or all eight Queens have 
been positioned.  If all eight Queens can not be positioned, then the 
first Queen would be moved and the remaining Queen positioning worked 
through again.

This is a made for recursion type of problem, but could be done with 
nested loops.

The Trying everything approach can , of course, be a very lengthy 
process.  I seem to remember a more sophisticated model for this type 
of problem (I think somehow related to linear algebra) but can't recall 
the specifics at the moment.  Maybe one of the more academic (an 
younger) members of this list can point you in such a direction.

Lee C

On Apr 13, 2005, at 12:15 PM, [EMAIL PROTECTED] wrote:

 I read through Magnus Hetland's book and noticed the Eight Queens
 problem, which I had solved some time ago using Visual Basic.

 This time, I wanted to use a non-recursive solution. I randomly place
 each queen on board coordinates running from 0,0(top left hand corner 
 of board) to 7,7(lower right hand corner of board)

 Here's the interesting part: I can only get eight queens safely on the
 board perhaps every one in 20 runs. At least 12 or 13 of those times, 
 I can place seven queens, while five or six times, I can only place 
 six queens or even five!

 Once a queen is safely placed, I establish her territory. Once this
 is done, when I try to place a subsequent queen, I check for all 
 placed queen's territories. Once I place six or seven queens, I have 
 to give the program a lot more tries to try to find a safe square. And

 it can't always be done.

 Does this sound right? Does trying to place each queen randomly cause
 this anomaly?

 I can post my code(beginner code!) if anyone is interested in seeing
 it.

 Best,

 John

 =
 John Soares, Webmaster
 Family Safe Surfinghttp://www.family-safe-surfing.net
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

 Tel: (810) 343-0571
 Fa x: (866) 895-3082

 Your best bet for online family-friendly resources 
 =

 ___
 Tutor maillist  -  Tutor@python.org 
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


RE: [Tutor] Python starting books

2005-04-12 Thread Kooser, Ara S
I've used http://www.freenetpages.co.uk/hp/alan.gauld/ Alan Gauld's both
for myself and to teach my students.

Ara



There is something to be learned from a rainstorm. When meeting with a
sudden shower, you try not to get wet and run quickly along the road.
But doing such things as passing under the eaves of houses, you still
get wet. When you are resolved from the beginning, you will not be
perplexed, though you still get the same soaking. - Yamamoto Tsunetomo


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Alexis
Sent: Tuesday, April 12, 2005 12:14 PM
To: tutor@python.org
Subject: [Tutor] Python starting books


Hi, i would like to know if someone could recommend me some books to get
started not only the first book to read but if possible a few to
continue learning also.

thnx in advance
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


RE: [Tutor] Python starting books

2005-04-12 Thread Kooser, Ara S
You can also check out How to Think Like a Computer Scientist at
http://www.ibiblio.org/obp/thinkCSpy/ .

Alan's page is up I checked it using Firefox.

Ara



There is something to be learned from a rainstorm. When meeting with a
sudden shower, you try not to get wet and run quickly along the road.
But doing such things as passing under the eaves of houses, you still
get wet. When you are resolved from the beginning, you will not be
perplexed, though you still get the same soaking. - Yamamoto Tsunetomo


-Original Message-
From: Alexis [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 12, 2005 12:31 PM
To: Kooser, Ara S
Cc: tutor@python.org
Subject: Re: [Tutor] Python starting books


Thnx for the info.

Unfortunately the site is unavailable

Not Found
The requested URL /hp/alan.gauld/ was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use
an ErrorDocument to handle the request.

Will try searching for these documents later and tell you if i find
anything

Thanks again,
Alexis

On Apr 12, 2005 3:25 PM, Kooser, Ara S [EMAIL PROTECTED] wrote:
 I've used http://www.freenetpages.co.uk/hp/alan.gauld/ Alan Gauld's 
 both for myself and to teach my students.
 
 Ara
 
 There is something to be learned from a rainstorm. When meeting with 
 a sudden shower, you try not to get wet and run quickly along the 
 road. But doing such things as passing under the eaves of houses, you 
 still get wet. When you are resolved from the beginning, you will not 
 be perplexed, though you still get the same soaking. - Yamamoto 
 Tsunetomo
 
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
 Behalf Of Alexis
 Sent: Tuesday, April 12, 2005 12:14 PM
 To: tutor@python.org
 Subject: [Tutor] Python starting books
 
 Hi, i would like to know if someone could recommend me some books to 
 get started not only the first book to read but if possible a few to 
 continue learning also.
 
 thnx in advance ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


RE: [Tutor] and once i have learned how to program ?

2005-03-11 Thread Kooser, Ara S
Title: RE: [Tutor] and once i have learned how to program ?






http://starship.python.net/crew/theller/py2exe/

This website is a good starting point.

Ara


-Original Message-
From: [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED]
Sent: Fri 3/11/2005 12:26 PM
To: tutor@python.org
Subject: [Tutor] and once i have learned how to program ?

Once i have learned how to program what can i do with the programs can they
run out side of the python shell like on My OS or a game? My OS is window XP
home





___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Printing columns of data

2005-02-08 Thread Kooser, Ara S
Title: Printing columns of data






Hello all,


 I am writing a program to take a data file, divide it up into columns and print the information back with headers. The data files looks like this

 0.0 -3093.44908 -3084.59762 387.64329 26.38518 0.3902434E+00 -0.6024320E-04 0.4529416E-05

 1.0 -3094.09209 -3084.52987 391.42288 105.55994 0.3889897E+00 -0.2290866E-03 0.4187074E-03

 2.0 -3094.59358 -3084.88826 373.64911 173.44885 0.3862430E+00 -0.4953443E-03 0.2383621E-02

 etc

 10.0 ...


So I wrote the program included below and it only prints the last line of the file.


Timestep PE

10.0 -3091.80609 


I have one question. Do I need to put ts and pe into a list before I print then to screen or I am just missing something. Thanks.

Ara


import string


inp = open(fort.44,r)

all_file = inp.readlines()

inp.close()


outp = open(out.txt,w)


cols = map(string.split,all_file)

##print cols


Data = "">

for line in cols:

 ts = line[0]

# print line[0]

 pe = line[1]

# print line[1]


print 


Timestep PE

print %s %s  % (ts,pe)



outp.close()



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Percolation model in python

2005-02-06 Thread Kooser, Ara S
Title: Percolation model in python






Hello,

 I have been working with some high school students to create a model of small pox transmission.
 I am somewhat new to python (my programming experience is in f77) so I have borrowed parts of Danny's code that he posted for the Game of Life. I have included the code that we are using below.
 I have two questions. Once a MxN world is generated how would you search for nearest neighbors (to see who is connected) and then color the '*' so it's easier to see who is connected and who isn't.

For a definition of percolation theory- http://en.wikipedia.org/wiki/Percolation_theory
or for the wolfram fans http://mathworld.wolfram.com/PercolationTheory.html

Thanks,
Ara

CODE STARTS HERE:

print 
Please pick your option:
1) Percolation model for Small Pox
2)
3) Instructions
4) Exit


option = raw_input(Which option[1,2,3,4]? )


if option == '1':

 import random

 perc = raw_input(Please enter a thresold between 0-1. )
 perc = float(perc)


 ###
 PERSON, EMPTY = '*', '.'
 ###

 ###

 def percolation(perc):
 randval = random.random()
 if randval  perc:
 return EMPTY
 else:
 return PERSON

 def make_random_world(M, N):
 Constructs a new random game world of size MxN.
 world = {}
 for j in range(N):
 for i in range(M):
 world[i, j] = percolation(perc)
 world['dimensions'] = (M, N)
 return world

 def print_world(world):
 Prints out a string representation of a world.
 M, N = world['dimensions']
 for j in range(N):
 for i in range(M):
 print world[i, j],
 print

 n = int(raw_input(Please enter a n dimension. ))
 m = int(raw_input(Please enter a m dimension. ))

 raw_input(Press return to make a world)
 print_world(make_random_world(n,m))







___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Modifying game of life

2005-01-10 Thread Kooser, Ara S
I was trying to modify the Game of Life to a percolation model (you can
pick what the probability of each point being occupied). I wrote the def
for the percolation however when I print the world all I get is 
NONE NONE NONE NONE 
Etc...

I know my problem is in the line  world[i, j] = percolation(perc). The
original code that Danny wrote had the line
world[i,j]= random.choice([LIVE,DEAD]). I am guessing that Danny's code
give a 50/50 chance of a site being occupied and assigns that to i,j . I
do not have the correct syntax to make the world[i,j] go through the
percolation def. I think i and j are not getting assigned a value.

Does anyone have an suggestions, explanations, websites? Thanks. 


Ara




import random

perc = raw_input(Please enter a threshold between 0-1.  )
raw_input(Press return to make a world)
PERSON, EMPTY = '*', '.'

def percolation(perc):
randval = random.random()
PERSON, EMPTY = '*', '.'
if randval  perc:
EMPTY
if randval  perc:
PERSON

def make_random_world(M, N):
world = {}
for j in range(N):
for i in range(M):
world[i, j] = percolation(perc)
world['dimensions'] = (M, N)
return world

def print_world(world):

M, N = world['dimensions']
for j in range(N):
for i in range(M):
print world[i, j],
print

print_world(make_random_world(10, 10))
###

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


RE: [Tutor] Modifying game of life

2005-01-10 Thread Kooser, Ara S
Kent and Max. Thank you very much. It works fine now. 

Ara



perc = raw_input(Please enter a threshold between 0-1.  )
perc = float(perc)

def percolation(perc):
randval = random.random()
print randval
PERSON, EMPTY = '*', '.'
if randval  perc:
EMPTY
return EMPTY
elif randval  perc:
PERSON
return PERSON
elif randval == perc:
PERSON
return PERSON


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] German Tutorials auf Deutsch

2005-01-06 Thread Kooser, Ara S
Title: German Tutorials auf Deutsch






Pardon to the non-german speaking (or readers) on the list.

Guten Tag. Mein Deutsch ist nicht so gut (ich habe keinen Deutsche in sieben Jahren geschreiben). Mann kann Python Tutorials auf Deutsch heir http://www.freenetpages.co.uk/hp/alan.gauld/german/index.htm
und
http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index_ger.html
und
http://starship.python.net/crew/gherman/publications/tut-de/
finden.
I habe Alan Gauld Tutorial vorgelesen. Es is gut und es abdeckt zimliche viele Themen.

Ara




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] The Game of Life question

2005-01-05 Thread Kooser, Ara S
   This is most likely a silly question and me not understanding python
enough. I am a mentor for some high school kids participating in a
supercomputing challenge. My background in programming is F77 (yeah
laugh it up) and I want the kids to learn python and use it for the
challenge. 
   They picked a project to model the flow of smallpox in a city and
surroundings areas. So I saw the game of life and thought maybe they
could modify it for use as a smallpox model. My question is when I run
this code as is and execute the command to generate a world, I get the
following error:

Traceback (most recent call last):
  File pyshell#0, line 1, in -toplevel-
print_world(make_random_world(10, 10))
  File C:\Python23\gameoflife.py, line 12, in make_random_world
world[i, j] = random.choice([LIVE, DEAD])
NameError: global name 'random' is not defined
 

Does random need to be defined after LIVE,DEAD or am I just missing
something. I was trying to run this on my work computer which is a winXP
machine running python 2.4.

Thanks,
Ara



This is the part of the game of life program I am trying to get to run

LIVE, DEAD = '*', '.'

def make_random_world(M, N):
Constructs a new random game world of size MxN.
world = {}
for j in range(N):
for i in range(M):
world[i, j] = random.choice([LIVE, DEAD])
world['dimensions'] = (M, N)
return world

def print_world(world):
Prints out a string representation of a world.
M, N = world['dimensions']
for j in range(N):
for i in range(M):
print world[i, j],
print

 print_world(make_random_world(10, 10))

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor