On Feb 12, 1:27 am, "agent-s" <[EMAIL PROTECTED]> wrote:
> Basically I'm programming a board game and I have to use a list of
> lists to represent the board (a list of 8 lists with 8 elements each).
> I have to search the adjacent cells for existing pieces and I was
> wondering how I would go about
OK I just realized that a list of lists can be accessed in the same
way a 2d array would be accessed. Thanks anyways guys.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks for the help guys but I'm a newbie at this and from what I
understand from the code, it looks like you guys are using a two
dimensional array. I am not using a two dimensional array. Basically,
it looks like this:
[
[' ',' ',' ',' ',' ',' ',' ',' '],
[' ',' ',' ',' ',' ',' ',' ',' '],
[' ',
"John Machin" <[EMAIL PROTECTED]> wrote:
> On Feb 13, 4:57 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote:
> > "John Machin" <[EMAIL PROTECTED]> wrote:
> >
> > > Now for the algorithm: all of that testing to see if you are about to
> > > sail off the end of the world is a bit ugly and slow. Y
On Feb 13, 4:57 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote:
> "John Machin" <[EMAIL PROTECTED]> wrote:
>
> > Now for the algorithm: all of that testing to see if you are about to
> > sail off the end of the world is a bit ugly and slow. You can use bit-
> > bashing, as Paul suggested, even
"John Machin" <[EMAIL PROTECTED]> wrote:
> Now for the algorithm: all of that testing to see if you are about to
> sail off the end of the world is a bit ugly and slow. You can use bit-
> bashing, as Paul suggested, even though it's on Steven D'Aprano's list
> of 6 deadly sins :-)
Thou shallt n
On 2007-02-12, James Stroud <[EMAIL PROTECTED]> wrote:
> Paul Rubin wrote:
>> "agent-s" <[EMAIL PROTECTED]> writes:
>>>Basically I'm programming a board game and I have to use a
>>>list of lists to represent the board (a list of 8 lists with 8
>>>elements each). I have to search the adjacent cells
On Sun, 11 Feb 2007 23:20:11 -0800, John Machin wrote:
> Now for the algorithm: all of that testing to see if you are about to
> sail off the end of the world is a bit ugly and slow. You can use bit-
> bashing, as Paul suggested, even though it's on Steven D'Aprano's list
> of 6 deadly sins :-)
H
On Feb 12, 4:24 pm, Samuel Karl Peterson
<[EMAIL PROTECTED]> wrote:
> C-like way to do it, (warning, untested in python):
>
> for i in range(8):
> for j in range(8):
> for offset_i in range(-1,2):
> for offset_j in range(-1, 2):
> row = i + offset_i
>
James Stroud:
> import operator
> srch = [(i,j) for i in [-1,0,1] for j in [-1,0,1] if (i,j) != (0,0)]
> is_adj = reduce(operator.or_, [ary[row+i][col+j] for (i,j) in srch]])
Or maybe (untested), Python V.2.5:
srch = [(i,j) for i in [-1,0,1] for j in [-1,0,1] if (i,j) != (0,0)]
is_adj = any(ary[r
Paul Rubin wrote:
> "agent-s" <[EMAIL PROTECTED]> writes:
>
>>Basically I'm programming a board game and I have to use a list of
>>lists to represent the board (a list of 8 lists with 8 elements each).
>>I have to search the adjacent cells for existing pieces and I was
>>wondering how I would go a
"agent-s" <[EMAIL PROTECTED]> writes:
> Basically I'm programming a board game and I have to use a list of
> lists to represent the board (a list of 8 lists with 8 elements each).
> I have to search the adjacent cells for existing pieces and I was
> wondering how I would go about doing this efficie
En Mon, 12 Feb 2007 02:24:54 -0300, Samuel Karl Peterson
<[EMAIL PROTECTED]> escribió:
> James Stroud <[EMAIL PROTECTED]> on Sun, 11 Feb 2007 16:53:16 -0800
> didst step forth and proclaim thus:
>
>> agent-s wrote:
>> > Basically I'm programming a board game and I have to use a list of
>> > list
James Stroud <[EMAIL PROTECTED]> on Sun, 11 Feb 2007 16:53:16 -0800
didst step forth and proclaim thus:
> agent-s wrote:
> > Basically I'm programming a board game and I have to use a list of
> > lists to represent the board (a list of 8 lists with 8 elements each).
> > I have to search the adjace
agent-s wrote:
> Basically I'm programming a board game and I have to use a list of
> lists to represent the board (a list of 8 lists with 8 elements each).
> I have to search the adjacent cells for existing pieces and I was
> wondering how I would go about doing this efficiently. Thanks
>
This i
Basically I'm programming a board game and I have to use a list of
lists to represent the board (a list of 8 lists with 8 elements each).
I have to search the adjacent cells for existing pieces and I was
wondering how I would go about doing this efficiently. Thanks
--
http://mail.python.org/mailm
16 matches
Mail list logo