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
96da0e85
Commit
96da0e85
authored
Mar 07, 2019
by
Ahmad Reza
Browse files
Bug-Fix with delete_matter_in
Create_scenario changed to only scenario
parent
8b897d47
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/particle.py
View file @
96da0e85
...
@@ -1225,7 +1225,7 @@ class Particle(matter.matter):
...
@@ -1225,7 +1225,7 @@ class Particle(matter.matter):
logging
.
info
(
"Could not delet tile with tile id %s"
,
str
(
id
))
logging
.
info
(
"Could not delet tile with tile id %s"
,
str
(
id
))
return
False
return
False
def
delete_tile_in
(
self
,
dir
=
E
):
def
delete_tile_in
(
self
,
dir
=
None
):
"""
"""
Deletes a tile either in a given direction
Deletes a tile either in a given direction
...
@@ -1234,7 +1234,7 @@ class Particle(matter.matter):
...
@@ -1234,7 +1234,7 @@ class Particle(matter.matter):
:return: True: Deleting successful; False: Deleting unsuccessful
:return: True: Deleting successful; False: Deleting unsuccessful
"""
"""
coords
=
()
coords
=
()
if
-
1
<
dir
<
7
:
if
dir
is
not
None
:
coords
=
self
.
sim
.
get_coords_in_dir
(
self
.
coords
,
dir
)
coords
=
self
.
sim
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
if
coords
is
not
None
:
if
coords
is
not
None
:
...
@@ -1565,14 +1565,14 @@ class Particle(matter.matter):
...
@@ -1565,14 +1565,14 @@ class Particle(matter.matter):
:param dir: 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
:return: True: Deleting successful; False: Deleting unsuccessful
"""
"""
if
dir
:
if
dir
is
not
None
:
coords
=
self
.
sim
.
get_coords_in_dir
(
self
.
coords
,
dir
)
coords
=
self
.
sim
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
if
self
.
sim
.
remove_particle_on
(
coords
):
if
self
.
sim
.
remove_particle_on
(
coords
):
logging
.
info
(
"Deleted particle with particle on coords %s"
,
str
(
coords
))
logging
.
info
(
"Deleted particle with particle on coords %s"
,
str
(
coords
))
self
.
csv_particle_writer
.
write_particle
(
particle_deleted
=
1
)
self
.
csv_particle_writer
.
write_particle
(
particle_deleted
=
1
)
else
:
else
:
logging
.
info
(
"Could not delet particle on coords %s"
,
str
(
coords
))
logging
.
info
(
"Could not delet particle on coords %s"
,
str
(
coords
))
def
delete_particle_on
(
self
,
x
=
None
,
y
=
None
):
def
delete_particle_on
(
self
,
x
=
None
,
y
=
None
):
"""
"""
...
@@ -1900,7 +1900,7 @@ class Particle(matter.matter):
...
@@ -1900,7 +1900,7 @@ class Particle(matter.matter):
else
:
else
:
logging
.
info
(
"Could not delet location with location id %s"
,
str
(
location_id
))
logging
.
info
(
"Could not delet location with location id %s"
,
str
(
location_id
))
def
delete_location_in
(
self
,
dir
=
None
,
x
=
None
,
y
=
None
):
def
delete_location_in
(
self
,
dir
=
None
):
"""
"""
Deletes a location either in a given direction or on a given x,y coordinates
Deletes a location either in a given direction or on a given x,y coordinates
...
@@ -1910,16 +1910,14 @@ class Particle(matter.matter):
...
@@ -1910,16 +1910,14 @@ class Particle(matter.matter):
:return: True: Deleting successful; False: Deleting unsuccessful
:return: True: Deleting successful; False: Deleting unsuccessful
"""
"""
if
dir
:
if
dir
is
not
None
:
coords
=
self
.
sim
.
get_coords_in_dir
(
self
.
coords
,
dir
)
coords
=
self
.
sim
.
get_coords_in_dir
(
self
.
coords
,
dir
)
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
logging
.
info
(
"Deleting tile in %s direction"
,
str
(
dir
))
elif
x
is
not
None
and
y
is
not
None
:
if
self
.
sim
.
remove_location_on
(
coords
):
coords
=
(
x
,
y
)
logging
.
info
(
"Deleted location with location on coords %s"
,
str
(
coords
))
if
self
.
sim
.
remove_location_on
(
coords
):
self
.
csv_particle_writer
.
write_particle
(
location_deleted
=
1
)
logging
.
info
(
"Deleted location with location on coords %s"
,
str
(
coords
))
else
:
self
.
csv_particle_writer
.
write_particle
(
location_deleted
=
1
)
logging
.
info
(
"Could not delet location on coords %s"
,
str
(
coords
))
else
:
logging
.
info
(
"Could not delet location on coords %s"
,
str
(
coords
))
def
delete_location_on
(
self
,
x
=
None
,
y
=
None
):
def
delete_location_on
(
self
,
x
=
None
,
y
=
None
):
"""
"""
...
...
lib/sim.py
View file @
96da0e85
...
@@ -103,7 +103,7 @@ class Sim:
...
@@ -103,7 +103,7 @@ class Sim:
steps
=
0
,
directory
=
dir
)
steps
=
0
,
directory
=
dir
)
mod
=
importlib
.
import_module
(
'scenario.'
+
scenario_name
.
rsplit
(
'.'
,
1
)[
0
])
mod
=
importlib
.
import_module
(
'scenario.'
+
scenario_name
.
rsplit
(
'.'
,
1
)[
0
])
mod
.
create_
scenario
(
self
)
mod
.
scenario
(
self
)
if
random_order
:
if
random_order
:
random
.
shuffle
(
self
.
particles
)
random
.
shuffle
(
self
.
particles
)
...
...
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