Module Spyder :: Class RubikSnake
[hide private]
[frames] | no frames]

Class RubikSnake

source code

object --+
         |
        RubikSnake

Spyder-generated class

module models3d

file /home/sjoerd/data/Spyder-devel/models3d/rubiksnake.spy

Description

Representation of Rubik's Snake as an array of turns

where 0 means no turn,

1 a 45 degree right turn,

2 a 90 degree turn

and 3 a 45 degree left turn

There is always one more segment than there is turns

Unlike the traditional Rubik's Snake (23 turns)

the snake can have any length

Upon construction, the snake is validated for clashes

Wiki

http://www.spyderware.nl/wiki/classes/RubikSnake

Validate block

>>>            
for t in turns:
assert t in range(0,4)
dir1,dir2,dir3 = 1,3,5
posx,posy,posz = 0,0,0
positions = {}
positions[(posx,posy,posz)] = (dir1,dir2)
for t in turns:
posx,posy,posz = rubiksnake.move(posx,posy,posz,dir1)
dir1,dir2,dir3 = rubiksnake.turn(dir1,dir2,dir3,t)
if (posx,posy,posz) in positions:
opposite = rubiksnake.get_opposite(positions[(posx,posy,posz)])
if dir1 != opposite[0] or dir2 != opposite[1]: 
raise ValidationError("Clash detected")
positions[(posx,posy,posz)] = (dir1,dir2)               
>>>

Form block

>>>            
BLENDER
MATRIX axis
DEFAULT size 1
RANGE size 1
ELEMIN turns -1
ELEMAX turns 4
ELEDEFAULT turns 0               
>>>

Converters

Can be converted to:

Can be converted from:

Instance Methods [hide private]

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
three_dimensional() source code
 
blenderevent(self, blenderdata, currobj, currobjtype, currblenderdata, signalhead, signal, event=None, eventval=None, handles=None) source code
Instance Variables [hide private]
IntegerArray turns = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
Float size
the size of each segment
AxisSystem axis = AxisSystem()
Properties [hide private]

Inherited from object: __class__

Instance Variable Details [hide private]

turns

Type:
IntegerArray
Value:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0