round_walk.py 831 Bytes
Newer Older
Ahmad Reza's avatar
Ahmad Reza committed
1

2
#Standard Lib that has to be in each solution
3
from solution.std_lib import *
Ahmad Reza's avatar
Ahmad Reza committed
4

Ahmad Reza's avatar
Ahmad Reza committed
5
def solution(world):
Ahmad Reza's avatar
Ahmad Reza committed
6

Ahmad Reza's avatar
Ahmad Reza committed
7
    for particle in world.get_particle_list():
Ahmad Reza's avatar
Ahmad Reza committed
8
9
        global ttl
        global max
10
        global direction
Ahmad Reza's avatar
Ahmad Reza committed
11

Ahmad Reza's avatar
Ahmad Reza committed
12
        if world.get_actual_round() == 1:
Ahmad Reza's avatar
Ahmad Reza committed
13
14
            max = 0
            ttl = 0
15
            direction = NE
Ahmad Reza's avatar
Ahmad Reza committed
16

17
        if (ttl==0 and (direction==NE or direction==SW)):
Ahmad Reza's avatar
Ahmad Reza committed
18
19
20
            max = max+1

        if ttl==0:
Ahmad Reza's avatar
Ahmad Reza committed
21
            print("Round ", world.get_actual_round())
Ahmad Reza's avatar
Ahmad Reza committed
22
            ttl=max
23
24
25
26
27
28
29
30
            if direction==NE:
                direction=NW
            elif direction==NW:
                direction=SW
            elif direction==SW:
                direction=SE
            elif direction==SE:
                direction=NE
Ahmad Reza's avatar
Ahmad Reza committed
31

32
        particle.create_marker()
33
        particle.move_to(direction)
Ahmad Reza's avatar
Ahmad Reza committed
34
        ttl = ttl - 1