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

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

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

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

12
        if sim.get_actual_round() == 1:
Ahmad Reza's avatar
Ahmad Reza committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
            max = 0
            ttl = 0
            dir = NE

        if (ttl==0 and (dir==NE or dir==SW)):
            max = max+1

        if ttl==0:
            print("Round ", sim.get_actual_round())
            ttl=max
            if dir==NE:
                dir=NW
            elif dir==NW:
                dir=SW
            elif dir==SW:
                dir=SE
            elif dir==SE:
                dir=NE

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