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
370907ab
Commit
370907ab
authored
Sep 18, 2019
by
Ahmad Reza
Browse files
Merge remote-tracking branch 'origin/master'
Conflicts: lib/particle.py solution/random_walk.py
parents
170a94e9
3157195a
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/particle.py
View file @
370907ab
...
...
@@ -11,12 +11,14 @@ TODO: Erase Memory
import
logging
,
math
from
lib
import
csv_generator
,
matter
from
lib.swarm_sim_header
import
*
from
lib.header
import
*
particle_counter
=
0
class
Particle
(
matter
.
Matter
):
"""In the classe marker all the methods for the characterstic of a marker is included"""
def
__init__
(
self
,
world
,
x
,
y
,
color
=
black
,
alpha
=
1
,
particle_counter
=
0
):
def
__init__
(
self
,
world
,
x
,
y
,
color
=
black
,
alpha
=
1
,
particle_counter
=
particle_counter
):
"""Initializing the marker constructor"""
super
().
__init__
(
world
,
(
x
,
y
),
color
,
alpha
,
type
=
"particle"
,
mm_size
=
world
.
config_data
.
particle_mm_size
)
...
...
@@ -80,24 +82,24 @@ class Particle(matter.Matter):
else
:
return
False
def
move_to
(
self
,
dir
ection
):
def
move_to
(
self
,
dir
):
"""
Moves the particle to the given direction
:param dir
ection
: The direction must be either: E, SE, SW, W, NW, or NE
:param dir: The direction must be either: E, SE, SW, W, NW, or NE
:return: True: Success Moving; False: Non moving
"""
dir
ection
_coord
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
dir
ection
,
direction
_coord
=
self
.
check_within_border
(
dir
ection
,
direction
_coord
)
if
check_coords
(
dir
ection
_coord
[
0
],
dir
ection
_coord
[
1
]):
dir_coord
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
dir
,
dir
_coord
=
self
.
check_within_border
(
dir
,
dir
_coord
)
if
check_coords
(
dir_coord
[
0
],
dir_coord
[
1
]):
if
self
.
coords
in
self
.
world
.
particle_map_coords
:
del
self
.
world
.
particle_map_coords
[
self
.
coords
]
if
not
dir
ection
_coord
in
self
.
world
.
particle_map_coords
:
self
.
coords
=
dir
ection
_coord
if
not
dir_coord
in
self
.
world
.
particle_map_coords
:
self
.
coords
=
dir_coord
self
.
world
.
particle_map_coords
[
self
.
coords
]
=
self
logging
.
info
(
"particle %s successfully moved to %s"
,
str
(
self
.
get_id
()),
dir
ection
)
logging
.
info
(
"particle %s successfully moved to %s"
,
str
(
self
.
get_id
()),
dir
)
self
.
world
.
csv_round
.
update_metrics
(
steps
=
1
)
self
.
csv_particle_writer
.
write_particle
(
steps
=
1
)
self
.
touch
()
...
...
@@ -113,28 +115,28 @@ class Particle(matter.Matter):
self
.
carried_particle
.
coords
=
self
.
coords
self
.
carried_particle
.
touch
()
def
check_within_border
(
self
,
dir
ection
,
direction
_coord
):
def
check_within_border
(
self
,
dir
,
dir
_coord
):
if
self
.
world
.
config_data
.
border
==
1
and
\
(
abs
(
dir
ection
_coord
[
0
])
>
self
.
world
.
get_
world
_x_size
()
or
abs
(
dir
ection
_coord
[
1
])
>
self
.
world
.
get_
world
_y_size
()):
dir
ection
=
direction
-
3
if
dir
ection
>
2
else
dir
ection
+
3
dir
ection
_coord
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
return
dir
ection
,
direction
_coord
(
abs
(
dir_coord
[
0
])
>
self
.
world
.
get_
sim
_x_size
()
or
abs
(
dir_coord
[
1
])
>
self
.
world
.
get_
sim
_y_size
()):
dir
=
dir
-
3
if
dir
>
2
else
dir
+
3
dir_coord
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
return
dir
,
dir
_coord
def
move_to_in_bounds
(
self
,
dir
ection
):
def
move_to_in_bounds
(
self
,
dir
):
"""
Moves the particle to the given direction if it would remain in bounds.
:param dir
ection
: The direction must be either: E, SE, SW, W, NW, or NE
:param dir: The direction must be either: E, SE, SW, W, NW, or NE
:return: True: Success Moving; False: Non moving
"""
dir
ection
_coord
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
sim_coord
=
coords_to_sim
(
dir
ection
_coord
)
if
self
.
world
.
get_
world
_x_size
()
>=
abs
(
sim_coord
[
0
])
and
\
self
.
world
.
get_
world
_y_size
()
>=
abs
(
sim_coord
[
1
]):
return
self
.
move_to
(
dir
ection
)
dir_coord
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
sim_coord
=
coords_to_sim
(
dir_coord
)
if
self
.
world
.
get_
sim
_x_size
()
>=
abs
(
sim_coord
[
0
])
and
\
self
.
world
.
get_
sim
_y_size
()
>=
abs
(
sim_coord
[
1
]):
return
self
.
move_to
(
dir
)
else
:
# 'bounce' off the wall
n_dir
=
dir
ection
-
3
if
dir
ection
>
2
else
dir
ection
+
3
n_dir
=
dir
-
3
if
dir
>
2
else
dir
+
3
self
.
move_to
(
n_dir
)
def
read_from_with
(
self
,
matter
,
key
=
None
):
...
...
@@ -164,73 +166,73 @@ class Particle(matter.Matter):
else
:
return
None
def
matter_in
(
self
,
dir
ection
=
E
):
def
matter_in
(
self
,
dir
=
E
):
"""
:param dir
ection
: the direction to check if a matter is there
:param dir: the direction to check if a matter is there
:return: True: if a matter is there, False: if not
"""
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_tile_map_coords
()
\
or
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_particle_map_coords
()
\
or
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_marker_map_coords
():
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_tile_map_coords
()
\
or
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_particle_map_coords
()
\
or
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_marker_map_coords
():
return
True
else
:
return
False
def
tile_in
(
self
,
dir
ection
=
E
):
def
tile_in
(
self
,
dir
=
E
):
"""
:param dir
ection
: the direction to check if a tile is there
:param dir: the direction to check if a tile is there
:return: True: if a tile is there, False: if not
"""
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_tile_map_coords
():
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_tile_map_coords
():
return
True
else
:
return
False
def
particle_in
(
self
,
dir
ection
=
E
):
def
particle_in
(
self
,
dir
=
E
):
"""
:param dir
ection
: the direction to check if a particle is there
:param dir: the direction to check if a particle is there
:return: True: if a particle is there, False: if not
"""
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_particle_map_coords
():
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_particle_map_coords
():
return
True
else
:
return
False
def
marker_in
(
self
,
dir
ection
=
E
):
def
marker_in
(
self
,
dir
=
E
):
"""
:param dir
ection
: the direction to check if a marker is there
:param dir: the direction to check if a marker is there
:return: True: if a marker is there, False: if not
"""
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_marker_map_coords
():
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_marker_map_coords
():
return
True
else
:
return
False
def
get_matter_in
(
self
,
dir
ection
=
E
):
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_tile_map_coords
():
return
self
.
world
.
get_tile_map_coords
()[
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)]
elif
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_particle_map_coords
():
return
self
.
world
.
get_particle_map_coords
()[
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)]
elif
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_marker_map_coords
():
return
self
.
world
.
get_marker_map_coords
()[
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)]
def
get_matter_in
(
self
,
dir
=
E
):
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_tile_map_coords
():
return
self
.
world
.
get_tile_map_coords
()[
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)]
elif
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_particle_map_coords
():
return
self
.
world
.
get_particle_map_coords
()[
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)]
elif
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_marker_map_coords
():
return
self
.
world
.
get_marker_map_coords
()[
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)]
else
:
return
False
def
get_tile_in
(
self
,
dir
ection
=
E
):
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_tile_map_coords
():
return
self
.
world
.
get_tile_map_coords
()[
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)]
def
get_tile_in
(
self
,
dir
=
E
):
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_tile_map_coords
():
return
self
.
world
.
get_tile_map_coords
()[
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)]
else
:
return
False
def
get_particle_in
(
self
,
dir
ection
=
E
):
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_particle_map_coords
():
return
self
.
world
.
get_particle_map_coords
()[
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)]
def
get_particle_in
(
self
,
dir
=
E
):
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_particle_map_coords
():
return
self
.
world
.
get_particle_map_coords
()[
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)]
else
:
return
False
def
get_marker_in
(
self
,
dir
ection
=
E
):
if
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
in
self
.
world
.
get_marker_map_coords
():
return
self
.
world
.
get_marker_map_coords
()[
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)]
def
get_marker_in
(
self
,
dir
=
E
):
if
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
in
self
.
world
.
get_marker_map_coords
():
return
self
.
world
.
get_marker_map_coords
()[
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)]
else
:
return
False
...
...
@@ -480,17 +482,17 @@ class Particle(matter.Matter):
else
:
return
False
def
create_tile_in
(
self
,
dir
ection
=
None
,
color
=
gray
,
alpha
=
1
):
def
create_tile_in
(
self
,
dir
=
None
,
color
=
gray
,
alpha
=
1
):
"""
Creates a tile either in a given direction
:param dir
ection
: The direction on which the tile should be created. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the tile should be created. Options: E, SE, SW, W, NW, NE,
:return: New tile or False
"""
logging
.
info
(
"particle with id %s is"
,
self
.
get_id
())
logging
.
info
(
"Going to create a tile in %s "
,
str
(
dir
ection
)
)
if
dir
ection
!=
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
logging
.
info
(
"Going to create a tile in %s "
,
str
(
dir
)
)
if
dir
!=
None
:
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
new_tile
=
self
.
world
.
add_tile
(
coords
[
0
],
coords
[
1
],
color
,
alpha
)
if
new_tile
:
self
.
world
.
tile_map_coords
[
coords
[
0
],
coords
[
1
]].
created
=
True
...
...
@@ -566,18 +568,18 @@ class Particle(matter.Matter):
logging
.
info
(
"Could not delet tile with tile id %s"
,
str
(
id
))
return
False
def
delete_tile_in
(
self
,
dir
ection
=
None
):
def
delete_tile_in
(
self
,
dir
=
None
):
"""
Deletes a tile either in a given direction
:param dir
ection
: The direction on which the tile should be deleted. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the tile should be deleted. Options: E, SE, SW, W, NW, NE,
:return: True: Deleting successful; False: Deleting unsuccessful
"""
coords
=
()
if
dir
ection
is
not
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
ection
))
if
dir
is
not
None
:
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
if
coords
is
not
None
:
if
self
.
world
.
remove_tile_on
(
coords
):
logging
.
info
(
"Deleted tile with tile on coords %s"
,
str
(
coords
))
...
...
@@ -663,15 +665,15 @@ class Particle(matter.Matter):
logging
.
info
(
"Tile cannot taken because particle is carrieng either a tile or a particle"
,
str
(
id
))
return
False
def
take_tile_in
(
self
,
dir
ection
):
def
take_tile_in
(
self
,
dir
):
"""
Takes a tile that is in a given direction
:param dir
ection
: The direction on which the tile should be taken. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the tile should be taken. Options: E, SE, SW, W, NW, NE,
:return: True: successful taken; False: unsuccessful taken
"""
if
self
.
carried_particle
is
None
and
self
.
carried_tile
is
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
if
coords
in
self
.
world
.
tile_map_coords
:
self
.
carried_tile
=
self
.
world
.
tile_map_coords
[
coords
]
logging
.
info
(
"Tile with tile id %s is in the world"
,
str
(
self
.
carried_tile
.
get_id
()))
...
...
@@ -745,14 +747,14 @@ class Particle(matter.Matter):
else
:
return
False
def
drop_tile_in
(
self
,
dir
ection
):
def
drop_tile_in
(
self
,
dir
):
"""
Drops the taken tile on a given direction
:param dir
ection
: The direction on which the tile should be dropped. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the tile should be dropped. Options: E, SE, SW, W, NW, NE,
"""
if
self
.
carried_tile
is
not
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
if
coords
not
in
self
.
world
.
tile_map_coords
:
try
:
# cher: insert so to overcome the AttributeError
self
.
carried_tile
.
drop_me
(
coords
)
...
...
@@ -818,19 +820,19 @@ class Particle(matter.Matter):
else
:
return
False
def
create_particle_in
(
self
,
dir
ection
=
None
,
color
=
black
,
alpha
=
1
):
def
create_particle_in
(
self
,
dir
=
None
,
color
=
black
,
alpha
=
1
):
"""
Creates a particle either in a given direction
:toDo: seperate the direction and coordinates and delete state
:param dir
ection
: The direction on which the particle should be created. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the particle should be created. Options: E, SE, SW, W, NW, NE,
:return: New Particle or False
"""
coords
=
(
0
,
0
)
if
dir
ection
is
not
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
logging
.
info
(
"Going to create a particle in %s on position %s"
,
str
(
dir
ection
),
str
(
coords
))
if
dir
is
not
None
:
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Going to create a particle in %s on position %s"
,
str
(
dir
),
str
(
coords
))
new_particle
=
self
.
world
.
add_particle
(
coords
[
0
],
coords
[
1
],
color
,
alpha
)
if
new_particle
:
self
.
world
.
particle_map_coords
[
coords
[
0
],
coords
[
1
]].
created
=
True
...
...
@@ -907,16 +909,16 @@ class Particle(matter.Matter):
else
:
logging
.
info
(
"Could not delet particle with particle id %s"
,
str
(
id
))
def
delete_particle_in
(
self
,
dir
ection
=
None
):
def
delete_particle_in
(
self
,
dir
=
None
):
"""
Deletes a particle either in a given direction
:param dir
ection
: The direction on which the particle should be deleted. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the particle should be deleted. Options: E, SE, SW, W, NW, NE,
:return: True: Deleting successful; False: Deleting unsuccessful
"""
if
dir
ection
is
not
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
ection
))
if
dir
is
not
None
:
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
if
self
.
world
.
remove_particle_on
(
coords
):
logging
.
info
(
"Deleted particle with particle on coords %s"
,
str
(
coords
))
self
.
csv_particle_writer
.
write_particle
(
particle_deleted
=
1
)
...
...
@@ -996,15 +998,15 @@ class Particle(matter.Matter):
else
:
logging
.
info
(
"particle cannot taken because particle is carrieng either a particle or a particle"
,
str
(
id
))
def
take_particle_in
(
self
,
dir
ection
):
def
take_particle_in
(
self
,
dir
):
"""
Takes a particle that is in a given direction
:param dir
ection
: The direction on which the particle should be taken. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the particle should be taken. Options: E, SE, SW, W, NW, NE,
:return: True: successful taken; False: unsuccessful taken
"""
if
self
.
carried_tile
is
None
and
self
.
carried_particle
is
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
if
coords
in
self
.
world
.
particle_map_coords
:
logging
.
info
(
"Take particle"
)
self
.
carried_particle
=
self
.
world
.
particle_map_coords
[
coords
]
...
...
@@ -1078,14 +1080,14 @@ class Particle(matter.Matter):
logging
.
info
(
"No particle taken to drop"
)
return
False
def
drop_particle_in
(
self
,
dir
ection
):
def
drop_particle_in
(
self
,
dir
):
"""
Drops the particle tile in a given direction
:param dir
ection
: The direction on which the particle should be dropped. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the particle should be dropped. Options: E, SE, SW, W, NW, NE,
"""
if
self
.
carried_particle
is
not
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
if
coords
not
in
self
.
world
.
particle_map_coords
:
try
:
# cher: insert so to overcome the AttributeError
self
.
carried_particle
.
drop_me
(
coords
)
...
...
@@ -1160,17 +1162,17 @@ class Particle(matter.Matter):
else
:
return
False
def
create_marker_in
(
self
,
dir
ection
=
None
,
color
=
black
,
alpha
=
1
):
def
create_marker_in
(
self
,
dir
=
None
,
color
=
black
,
alpha
=
1
):
"""
Creates a marker either in a given direction
:param dir
ection
: The direction on which the marker should be created. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the marker should be created. Options: E, SE, SW, W, NW, NE,
:return: New marker or False
"""
coords
=
(
0
,
0
)
if
dir
ection
is
not
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
logging
.
info
(
"Going to create a marker in %s on position %s"
,
str
(
dir
ection
),
str
(
coords
))
if
dir
is
not
None
:
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Going to create a marker in %s on position %s"
,
str
(
dir
),
str
(
coords
))
new_marker
=
self
.
world
.
add_marker
(
coords
[
0
],
coords
[
1
],
color
,
alpha
)
if
new_marker
:
logging
.
info
(
"Created marker on coords %s"
,
str
(
coords
))
...
...
@@ -1241,19 +1243,19 @@ class Particle(matter.Matter):
else
:
logging
.
info
(
"Could not delet marker with marker id %s"
,
str
(
marker_id
))
def
delete_marker_in
(
self
,
dir
ection
=
None
):
def
delete_marker_in
(
self
,
dir
=
None
):
"""
Deletes a marker either in a given direction or on a given x,y coordinates
:param dir
ection
: The direction on which the marker should be deleted. Options: E, SE, SW, W, NW, NE,
:param dir: The direction on which the marker should be deleted. Options: E, SE, SW, W, NW, NE,
:param x: x coordinate
:param y: y coordinate
:return: True: Deleting successful; False: Deleting unsuccessful
"""
if
dir
ection
is
not
None
:
coords
=
get_coords_in_dir
ection
(
self
.
coords
,
dir
ection
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
ection
))
if
dir
is
not
None
:
coords
=
self
.
world
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
if
self
.
world
.
remove_marker_on
(
coords
):
logging
.
info
(
"Deleted marker with marker on coords %s"
,
str
(
coords
))
self
.
csv_particle_writer
.
write_particle
(
marker_deleted
=
1
)
...
...
lib/world.py
View file @
370907ab
...
...
@@ -79,6 +79,14 @@ class World:
def
success_termination
(
self
):
self
.
csv_round
.
success
()
self
.
set_end
()
def
get_max_round
(
self
):
"""
The max round number
:return: maximum round number
"""
return
self
.
config_data
.
max_round
def
get_actual_round
(
self
):
"""
...
...
solution/random_walk.py
View file @
370907ab
...
...
@@ -2,7 +2,8 @@ import random
#Standard Lib that has to be in each solution
from
solution.std_lib
import
*
def
solution
(
world
):
for
particle
in
world
.
get_particle_list
():
particle
.
move_to
(
random
.
choice
(
direction
))
\ No newline at end of file
if
world
.
get_actual_round
()
%
1
==
0
:
for
particle
in
world
.
get_particle_list
():
particle
.
move_to
(
random
.
choice
(
direction
))
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment