Terry Reedy wrote:
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
def setRandomState(self):
# container for the elements to pick from
container = [1,2,3,4,5,6,7,8,-1]
# create elements of puzzle randomly
i = 0
j = 0
while i <= self.dim-1:
whil
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>def setRandomState(self):
> # container for the elements to pick from
> container = [1,2,3,4,5,6,7,8,-1]
>
> # create elements of puzzle randomly
> i = 0
> j = 0
> while i <= self.dim-1:
>
[EMAIL PROTECTED] wrote:
> Allright. What difference in runtime and space would it make using
> dictionaries instead?
is this for an interactive game? if so, the answer is "none at all".
(on my machine, you can make about 600 dict[x,y] accesses per
second, compared to 750 list[x][y] acc
Allright. What difference in runtime and space would it make using
dictionaries instead?
Do you have a pointer for me concerning runtime of standard
manipulations in Pythons?
Thanks for the tip.
--
http://mail.python.org/mailman/listinfo/python-list
Allright. What difference in runtime and space would it make using
dictionaries instead?
Do you have a pointer for me concerning runtime of standard
manipulations in Pythons?
Thanks for tip.
--
http://mail.python.org/mailman/listinfo/python-list
"Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message >
>And use xrange instead of range.
For small dimensions like 3,4,5, xrange is way overkill and perhaps takes
both more space and time. Since dim is a constant for a given puzzle, I
would set self._range = range(dim) in __init__() and us
Thanks for the code.
What I want to do is this:
I want to solve the block puzzle problem. The problem is as follows:
You have a nxn Array of Numbers and one empty space. Now you there are
up to four possible moves: up, right, down and left, so that each
neighbour of the empty slot can be moved the
naturalborncyborg wrote:
Hi, I'm using nested lists as arrays and having some problems with
that approach. In my puzzle class there is a swapelement method which
doesn't work out.
What "doesn't work out"? On casual inspection that method seems to "work":
>>> p = Puzzle(2)
>>> p.elements[0][0] =
"naturalborncyborg" <[EMAIL PROTECTED]> wrote:
> Hi, I'm using nested lists as arrays and having some problems with
> that approach. In my puzzle class there is a swapelement method which
> doesn't work out.
what happens, and what do you expect?
> Any help and comments on the code will be apprec
Diez B. Roggisch wrote:
> [EMAIL PROTECTED] wrote:
>
> > Hi,
> >
> > why can't I do this:
> >
> > dummy = self.elements[toy][tox]
> >
> > self.elements[toy][tox] = self.elements[fromy][fromx]
> > self.elements[fromy][fromx] = dummy
> >
> > after initialising my nested list
[EMAIL PROTECTED] wrote:
Hi,
why can't I do this:
dummy = self.elements[toy][tox]
self.elements[toy][tox] = self.elements[fromy][fromx]
self.elements[fromy][fromx] = dummy
after initialising my nested list like this:
self.elements = [[0 for column in range(dim)] for r
[EMAIL PROTECTED] wrote:
> Hi,
>
> why can't I do this:
>
> dummy = self.elements[toy][tox]
>
> self.elements[toy][tox] = self.elements[fromy][fromx]
> self.elements[fromy][fromx] = dummy
>
> after initialising my nested list like this:
>
>self.elements = [[0 f
12 matches
Mail list logo