Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ahmad Reza Cheraghi
swarm-sim
Commits
ffc59465
Commit
ffc59465
authored
Jun 04, 2019
by
Ahmad Reza
Browse files
Changed the location name to marker.
parent
1e3b4742
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
.idea/misc.xml
0 → 100644
View file @
ffc59465
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"JavaScriptSettings"
>
<option
name=
"languageLevel"
value=
"ES6"
/>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.6.2 (/usr/bin/python3.6)"
project-jdk-type=
"Python SDK"
/>
</project>
\ No newline at end of file
.idea/modules.xml
0 → 100644
View file @
ffc59465
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/swarm-sim.iml"
filepath=
"$PROJECT_DIR$/.idea/swarm-sim.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
.idea/swarm-sim.iml
0 → 100644
View file @
ffc59465
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$"
/>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
<component
name=
"TemplatesService"
>
<option
name=
"TEMPLATE_FOLDERS"
>
<list>
<option
value=
"$MODULE_DIR$/docs/source/_templates"
/>
</list>
</option>
</component>
<component
name=
"TestRunnerService"
>
<option
name=
"PROJECT_TEST_RUNNER"
value=
"Unittests"
/>
</component>
</module>
\ No newline at end of file
config.ini
View file @
ffc59465
...
...
@@ -35,7 +35,7 @@ mm_limitation = 0
## mm size in quantity
## Works only with mm_limitation flag set on 1
location
_mm_size
=
2
marker
_mm_size
=
2
particle_mm_size
=
2
tile_mm_size
=
2
...
...
@@ -57,11 +57,11 @@ solution = create_delete
#solution= take_drop_aims
## Read and Write
#scenario = two_particles_tiles_
location
s
#scenario = two_particles_tiles_
marker
s
#solution = read_write
## Scanning for matters
#scenario = particles_tiles_
location
s_ring
#scenario = particles_tiles_
marker
s_ring
#solution= scanning_for_all_aims
## All interfaces
...
...
lib/csv_generator.py
View file @
ffc59465
This diff is collapsed.
Click to expand it.
lib/matter.py
View file @
ffc59465
"""The
location
module provides the interface to the
locations. A location
is any point on
"""The
marker
module provides the interface to the
markers. A marker
is any point on
the coordinate system of the simulators sim"""
...
...
@@ -31,10 +31,10 @@ color_map = {
class
Matter
():
"""In the classe
location
all the methods for the characterstic of a
location
is included"""
"""In the classe
marker
all the methods for the characterstic of a
marker
is included"""
def
__init__
(
self
,
sim
,
x
,
y
,
color
=
black
,
alpha
=
1
,
type
=
None
,
mm_limit
=
False
,
mm_size
=
0
):
"""Initializing the
location
constructor"""
"""Initializing the
marker
constructor"""
self
.
coords
=
(
x
,
y
)
self
.
color
=
color_map
[
color
]
self
.
__id
=
str
(
uuid
.
uuid4
())
...
...
@@ -97,7 +97,7 @@ class Matter():
def
read_whole_memory
(
self
):
"""
Reads all
location
s own memory based on a give keywoard
Reads all
marker
s own memory based on a give keywoard
:param key: Keywoard
:return: The founded memory; None: When nothing is written based on the keywoard
...
...
@@ -152,16 +152,16 @@ class Matter():
def
get_id
(
self
):
"""
Gets the
location
id
:return:
Location
id
Gets the
marker
id
:return:
marker
id
"""
return
self
.
__id
def
set_color
(
self
,
color
):
"""
Sets the
location
color
Sets the
marker
color
:param color:
Location
color
:param color:
marker
color
:return: None
"""
if
type
(
color
)
==
int
:
...
...
@@ -173,9 +173,9 @@ class Matter():
def
get_color
(
self
):
"""
Sets the
location
color
Sets the
marker
color
:param color:
Location
color
:param color:
marker
color
:return: None
"""
for
color
,
code
in
color_map
.
items
():
# for name, age in dictionary.iteritems(): (for Python 2.x)
...
...
lib/particle.py
View file @
ffc59465
This diff is collapsed.
Click to expand it.
lib/sim.py
View file @
ffc59465
"""The sim module provides the interface of the simulation sim. In the simulation sim
all the data of the particles, tiles, and
location
s are stored.
all the data of the particles, tiles, and
marker
s are stored.
It also have the the coordination system and stated the maximum of the x and y coordinate.
.. todo:: What happens if the maximum y or x axis is passed? Either the start from the other side or turns back.
...
...
@@ -10,7 +10,7 @@ import importlib
import
random
import
math
import
logging
from
lib
import
csv_generator
,
particle
,
tile
,
location
,
vis
from
lib
import
csv_generator
,
particle
,
tile
,
marker
,
vis
from
lib.gnuplot_generator
import
generate_gnuplot
...
...
@@ -80,14 +80,14 @@ class Sim:
self
.
__tile_deleted
=
False
self
.
new_tile_flag
=
False
self
.
tile_mm_size
=
config_data
.
tile_mm_size
self
.
location
s_num
=
0
self
.
location
s
=
[]
self
.
location
s_created
=
[]
self
.
location
_map_coords
=
{}
self
.
location
_map_id
=
{}
self
.
location
s_rm
=
[]
self
.
location
_mm_size
=
config_data
.
location
_mm_size
self
.
__
location
_deleted
=
False
self
.
marker
s_num
=
0
self
.
marker
s
=
[]
self
.
marker
s_created
=
[]
self
.
marker
_map_coords
=
{}
self
.
marker
_map_id
=
{}
self
.
marker
s_rm
=
[]
self
.
marker
_mm_size
=
config_data
.
marker
_mm_size
self
.
__
marker
_deleted
=
False
self
.
new_tile
=
None
self
.
__size_x
=
config_data
.
size_x
self
.
__size_y
=
config_data
.
size_y
...
...
@@ -249,37 +249,37 @@ class Sim:
"""
return
self
.
tile_map_id
def
get_
location
_num
(
self
):
def
get_
marker
_num
(
self
):
"""
Returns the actual number of
location
s in the sim
Returns the actual number of
marker
s in the sim
:return: The actual number of
location
s
:return: The actual number of
marker
s
"""
return
self
.
location
s_num
return
self
.
marker
s_num
def
get_
location
_list
(
self
):
def
get_
marker
_list
(
self
):
"""
Returns the actual number of
location
s in the sim
Returns the actual number of
marker
s in the sim
:return: The actual number of
location
s
:return: The actual number of
marker
s
"""
return
self
.
location
s
return
self
.
marker
s
def
get_
location
_map_coords
(
self
):
def
get_
marker
_map_coords
(
self
):
"""
Get a dictionary with all
location
s mapped with their actual coordinates
Get a dictionary with all
marker
s mapped with their actual coordinates
:return: a dictionary with
location
s and their coordinates
:return: a dictionary with
marker
s and their coordinates
"""
return
self
.
location
_map_coords
return
self
.
marker
_map_coords
def
get_
location
_map_id
(
self
):
def
get_
marker
_map_id
(
self
):
"""
Get a dictionary with all
location
s mapped with their own ids
Get a dictionary with all
marker
s mapped with their own ids
:return: a dictionary with
location
s and their own ids
:return: a dictionary with
marker
s and their own ids
"""
return
self
.
location
_map_id
return
self
.
marker
_map_id
def
get_coords_in_dir
(
self
,
coords
,
dir
):
...
...
@@ -311,8 +311,8 @@ class Sim:
def
get_particle_deleted
(
self
):
return
self
.
__particle_deleted
def
get_
location
_deleted
(
self
):
return
self
.
__
location
_deleted
def
get_
marker
_deleted
(
self
):
return
self
.
__
marker
_deleted
def
set_tile_deleted
(
self
):
self
.
__tile_deleted
=
False
...
...
@@ -320,8 +320,8 @@ class Sim:
def
set_particle_deleted
(
self
):
self
.
__particle_deleted
=
False
def
set_
location
_deleted
(
self
):
self
.
__
location
_deleted
=
False
def
set_
marker
_deleted
(
self
):
self
.
__
marker
_deleted
=
False
def
check_coords
(
self
,
coords_x
,
coords_y
):
"""
...
...
@@ -545,7 +545,7 @@ class Sim:
return
False
def
add_
location
(
self
,
x
,
y
,
color
=
black
,
alpha
=
1
):
def
add_
marker
(
self
,
x
,
y
,
color
=
black
,
alpha
=
1
):
"""
Add a tile to the sim database
...
...
@@ -557,77 +557,77 @@ class Sim:
if
alpha
<
0
or
alpha
>
1
:
alpha
=
1
if
self
.
check_coords
(
x
,
y
)
==
True
:
if
(
x
,
y
)
not
in
self
.
location
_map_coords
:
self
.
new_
location
=
location
.
Location
(
self
,
x
,
y
,
color
,
alpha
,
self
.
mm_limitation
,
self
.
location
_mm_size
)
self
.
location
s
.
append
(
self
.
new_
location
)
self
.
location
_map_coords
[
self
.
new_
location
.
coords
]
=
self
.
new_
location
self
.
location
_map_id
[
self
.
new_
location
.
get_id
()]
=
self
.
new_
location
self
.
csv_round_writer
.
update_
location
s_num
(
len
(
self
.
location
s
))
logging
.
info
(
"Created
location
with id %s on coords %s"
,
str
(
self
.
new_
location
.
get_id
()),
str
(
self
.
new_
location
.
coords
))
self
.
new_
location
.
created
=
True
self
.
new_
location
.
touch
()
return
self
.
new_
location
if
(
x
,
y
)
not
in
self
.
marker
_map_coords
:
self
.
new_
marker
=
marker
.
marker
(
self
,
x
,
y
,
color
,
alpha
,
self
.
mm_limitation
,
self
.
marker
_mm_size
)
self
.
marker
s
.
append
(
self
.
new_
marker
)
self
.
marker
_map_coords
[
self
.
new_
marker
.
coords
]
=
self
.
new_
marker
self
.
marker
_map_id
[
self
.
new_
marker
.
get_id
()]
=
self
.
new_
marker
self
.
csv_round_writer
.
update_
marker
s_num
(
len
(
self
.
marker
s
))
logging
.
info
(
"Created
marker
with id %s on coords %s"
,
str
(
self
.
new_
marker
.
get_id
()),
str
(
self
.
new_
marker
.
coords
))
self
.
new_
marker
.
created
=
True
self
.
new_
marker
.
touch
()
return
self
.
new_
marker
else
:
logging
.
info
(
"on x %f and y %f coordinates is a
location
already"
,
x
,
y
)
logging
.
info
(
"on x %f and y %f coordinates is a
marker
already"
,
x
,
y
)
return
False
else
:
logging
.
info
(
"for x %f and y %f not possible to draw "
,
x
,
y
)
return
False
def
remove_
location
(
self
,
id
):
def
remove_
marker
(
self
,
id
):
"""
Removes a tile with a given tile_id from to the sim database
:param id: The
location
s id that should be removec
:param id: The
marker
s id that should be removec
:return: True: Successful removed; False: Unsuccessful
"""
if
id
in
self
.
location
_map_id
:
rm_
location
=
self
.
location
_map_id
[
id
]
rm_
location
.
touch
()
if
rm_
location
in
self
.
location
s
:
self
.
location
s
.
remove
(
rm_
location
)
if
id
in
self
.
marker
_map_id
:
rm_
marker
=
self
.
marker
_map_id
[
id
]
rm_
marker
.
touch
()
if
rm_
marker
in
self
.
marker
s
:
self
.
marker
s
.
remove
(
rm_
marker
)
self
.
location
s_rm
.
append
(
rm_
location
)
logging
.
info
(
"Deleted
location with location
id %s on %s"
,
str
(
id
),
str
(
rm_
location
.
coords
))
self
.
marker
s_rm
.
append
(
rm_
marker
)
logging
.
info
(
"Deleted
marker with marker
id %s on %s"
,
str
(
id
),
str
(
rm_
marker
.
coords
))
try
:
del
self
.
location
_map_coords
[
rm_
location
.
coords
]
del
self
.
marker
_map_coords
[
rm_
marker
.
coords
]
except
KeyError
:
pass
try
:
del
self
.
location
_map_id
[
id
]
del
self
.
marker
_map_id
[
id
]
except
KeyError
:
pass
self
.
csv_round_writer
.
update_
location
s_num
(
len
(
self
.
location
s
))
self
.
csv_round_writer
.
update_metrics
(
location
_deleted
=
1
)
self
.
__
location
_deleted
=
True
self
.
csv_round_writer
.
update_
marker
s_num
(
len
(
self
.
marker
s
))
self
.
csv_round_writer
.
update_metrics
(
marker
_deleted
=
1
)
self
.
__
marker
_deleted
=
True
return
True
else
:
return
False
def
remove_
location
_on
(
self
,
coords
):
def
remove_
marker
_on
(
self
,
coords
):
"""
Removes a
location
on a give coordinat from to the sim database
Removes a
marker
on a give coordinat from to the sim database
:param coords: A tupel that includes the x and y coorindates
:return: True: Successful removed; False: Unsuccessful
"""
if
coords
in
self
.
location
_map_coords
:
self
.
location
s
.
remove
(
self
.
location
_map_coords
[
coords
])
self
.
location
s_rm
.
append
(
self
.
location
_map_coords
[
coords
])
if
coords
in
self
.
marker
_map_coords
:
self
.
marker
s
.
remove
(
self
.
marker
_map_coords
[
coords
])
self
.
marker
s_rm
.
append
(
self
.
marker
_map_coords
[
coords
])
try
:
# cher: added so the program does not crashed if it does not find any entries in the map
del
self
.
location
_map_id
[
self
.
location
_map_coords
[
coords
].
get_id
()]
del
self
.
marker
_map_id
[
self
.
marker
_map_coords
[
coords
].
get_id
()]
except
KeyError
:
pass
try
:
# cher: added so the program does not crashed if it does not find any entries in the map
del
self
.
location
_map_coords
[
coords
]
del
self
.
marker
_map_coords
[
coords
]
except
KeyError
:
pass
self
.
csv_round_writer
.
update_
location
s_num
(
len
(
self
.
location
s
))
self
.
csv_round_writer
.
update_metrics
(
location
_deleted
=
1
)
self
.
__
location
_deleted
=
True
self
.
csv_round_writer
.
update_
marker
s_num
(
len
(
self
.
marker
s
))
self
.
csv_round_writer
.
update_metrics
(
marker
_deleted
=
1
)
self
.
__
marker
_deleted
=
True
return
True
else
:
return
False
\ No newline at end of file
lib/tile.py
View file @
ffc59465
...
...
@@ -15,10 +15,10 @@ write=1
class
Tile
(
matter
.
Matter
):
"""In the classe
location
all the methods for the characterstic of a
location
is included"""
"""In the classe
marker
all the methods for the characterstic of a
marker
is included"""
def
__init__
(
self
,
sim
,
x
,
y
,
color
=
gray
,
alpha
=
1
,
mm_limit
=
0
,
mm_size
=
0
):
"""Initializing the
location
constructor"""
"""Initializing the
marker
constructor"""
super
().
__init__
(
sim
,
x
,
y
,
color
,
alpha
=
1
,
type
=
"tile"
,
mm_limit
=
mm_limit
,
mm_size
=
mm_size
)
self
.
__isCarried
=
False
self
.
created
=
False
...
...
lib/vis.py
View file @
ffc59465
...
...
@@ -38,7 +38,7 @@ rounds_per_second = 10
# tile_alpha = 0.6
particle_alpha
=
1
location
_alpha
=
1
marker
_alpha
=
1
...
...
@@ -118,7 +118,7 @@ class VisWindow(pyglet.window.Window):
self
.
sim
=
sim
self
.
init_tile_vertex_list
()
self
.
init_particle_vertex_list
()
self
.
init_
location
_vertex_list
()
self
.
init_
marker
_vertex_list
()
self
.
view
=
View
()
self
.
particleTexture
=
pyglet
.
image
.
load
(
'lib/images/particle.png'
).
get_mipmapped_texture
()
...
...
@@ -206,7 +206,7 @@ class VisWindow(pyglet.window.Window):
def
draw
(
self
):
self
.
update_tiles
()
self
.
update_particles
()
self
.
update_
location
s
()
self
.
update_
marker
s
()
glLoadIdentity
()
glOrtho
(
self
.
view
.
left
,
self
.
view
.
right
,
self
.
view
.
bottom
,
self
.
view
.
top
,
1
,
-
1
)
...
...
@@ -222,7 +222,7 @@ class VisWindow(pyglet.window.Window):
if
len
(
self
.
sim
.
tiles
)
!=
0
:
self
.
tile_vertex_list
.
draw
(
GL_QUADS
)
self
.
particle_vertex_list
.
draw
(
GL_QUADS
)
self
.
location
_vertex_list
.
draw
(
GL_QUADS
)
self
.
marker
_vertex_list
.
draw
(
GL_QUADS
)
self
.
flip
()
...
...
@@ -375,46 +375,46 @@ class VisWindow(pyglet.window.Window):
self
.
particle_vertex_list
.
colors
[
16
*
i
:
16
*
i
+
16
]
=
(
particle
.
color
+
[
particle
.
get_alpha
()])
*
4
def
init_
location
_vertex_list
(
self
):
self
.
location
_vertex_list
=
self
.
location
_vertex_list
=
pyglet
.
graphics
.
vertex_list
\
(
4
*
len
(
self
.
sim
.
location
s
),
'v2f'
,
't2f'
,
'c4f'
)
self
.
update_
location
s
(
True
)
def
init_
marker
_vertex_list
(
self
):
self
.
marker
_vertex_list
=
self
.
marker
_vertex_list
=
pyglet
.
graphics
.
vertex_list
\
(
4
*
len
(
self
.
sim
.
marker
s
),
'v2f'
,
't2f'
,
'c4f'
)
self
.
update_
marker
s
(
True
)
def
update_
location
s
(
self
,
update_all
=
True
):
if
(
len
(
self
.
sim
.
location
s
)
!=
0
):
if
self
.
sim
.
get_
location
_deleted
():
self
.
location
_vertex_list
.
resize
(
4
*
len
(
self
.
sim
.
location
s
))
self
.
sim
.
set_
location
_deleted
()
def
update_
marker
s
(
self
,
update_all
=
True
):
if
(
len
(
self
.
sim
.
marker
s
)
!=
0
):
if
self
.
sim
.
get_
marker
_deleted
():
self
.
marker
_vertex_list
.
resize
(
4
*
len
(
self
.
sim
.
marker
s
))
self
.
sim
.
set_
marker
_deleted
()
update_all
=
True
for
i
,
location
in
enumerate
(
self
.
sim
.
location
s
):
if
location
.
created
:
self
.
location
_vertex_list
.
resize
(
4
*
len
(
self
.
sim
.
location
s
))
for
i
,
marker
in
enumerate
(
self
.
sim
.
marker
s
):
if
marker
.
created
:
self
.
marker
_vertex_list
.
resize
(
4
*
len
(
self
.
sim
.
marker
s
))
# self.tile_vertex_list.resize(4 * len(self.sim.tiles), 8 * len(self.sim.tiles))
location
.
created
=
False
if
update_all
or
location
.
modified
:
self
.
update_
location
(
i
,
location
)
location
.
modified
=
False
marker
.
created
=
False
if
update_all
or
marker
.
modified
:
self
.
update_
marker
(
i
,
marker
)
marker
.
modified
=
False
else
:
pass
def
update_
location
(
self
,
i
,
location
):
def
update_
marker
(
self
,
i
,
marker
):
weird
=
256
/
220
pos
=
coords_to_sim
(
location
.
coords
)
pos
=
coords_to_sim
(
marker
.
coords
)
x
=
pos
[
0
]
y
=
pos
[
1
]
self
.
location
_vertex_list
.
vertices
[
8
*
i
:
8
*
i
+
8
]
=
[
x
-
weird
,
y
-
weird
,
x
+
weird
,
y
-
weird
,
x
+
weird
,
self
.
marker
_vertex_list
.
vertices
[
8
*
i
:
8
*
i
+
8
]
=
[
x
-
weird
,
y
-
weird
,
x
+
weird
,
y
-
weird
,
x
+
weird
,
y
+
weird
,
x
-
weird
,
y
+
weird
]
texLeft
=
7
/
8
texRight
=
1
#8/8
texBottom
=
0
/
8
texTop
=
1
/
8
self
.
location
_vertex_list
.
tex_coords
[
8
*
i
:
8
*
i
+
8
]
=
[
texLeft
,
texBottom
,
texRight
,
texBottom
,
self
.
marker
_vertex_list
.
tex_coords
[
8
*
i
:
8
*
i
+
8
]
=
[
texLeft
,
texBottom
,
texRight
,
texBottom
,
texRight
,
texTop
,
texLeft
,
texTop
]
self
.
location
_vertex_list
.
colors
[
16
*
i
:
16
*
i
+
16
]
=
(
location
.
color
+
[
location
.
get_alpha
()])
*
4
self
.
marker
_vertex_list
.
colors
[
16
*
i
:
16
*
i
+
16
]
=
(
marker
.
color
+
[
marker
.
get_alpha
()])
*
4
def
run
(
self
):
p
=
0
...
...
run.py
View file @
ffc59465
...
...
@@ -35,7 +35,7 @@ class ConfigData():
self
.
mm_limitation
=
config
.
getboolean
(
"Matter"
,
"mm_limitation"
)
self
.
particle_mm_size
=
config
.
getint
(
"Matter"
,
"particle_mm_size"
)
self
.
tile_mm_size
=
config
.
getint
(
"Matter"
,
"tile_mm_size"
)
self
.
location
_mm_size
=
config
.
getint
(
"Matter"
,
"
location
_mm_size"
)
self
.
marker
_mm_size
=
config
.
getint
(
"Matter"
,
"
marker
_mm_size"
)
self
.
dir_name
=
None
def
swarm_sim
(
argv
):
...
...
scenario/between_particle_one_tile_particle.py
View file @
ffc59465
"""
A sim is created that has two particles, two
location
s, and two tiles.
A sim is created that has two particles, two
marker
s, and two tiles.
"""
def
scenario
(
sim
):
...
...
scenario/particles_tiles_locations_ring.py
View file @
ffc59465
...
...
@@ -29,23 +29,23 @@ def scenario(sim):
sim
.
add_tile
(
-
1.000000
,
-
2.000000
,
color
=
2
)
# 3rd ring
sim
.
add_
location
(
3.000000
,
0.000000
,
color
=
3
)
sim
.
add_
location
(
-
3.000000
,
0.000000
,
color
=
3
)
sim
.
add_
location
(
2.500000
,
1.000000
,
color
=
3
)
sim
.
add_
location
(
2.500000
,
-
1.000000
,
color
=
3
)
sim
.
add_
location
(
-
2.500000
,
1.000000
,
color
=
3
)
sim
.
add_
location
(
-
2.500000
,
-
1.000000
,
color
=
3
)
sim
.
add_
location
(
2.000000
,
2.000000
,
color
=
3
)
sim
.
add_
location
(
2.000000
,
-
2.000000
,
color
=
3
)
sim
.
add_
location
(
-
2.000000
,
2.000000
,
color
=
3
)
sim
.
add_
location
(
-
2.000000
,
-
2.000000
,
color
=
3
)
sim
.
add_
location
(
1.500000
,
3.000000
,
color
=
3
)
sim
.
add_
location
(
1.500000
,
-
3.000000
,
color
=
3
)
sim
.
add_
location
(
0.500000
,
3.000000
,
color
=
3
)
sim
.
add_
location
(
0.500000
,
-
3.000000
,
color
=
3
)
sim
.
add_
location
(
-
0.500000
,
3.000000
,
color
=
3
)
sim
.
add_
location
(
-
0.500000
,
-
3.000000
,
color
=
3
)
sim
.
add_
location
(
-
1.500000
,
3.000000
,
color
=
3
)
sim
.
add_
location
(
-
1.500000
,
-
3.000000
,
color
=
3
)
sim
.
add_
marker
(
3.000000
,
0.000000
,
color
=
3
)
sim
.
add_
marker
(
-
3.000000
,
0.000000
,
color
=
3
)
sim
.
add_
marker
(
2.500000
,
1.000000
,
color
=
3
)
sim
.
add_
marker
(
2.500000
,
-
1.000000
,
color
=
3
)
sim
.
add_
marker
(
-
2.500000
,
1.000000
,
color
=
3
)
sim
.
add_
marker
(
-
2.500000
,
-
1.000000
,
color
=
3
)
sim
.
add_
marker
(
2.000000
,
2.000000
,
color
=
3
)
sim
.
add_
marker
(
2.000000
,
-
2.000000
,
color
=
3
)
sim
.
add_
marker
(
-
2.000000
,
2.000000
,
color
=
3
)
sim
.
add_
marker
(
-
2.000000
,
-
2.000000
,
color
=
3
)
sim
.
add_
marker
(
1.500000
,
3.000000
,
color
=
3
)
sim
.
add_
marker
(
1.500000
,
-
3.000000
,
color
=
3
)
sim
.
add_
marker
(
0.500000
,
3.000000
,
color
=
3
)
sim
.
add_
marker
(
0.500000
,
-
3.000000
,
color
=
3
)
sim
.
add_
marker
(
-
0.500000
,
3.000000
,
color
=
3
)
sim
.
add_
marker
(
-
0.500000
,
-
3.000000
,
color
=
3
)
sim
.
add_
marker
(
-
1.500000
,
3.000000
,
color
=
3
)
sim
.
add_
marker
(
-
1.500000
,
-
3.000000
,
color
=
3
)
scenario/test_interfaces.py
View file @
ffc59465
...
...
@@ -4,7 +4,7 @@ A sim is created that has particles formated in a ring structure that is up to 5
def
scenario
(
sim
):
sim
.
add_particle
(
0
,
0
,
color
=
3
)
sim
.
add_tile
(
1.0
,
0.0
)
sim
.
add_
location
(
3.0
,
2.0
)
sim
.
add_
marker
(
3.0
,
2.0
)
# 1st ring
sim
.
add_particle
(
1.000000
,
0.000000
,
color
=
1
)
...
...
scenario/two_particles_tiles_locations.py
View file @
ffc59465
"""
A sim is created that has two particles, two
location
s, and two tiles.
A sim is created that has two particles, two
marker
s, and two tiles.
"""
def
scenario
(
sim
):
sim
.
add_particle
(
0
,
0
)
sim
.
add_particle
(
1
,
0
)
sim
.
add_
location
(
0.5
,
1
)
sim
.
add_
marker
(
0.5
,
1
)
sim
.
add_tile
(
-
1
,
0
)
sim
.
add_tile
(
1
,
0
)
solution/create_delete.py
View file @
ffc59465
"""
This solution is an example for creating and deleting, particles, tiles or
location
s
This solution is an example for creating and deleting, particles, tiles or
marker
s
"""
import
logging
...
...
@@ -21,10 +21,10 @@ def solution(sim):
for
particle
in
sim
.
get_particle_list
():
print
(
"Sim started"
)
particle
.
create_tile_in
(
E
)
particle
.
create_
location
_in
(
W
)
particle
.
create_
marker
_in
(
W
)
if
sim
.
get_actual_round
()
==
2
:
if
len
(
sim
.
get_particle_list
())
>
0
:
# sim.get_particle_list()[0].delete_
location
_in(W)
# sim.get_particle_list()[0].delete_
marker
_in(W)
sim
.
get_particle_list
()[
0
].
create_particle_in
(
W
)
sim
.
get_particle_list
()[
0
].
create_particle_in
(
W
)
if
sim
.
get_actual_round
()
==
3
:
...
...
@@ -34,17 +34,17 @@ def solution(sim):
sim
.
get_particle_list
()[
0
].
delete_tile_in
(
E
)
if
sim
.
get_actual_round
()
==
4
:
sim
.
get_particle_list
()[
0
].
create_tile_on
(
1
,
0
)
sim
.
get_particle_list
()[
0
].
create_
location
_on
(
1
,
0
)
sim
.
get_particle_list
()[
0
].
create_
marker
_on
(
1
,
0
)
if
sim
.
get_actual_round
()
==
5
:
sim
.
get_particle_list
()[
0
].
delete_tile_on
(
1
,
0
)
if
sim
.
get_actual_round
()
==
6
:
sim
.
get_particle_list
()[
0
].
create_particle_on
(
-
1
,
0
)
sim
.
get_particle_list
()[
0
].
delete_
location
_on
(
1
,
0
)
sim
.
get_particle_list
()[
0
].
delete_
marker
_on
(
1
,
0
)
if
sim
.
get_actual_round
()
==
7
:
sim
.
get_particle_list
()[
0
].
delete_particle_on
(
-
1
,
0
)
if
sim
.
get_actual_round
()
==
8
:
sim
.
get_particle_list
()[
0
].
create_tile
()
sim
.
get_particle_list
()[
0
].
create_
location
()
sim
.
get_particle_list
()[
0
].
create_
marker
()
if
sim
.
get_actual_round
()
==
9
:
sim
.
get_particle_list
()[
0
].
delete_tile
()
...
...
@@ -52,4 +52,4 @@ def solution(sim):