scanning_for_all_aims.py 1.2 KB
Newer Older
Ahmad Reza's avatar
Ahmad Reza committed
1
2
3
4
"""
This solution just scans for particles that are within 5 hops range and prints them out.
"""

5
#Standard Lib that has to be in each solution
6
from lib.swarm_sim_headerimport import *
Ahmad Reza's avatar
Ahmad Reza committed
7

Ahmad Reza's avatar
Ahmad Reza committed
8
def solution(world):
Ahmad Reza's avatar
Ahmad Reza committed
9
10

    all_matters_list=[]
Ahmad Reza's avatar
Ahmad Reza committed
11
    if world.get_actual_round() == 1:
Ahmad Reza's avatar
Ahmad Reza committed
12
        all_matters_list=world.get_particle_map_coords()[(0,0)].scan_for_matters_within(hop=5)
Ahmad Reza's avatar
Ahmad Reza committed
13
14
15
16
17
        for list in all_matters_list:
            if list.type=='particle':
                print ("particle at", list.coords)
            elif list.type=='tile':
                print("tile", list.coords)
18
19
            elif list.type=='marker':
                print("marker", list.coords)
Ahmad Reza's avatar
Ahmad Reza committed
20
21
22
23
24
25
26
27
28
29
    if world.get_actual_round() == 2:
        all_matters_list = world.get_particle_map_coords()[(0, 0)].scan_for_particles_within(hop=5)
        for list in all_matters_list:
            print ("particle at", list.coords)
        all_matters_list = world.get_particle_map_coords()[(0, 0)].scan_for_tiles_within(hop=5)
        for list in all_matters_list:
            print("tile", list.coords)
        all_matters_list = world.get_particle_map_coords()[(0, 0)].scan_for_markers_within(hop=5)
        for list in all_matters_list:
            print("marker", list.coords)