-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnake.py
More file actions
57 lines (39 loc) · 1.28 KB
/
snake.py
File metadata and controls
57 lines (39 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import mover
import misc
import planter
def runGame( tillFirst ):
if( num_unlocked(Unlocks.Dinosaurs) == 0 ):
return False
if( planter.canAffordEntity(Entities.Apple, misc.getEntityMaxCount()) == False ):
return False
starterBone = num_items(Items.Bone)
worldStartSize = get_world_size()
if( misc.isOdd(worldStartSize) ):
set_world_size(worldStartSize-1)
if( mover.usedWorldSize != get_world_size() ):
mover.init()
mover.moveToPos( mover.getCircuitStartPos() )
if( tillFirst == True ):
change_hat( Hats.Straw_Hat ) #apply default hat
tillToggled = tillFirst
while( tillToggled == True ):
harvest()
if( get_ground_type() != Grounds.Soil ):
till()
move( mover.circuitDict[ (get_pos_x(),get_pos_y()) ] )
if( (get_pos_x(),get_pos_y()) == mover.getCircuitStartPos() ):
tillToggled = False
change_hat(Hats.Dinosaur_Hat) #apply "snake hat"
applePos = measure()
mover.moveToPos(applePos)
while( applePos != None ):
pos = ( get_pos_x(),get_pos_y() )
if( pos == applePos ):
applePos = measure()
moveDirection = mover.circuitDict[pos]
if( move(moveDirection) == False ):
applePos = None
change_hat(Hats.Straw_Hat) #remove "snake hat"
if( get_world_size() < worldStartSize ):
set_world_size(worldStartSize)
return num_items(Items.Bone) > starterBone