Comparing lists
"Will Davis" <[email protected]>
| Newsgroups | gmane.comp.breve |
|---|---|
| Message-ID | <000e01c3e906$7a9b0080$f90110ac@KWIKSILVA> |
Hi all,
I've written a lookup table comparing a list of ordered vectors against other lists. If a match occurs the method returns 1 otherwise 0. I've come up against a problem in that when comparing a list with two (or more elements), it doesn't appear to behave as it should.
Here is my lookup table
if neighbours == {(1,0,0)}: return 1.
if neighbours == {(-1,0,0)}: return 1.
if neighbours == {(0,1,0)}: return 1.
if neighbours == {(0,-1,0)}: return 1.
if neighbours == {(0,1,0),(1,0,0)}: return 1.
if neighbours == {(-1,0,0),(0,-1,0)}: return 1.
if neighbours == {(0,-1,0),(1,0,0)}: return 1.
if neighbours == {(-1,0,0),(0,1,0)}: return 1.
return 0.
The neighbours list is an ordered list of the relative positions of the objects in the immediate neighbourhood. If the block configuration (i.e. the ordered list of vectors) matches one of the above rules, then a block can be placed. The problem is that even though none of these rules allow a block to be placed in the z dimension (there are no vectors relating to a block being in that position), they still get placed in the z dimension. I've got around this by checking the items in the list for a z component, but I'd still like to be able to work out why it happens. Does list equality work differently? I know it's probably difficult to get an idea without the rest of the code, but if anybody has any ideas then that'd be great.
Cheers,
Will
_______________________________________________
breve mailing list
[email protected]
http://www.spiderland.org/mailman/listinfo/breve