Updated version to 0.0.7.
[troncode.git] / players / old / TurnRightPlayer.py
blob423937326e6a3bf95c2a9d36aa37edae6ced5624
1 from troncode_values import *
3 class TurnRightPlayer( object ):
4 """An example player to get you started on writing your own. This player
5 goes straight until it hits a wall, and then it turns right."""
7 def __init__( self ):
8 """Do any required setup here."""
9 pass
11 def GetColour( self ):
12 """Return the colour this light cycle should be displayed on screen."""
13 return ( 160, 160, 255 )
15 def GetName():
16 """Return the name of this player as it should be displayed."""
17 return "Turn Right"
18 GetName = staticmethod( GetName )
20 def GetDir( self, position, direction, gameboard ):
21 """Turn right if there is a pixel directly in front.
22 position is my location - a point (x,y) in the arena
23 direction is my direction: DIR_UP, DIR_DOWN, DIR_LEFT or DIR_RIGHT
24 gameboard is an AbstractGameBoard which has useful methods on it."""
26 if gameboard.GetRelativePixel( position, direction, 1, 0 ) > 0:
27 return gameboard.TurnRight( direction )
28 else:
29 return direction