[Tutor] Scripting-Puzzle Pirates

2010-10-24 Thread Nathan Finney
Hey, So I got bored of having to do a repeated task on this game, YPP Puzzle Pirates and I was wondering if it was possible to script it. My task would be to start at a dock, click on the port arrow, choose a ship (a different one each time and in order preferably), go to its hold, select mat

Re: [Tutor] Scripting-Puzzle Pirates

2010-10-24 Thread Alan Gauld
"Nathan Finney" wrote So I got bored of having to do a repeated task on this game, YPP Puzzle Pirates and I was wondering if it was possible to script it. No idea, never heard of it. If this is possible would I first need a set of the games coding (which uses javascript) to be obtained s

Re: [Tutor] Scripting-Puzzle Pirates

2010-10-24 Thread Lie Ryan
On 10/24/10 15:33, Nathan Finney wrote: > Hey, > > So I got bored of having to do a repeated task on this game, YPP Puzzle > Pirates and I was wondering if it was possible to script it. Even if you can (hint: no, you can't), most games consider writing scripts to do tasks as botting, i.e. cheat

[Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Richard D. Moores
What's the best way to model an unfair coin? This is one way to do it, I suppose: Create a list containing only 'H's and 'T's. If you want the coin to have the probability of a head to be 6/11, ['H', 'H', 'H', 'H', 'H', 'H', 'T', 'T', 'T', 'T', 'T'] is the list to use. Use random.choice on the l

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Evert Rol
> What's the best way to model an unfair coin? > > This is one way to do it, I suppose: Create a list containing only > 'H's and 'T's. If you want the coin to have the probability of a head > to be 6/11, > > ['H', 'H', 'H', 'H', 'H', 'H', 'T', 'T', 'T', 'T', 'T'] > > is the list to use. Use rand

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-24 Thread Richard D. Moores
On Sat, Oct 23, 2010 at 02:28, col speed wrote: > > >> >> >> Message: 7 >> Date: Fri, 22 Oct 2010 21:48:29 -0700 >> From: "Richard D. Moores" >> To: "Steven D'Aprano" >> Cc: tutor@python.org >> Subject: Re: [Tutor] What does "TypeError: 'int' object is not >>        iterable"       mean? >> Mess

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Steven D'Aprano
Richard D. Moores wrote: What's the best way to model an unfair coin? Let probability of heads = p, where 0 <= p <= 1 Then probability of tails = 1-p. if random.random() <= p: print("got heads") else: print("got tails") [...] That's the only way I can think of. But surely there's a better, m

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Alan Gauld
"Richard D. Moores" wrote 'H's and 'T's. If you want the coin to have the probability of a head to be 6/11, ['H', 'H', 'H', 'H', 'H', 'H', 'T', 'T', 'T', 'T', 'T'] is the list to use. Use random.choice on the list, for a 6/11 heads probability. That will work but as you say is not very ge

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Evert Rol
> Btw, to be pedantic, 1/e is not an irrational number, just a real number. i/e > would be. My bad: irrational != imaginary. And real = irrational. Things are definitely a bit rusty... ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Steven D'Aprano
Evert Rol wrote: Btw, to be pedantic, 1/e is not an irrational number, just a real number. i/e would be. Actually, Richard is correct. Like π, e and 1/e are irrational numbers. "Irrational" means the number is not rational, in the sense of *ratio*, not sanity :) There is no exact ratio of

Re: [Tutor] Problem with python

2010-10-24 Thread Richard D. Moores
On Wed, Oct 20, 2010 at 03:13, Steven D'Aprano wrote: > Let's start with an easy example: factorial(0). When Python sees > factorial(0), it does this: > > Call factorial with argument 0: > * if n == 0 <-- this is true, so execute the "if" block: >    return 1 > > so the function factorial(0) retu

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Richard D. Moores
On Sun, Oct 24, 2010 at 05:17, Steven D'Aprano wrote: > Let probability of heads = p, where 0 <= p <= 1 > Then probability of tails = 1-p. > > if random.random() <= p: print("got heads") > else: print("got tails") My thanks to Evert, Steven, and Alan. I should have thought of that solution. Act

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Evert Rol
> Actually, I used the unfair coin model as the simplest example of the > kind of thing I want to do -- which is to model the USD->Yen exchange > rate. I want the next quote to vary in a controlled random way, by > assigning probabilities to various possible changes in the rate. See >

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Richard D. Moores
On Sun, Oct 24, 2010 at 06:36, Evert Rol wrote: >> Actually, I used the unfair coin model as the simplest example of the >> kind of thing I want to do -- which is to model the USD->Yen exchange >> rate. I want the next quote to vary in a controlled random way, by >> assigning probabilities to vari

Re: [Tutor] Tutor Digest, Vol 80, Issue 108

2010-10-24 Thread Art Cla Media
mai date  in pula  mea  cu masurile  tale  mai acrit  la coie  mai termina  in plm cu  ele --- On Sun, 10/24/10, tutor-requ...@python.org wrote: From: tutor-requ...@python.org Subject: Tutor Digest, Vol 80, Issue 108 To: tutor@python.org Date: Sunday, October 24, 2010, 12:25 PM Send Tutor mai

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Richard D. Moores
Here's my model unfair die. Dick ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Jose Amoreira
On Sunday, October 24, 2010 01:18:52 pm Alan Gauld wrote: > In pseudo code: > > def coinToss(prob = 0.5): > rand = random() > if rand >= prob: return True > else: return False > > print "Heads" if coinToss(6/11) else "Tails" > The only problem with this snippet is integer division:

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Lie Ryan
On 10/25/10 02:46, Jose Amoreira wrote: > On Sunday, October 24, 2010 01:18:52 pm Alan Gauld wrote: > >> In pseudo code: >> >> def coinToss(prob = 0.5): >> rand = random() >> if rand >= prob: return True >> else: return False >> >> print "Heads" if coinToss(6/11) else "Tails" >> > > T

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-24 Thread Lie Ryan
On 10/23/10 01:19, David Hutto wrote: > If I understand what i just said correctly, it just means it tells the > string what type to convert from when placing it into the final > result. basically, when doing this %-interpolation, python does this: ("NEW LOW: %%.%sf at %%s" % i) % (lowz, time

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Steven D'Aprano
Richard D. Moores wrote: Actually, I used the unfair coin model as the simplest example of the kind of thing I want to do -- which is to model the USD->Yen exchange rate. I want the next quote to vary in a controlled random way, by assigning probabilities to various possible changes in the rate.

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Richard D. Moores
On Sun, Oct 24, 2010 at 09:22, Steven D'Aprano wrote: > Richard D. Moores wrote: > >> Actually, I used the unfair coin model as the simplest example of the >> kind of thing I want to do -- which is to model the USD->Yen exchange >> rate. I want the next quote to vary in a controlled random way, by

[Tutor] Problems with partial string matching

2010-10-24 Thread Josep M. Fontana
Hi, As I said in another message with the heading "Using contents of a document to change file names", I'm trying to learn Python "by doing" and I was working on a little project where I had to change the names of the files in a directory according to some codes contained in a CSV file. With the h

Re: [Tutor] Problems with partial string matching

2010-10-24 Thread Joel Goldstick
On Sun, Oct 24, 2010 at 2:16 PM, Josep M. Fontana wrote: > Hi, > > As I said in another message with the heading "Using contents of a > document to change file names", I'm trying to learn Python "by doing" > and I was working on a little project where I had to change the names > of the files in a

Re: [Tutor] Problems with partial string matching

2010-10-24 Thread Dave Angel
On 2:59 PM, Josep M. Fontana wrote: Hi, As I said in another message with the heading "Using contents of a document to change file names", I'm trying to learn Python "by doing" and I was working on a little project where I had to change the names I run this and I don't get any errors. The name

[Tutor] What is random.triangular() used for

2010-10-24 Thread Richard D. Moores
In looking through the doc on the random module I came across random.triangular(): random.triangular(low, high, mode) Return a random floating point number N such that low <= N <= high and with the specified mode between those bounds. The low and high bound

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Emile van Sebille
On 10/24/2010 1:17 PM Richard D. Moores said... In looking through the doc on the random module I came across random.triangular(): random.triangular(low, high, mode) Return a random floating point number N such that low<= N<= high and with the specified m

Re: [Tutor] Problem with python

2010-10-24 Thread python
> I just wanted to note that Steven is a great teacher! +1 Malcolm ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Richard D. Moores
On Sun, Oct 24, 2010 at 13:29, Emile van Sebille wrote: > From people who would know found at > http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.triangular.html > > > """The triangular distribution is often used in ill-defined problems where > the underlying distribution is not kn

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Adam Bark
On 24/10/10 21:57, Richard D. Moores wrote: On Sun, Oct 24, 2010 at 13:29, Emile van Sebille wrote: From people who would know found at http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.triangular.html """The triangular distribution is often used in ill-defined problems w

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Steven D'Aprano
Richard D. Moores wrote: NameError: name 'np' is not defined [...] but where do I get np? I believe that it is common in the scientific python world to do this: import numpy as np and then use np.FUNCTION instead of numpy.FUNCTION. -- Steven ___

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Richard D. Moores
On Sun, Oct 24, 2010 at 14:48, Steven D'Aprano wrote: > Richard D. Moores wrote: >> >> NameError: name 'np' is not defined > > [...] >> >> but where do I get np? > > > I believe that it is common in the scientific python world to do this: > > import numpy as np > > and then use np.FUNCTION instead

Re: [Tutor] Writing Scripts.

2010-10-24 Thread John
Autumn, Here's a basic script, if you save this in a file called hello.py and type 'python hello.py' at the prompt, or as others are saying using the python launcher, you should get some output. hth, john SCRIPT (include lines below here): #!/usr/bin/env python import os user = os.environ.get(

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Dave Angel
On 2:59 PM, Richard D. Moores wrote: On Sun, Oct 24, 2010 at 13:29, Emile van Sebille wrote: From people who would know found at http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.triangular.html """The triangular distribution is often used in ill-defined problems where the u

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Richard D. Moores
On Sun, Oct 24, 2010 at 16:38, Dave Angel wrote: > import numpy as np > > see > http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_examples/histogram_demo.py > for one example.  I don't know anything about matplotlib as a whole, this > was just a lucky shot Thanks, Dave. That's

[Tutor] 2.6 vs 2.7: package compatibility?

2010-10-24 Thread Alex Hall
Hi all, I want to run a certain program from source. One dependency, Durus, keeps giving me an error that no one can figure out. Someone said that it will work if I use 2.7 instead of 2.6, but a lot of packages I have installed work only on 2.6. I know I can install both, but here is the question: