Commit e84af8b2 authored by Ahmad Reza's avatar Ahmad Reza
Browse files

No world.py anymore everything is in sim.py

Bugfix run.py and config.py
parent 3b844d97
[Simulator]
seedvalue = 1
#2
#One tile works with 7 and with 1 in goes into a loop
# L3 with seed 9 almost
#Tube with seed 4 works
#with 8 it is getting into a loop
#With L1 World
max_round = 100
visualization=1
random_order=1
[World]
window_size_x =600
window_size_y =800
size_x = 9
size_y = 6
max_particles=10000
[matter]
mm_limitation= 0
## Seedvalue for the same random sequence
## Different number creates a different random sequence
seedvalue = 12
## Maximum round number in swarm-sim
max_round = 30
# Visualization 1 = On, 0 = Off
visualization = 0
## 1 = Call of particles in randmom order
## 0 = Call of particles in added order in scenario
random_order = 1
## Viewing window size in pixels
window_size_x = 600
window_size_y = 800
## 0 = Unlimited sim size
## 1 = limited sim size
border = 0
## Swarm-Sim sim size in points
## Works only with border flag set on 1
size_x = 20
size_y = 20
## Maximum number of particles that can be created while simulating
max_particles = 10000
[Matter]
## with memory (mm) limitation 1=Yes 0=No
mm_limitation = 0
## mm size in quantity
## Works only with mm_limitation flag set on 1
location_mm_size = 2
particle_mm_size = 2
tile_mm_size = 2
tile_color_map=0
[File]
#scenario = two_particles_tiles_locations.py
#scenario = tile_beside_particle.py
##Examples##
##Moving
scenario = lonely_particle.py
solution = random_walk.py
#solution = round_walk.py
## Creating and Deleting
#scenario = lonely_particle.py
#scenario=one_particle_and_one_tile.py
#scenario = two_particles_infront.py
#scenario= n_particle_on_a_line.py
#scenario= lined_particles.py
#scenario=rand_n_tile_one_particle.py
#scenario = world_five_rings_particle.py
#scenario = world_five_rings_tiles.py
#scenario = world_five_rings_particle_tiles.py
#scenario=all_matters_in_1st_ring.py
#scenario = world_two_rings_particle_tiles.py
#scenario = world_two_rings_particle.py
#scenario = world_test_interfaces.py
#scenario=unsorted_tiles.py
#scenario=S2_oddGapWorld.py
#scenario=lonely_tile.py
#scenario=lonely_tile_L1.py
#scenario=lonely_tile_L2.py
#scenario=lonely_tile_L3.py
#scenario= S2_tripleTileLineWorld.py
#scenario=lined_particles_to_tile.py
#scenario = whole_island.py
# scenario = whole_island_ph1.py
#scenario = whole_island_ph2.py
#scenario = whole_island_ph3.py
##scenario = whole_island_L1.py
#orld = whole_island_L2.py
#scenario=reagenz.py
#scenario=cemal_world_30.py
#scenario=random_200_200_200.py
#solution = read_write.py
#solution = scanning.py
#solution = create_delete.py
#solution = scanning_for_all_aims.py
#solution = take_drop_matters.py
#solution = take_drop_particles.py
#solution = take_drop_tile.py
#solution = random_walk.py
#solution=move_to_tile
#solution=walk_on_Take_Drop_tiles.py
#solution=move_to_tile_better
#solution = round_walk.py
#solution = round_walk_hex.py
#solution = round_walk_hex_steps.py
#solution = round_walk_hex_norec.py
#solution = search_for_tile_rw.py
#solution = create_delete.py
## Take and Drop
#scenario = between_particle_one_tile_particle.py
#solution= take_drop_aims.py
## Read and Write
#scenario = two_particles_tiles_locations.py
#solution = read_write.py
## Scanning for matters
#scenario = particles_tiles_locations_ring.py
#solution= scanning_for_all_aims.py
## All interfaces
#scenario = test_interfaces.py
#solution = test_all_the_interfaces.py
#solution = pheromone_particle.py
#solution = pheromone_location.py
#solution = pheromone_location_with_nest.py
#solution = strongest_pheromone_nest.py
#solution = strongest_pheromone_nest_NB.py
#solution = probability_pheromone_nest.py
#solution = SolutionBeispiel.py
#solution = random_walk_back_for.py
#solution = random_walk_search.py
#solution = oppnet_search.py
#solution = oppnet_epidemic.py
#solution = search_for_tile_rw.py
#solution = S2_allMoving.py
#solution = indi_encaps.py
#solution = no_jam_control.py
#solution = jam_neigh_controll.py
#solution = mv_ch_near_tile.py
#solution = flock_m2.py
#solution = flock_m3.py
#solution = flock_m4.py
#solution = greedy_enc_m1.py
#solution = clockwise_enc_m1.py
#solution = encaps_round.py
#solution = encaps_round_m2.py
#solution = encaps_tile_m1.py
#solution = encaps_tile_m2.py
#solution = encaps_tile_m3.py
#solution = encaps_tile_m4.py
#solution = encaps_tile_m5.py
#solution = encaps_tile_m6.py
#solution = encaps_tile_m7.py
#solution = encaps_tile_m8.py
#solution = encaps_tile_m9.py
#solution = encaps_tile_m10.py
#solution = encaps_tile_m11.py
#solution = encaps_griddy_m1.py
#solution = cemal_solution.py
#solution = cemal_final.py
#solution = my_Zwei_Particle_solution.py
#solution = move_protocol.py
#solution = test_move_protocol.py
#random walk
#scenario = world_two_rings_particle_tiles.py
#solution = random_walk_search.py
# Coating the Tile
#scenario = island_L2.py
#solution = encaps_tile_m11.py
# Filling up the whole
#scenario = whole_island_ph3.py
#scenario = whole_island_L2.py
#solution = communication_m1.py
#Kalman Coating
solution = kalman_coating.py
#scenario=test_kalman.py
#scenario=S2_oddGapWorld.py
#scenario=S2_singleTileWorld.py
#scenario=lined_particles_to_tile.py
scenario = whole_island.py
#scenario = whole_island_tube.py
#scenario = tube_particles.py
#scenario=whole_island.py
#scenario = one_whole_island.py
#scenario = whole_island_ph1.py
#scenario = whole_island_ph2.py
#scenario = whole_island_ph3.py
#scenario = whole_island_L1.py
#scenario = whole_island_L2.py
#scenario=tile_beside_particle.py
# FLocking
#solution=flock_for_two.py
#solution=round_walk_hex_norec.py
#solution=testsol.py
#solution=get_together.py
#scenario=particle_line.py
#New Coating Algorithm
#solution = coating.py
......@@ -43,7 +43,7 @@
<li><a href="oppnet_csv_generator.html">oppnet_csv_generator</a></li>
<li><a href="particle.html">particle</a></li>
<li><a href="tile.html">tile</a></li>
<li><a href="world.html">world</a></li>
<li><a href="sim.html">sim</a></li>
</ul>
</div>
......
......@@ -38,7 +38,7 @@
<h1>Source code for location</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;The location module provides the interface to the locations. A location is any point on</span>
<span class="sd"> the coordinate system of the simulators world&quot;&quot;&quot;</span>
<span class="sd"> the coordinate system of the simulators sim&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">uuid</span>
......@@ -54,12 +54,12 @@
<div class="viewcode-block" id="matter"><a class="viewcode-back" href="../location.html#location.matter">[docs]</a><span class="k">class</span> <span class="nc">matter</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;In the classe location all the methods for the characterstic of a location is included&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">world</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">black</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">black</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Initializing the location constructor&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="n">color</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__id</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">uuid</span><span class="o">.</span><span class="n">uuid4</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span> <span class="o">=</span> <span class="n">world</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span> <span class="o">=</span> <span class="n">sim</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="o">=</span><span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__modified</span><span class="o">=</span><span class="kc">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__alpha</span><span class="o">=</span><span class="n">alpha</span>
......@@ -102,7 +102,7 @@
<span class="n">tmp_memory</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">:</span>
<span class="n">tmp_memory</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_read</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_read</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">None</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
......@@ -132,7 +132,7 @@
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span> <span class="o">==</span> <span class="kc">True</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">)</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_size</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span></div>
......@@ -150,7 +150,7 @@
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span> <span class="o">==</span> <span class="kc">True</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">)</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_size</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">[</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y-%m-</span><span class="si">%d</span><span class="s1"> %H:%M:%S.</span><span class="si">%f</span><span class="s1">&#39;</span><span class="p">)[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">data</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span></div>
......
......@@ -38,7 +38,7 @@
<h1>Source code for matter</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;The location module provides the interface to the locations. A location is any point on</span>
<span class="sd"> the coordinate system of the simulators world&quot;&quot;&quot;</span>
<span class="sd"> the coordinate system of the simulators sim&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">uuid</span>
......@@ -54,12 +54,12 @@
<div class="viewcode-block" id="matter"><a class="viewcode-back" href="../matter.html#matter.matter">[docs]</a><span class="k">class</span> <span class="nc">matter</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;In the classe location all the methods for the characterstic of a location is included&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">world</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">black</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">black</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Initializing the location constructor&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="n">color</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__id</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">uuid</span><span class="o">.</span><span class="n">uuid4</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span> <span class="o">=</span> <span class="n">world</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span> <span class="o">=</span> <span class="n">sim</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="o">=</span><span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__modified</span><span class="o">=</span><span class="kc">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__alpha</span><span class="o">=</span><span class="n">alpha</span>
......@@ -102,7 +102,7 @@
<span class="n">tmp_memory</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">:</span>
<span class="n">tmp_memory</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_read</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_read</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">None</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">tmp_memory</span><span class="p">))</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
......@@ -132,7 +132,7 @@
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span> <span class="o">==</span> <span class="kc">True</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">)</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_size</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span></div>
......@@ -150,7 +150,7 @@
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span> <span class="o">==</span> <span class="kc">True</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">)</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_size</span><span class="p">)</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">mm_limit</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_memory</span><span class="p">[</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y-%m-</span><span class="si">%d</span><span class="s1"> %H:%M:%S.</span><span class="si">%f</span><span class="s1">&#39;</span><span class="p">)[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">data</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">update_metrics</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">(),</span> <span class="n">memory_write</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">False</span></div>
......
......@@ -48,18 +48,18 @@
<span class="n">seedvalue</span> <span class="o">=</span> <span class="mi">5</span>
<span class="n">nTime</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">utcnow</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%Y-%m-</span><span class="si">%d</span><span class="s1"> %H:%M:%S&#39;</span><span class="p">)[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">opts</span><span class="p">,</span> <span class="n">args</span> <span class="o">=</span> <span class="n">getopt</span><span class="o">.</span><span class="n">getopt</span><span class="p">(</span><span class="n">argv</span><span class="p">,</span> <span class="s2">&quot;hs:w:r:n:v:&quot;</span><span class="p">,</span> <span class="p">[</span><span class="s2">&quot;solution=&quot;</span><span class="p">,</span> <span class="s2">&quot;world=&quot;</span><span class="p">])</span>
<span class="n">opts</span><span class="p">,</span> <span class="n">args</span> <span class="o">=</span> <span class="n">getopt</span><span class="o">.</span><span class="n">getopt</span><span class="p">(</span><span class="n">argv</span><span class="p">,</span> <span class="s2">&quot;hs:w:r:n:v:&quot;</span><span class="p">,</span> <span class="p">[</span><span class="s2">&quot;solution=&quot;</span><span class="p">,</span> <span class="s2">&quot;sim=&quot;</span><span class="p">])</span>
<span class="k">except</span> <span class="n">getopt</span><span class="o">.</span><span class="n">GetoptError</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Error: main.py -r &lt;randomeSeed&gt; -s &lt;solution&gt; -w &lt;world&gt; -n &lt;maxRounds&gt;&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Error: main.py -r &lt;randomeSeed&gt; -s &lt;solution&gt; -w &lt;sim&gt; -n &lt;maxRounds&gt;&#39;</span><span class="p">)</span>
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="k">for</span> <span class="n">opt</span><span class="p">,</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="p">:</span>
<span class="k">if</span> <span class="n">opt</span> <span class="o">==</span> <span class="s1">&#39;-h&#39;</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;main.py -r &lt;randomeSeed&gt; -s &lt;solution&gt; -w &lt;world&gt; -n &lt;maxRounds&gt;&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;main.py -r &lt;randomeSeed&gt; -s &lt;solution&gt; -w &lt;sim&gt; -n &lt;maxRounds&gt;&#39;</span><span class="p">)</span>
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">()</span>
<span class="k">elif</span> <span class="n">opt</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;-s&quot;</span><span class="p">,</span> <span class="s2">&quot;--solution&quot;</span><span class="p">):</span>
<span class="n">solution_file</span> <span class="o">=</span> <span class="n">arg</span>
<span class="k">elif</span> <span class="n">opt</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;-w&quot;</span><span class="p">,</span> <span class="s2">&quot;--world&quot;</span><span class="p">):</span>
<span class="n">world_file</span> <span class="o">=</span> <span class="n">arg</span>
<span class="k">elif</span> <span class="n">opt</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;-w&quot;</span><span class="p">,</span> <span class="s2">&quot;--sim&quot;</span><span class="p">):</span>
<span class="n">sim_file</span> <span class="o">=</span> <span class="n">arg</span>
<span class="k">elif</span> <span class="n">opt</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;-r&quot;</span><span class="p">,</span> <span class="s2">&quot;--seed&quot;</span><span class="p">):</span>
<span class="n">seedvalue</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">opt</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;-n&quot;</span><span class="p">,</span> <span class="s2">&quot;--maxrounds&quot;</span><span class="p">):</span>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -84,21 +84,21 @@
<span class="bp">self</span><span class="o">.</span><span class="n">__round_counter</span> <span class="o">+=</span> <span class="mi">1</span></div>
<div class="viewcode-block" id="Sim.run"><a class="viewcode-back" href="../sim.html#sim.Sim.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">world</span><span class="p">,</span> <span class="n">solution</span><span class="p">):</span>
<div class="viewcode-block" id="Sim.run"><a class="viewcode-back" href="../sim.html#sim.Sim.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="p">,</span> <span class="n">solution</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> :param world: The worlds object</span>
<span class="sd"> :param sim: The sims object</span>
<span class="sd"> :param solution: The name of the solution file</span>
<span class="sd"> :return:</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">solution</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">mod</span> <span class="o">=</span> <span class="n">importlib</span><span class="o">.</span><span class="n">import_module</span><span class="p">(</span><span class="s1">&#39;lib.solutions.&#39;</span><span class="o">+</span><span class="n">solution</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s1">&#39;.py&#39;</span><span class="p">))</span>
<span class="k">while</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">()</span> <span class="o">&lt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_max_round</span><span class="p">():</span>
<span class="n">mod</span><span class="o">.</span><span class="n">solution</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">world</span><span class="p">)</span>
<span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">next_line</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">())</span>
<span class="n">mod</span><span class="o">.</span><span class="n">solution</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="p">)</span>
<span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">next_line</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_actual_round</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__round_counter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__round_counter</span> <span class="o">+</span> <span class="mi">1</span>
<span class="n">world</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">aggregate_metrics</span><span class="p">()</span> <span class="c1"># After simulation is finished, aggregate everything</span>
<span class="k">for</span> <span class="n">particle</span> <span class="ow">in</span> <span class="n">world</span><span class="o">.</span><span class="n">particles</span><span class="p">:</span>
<span class="n">sim</span><span class="o">.</span><span class="n">csv_round_writer</span><span class="o">.</span><span class="n">aggregate_metrics</span><span class="p">()</span> <span class="c1"># After simulation is finished, aggregate everything</span>
<span class="k">for</span> <span class="n">particle</span> <span class="ow">in</span> <span class="n">sim</span><span class="o">.</span><span class="n">particles</span><span class="p">:</span>
<span class="n">particle</span><span class="o">.</span><span class="n">csv_particle_writer</span><span class="o">.</span><span class="n">close_particle</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
......
......@@ -56,9 +56,9 @@
<div class="viewcode-block" id="Tile"><a class="viewcode-back" href="../tile.html#tile.Tile">[docs]</a><span class="k">class</span> <span class="nc">Tile</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;In the classe location all the methods for the characterstic of a location is included&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">world</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">gray</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">gray</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Initializing the location constructor&quot;&quot;&quot;</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span> <span class="n">world</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s2">&quot;tile&quot;</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="n">mm_limit</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="n">mm_size</span><span class="p">)</span>
<span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span> <span class="n">sim</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s2">&quot;tile&quot;</span><span class="p">,</span> <span class="n">mm_limit</span><span class="o">=</span><span class="n">mm_limit</span><span class="p">,</span> <span class="n">mm_size</span><span class="o">=</span><span class="n">mm_size</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__isCarried</span> <span class="o">=</span> <span class="kc">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">created</span> <span class="o">=</span> <span class="kc">False</span>
......@@ -90,8 +90,8 @@
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">coords</span><span class="o">==</span><span class="mi">0</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__isCarried</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">tile_map</span><span class="p">:</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">tile_map</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">coords</span><span class="p">]</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">tile_map</span><span class="p">:</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">tile_map</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">coords</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__isCarried</span> <span class="o">=</span> <span class="kc">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">touch</span><span class="p">()</span>
<span class="k">return</span> <span class="kc">True</span>
......@@ -99,8 +99,8 @@
<span class="k">return</span> <span class="kc">False</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__isCarried</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">tile_map</span><span class="p">:</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">tile_map</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">coords</span><span class="p">]</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">tile_map</span><span class="p">:</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">tile_map</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">coords</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__isCarried</span> <span class="o">=</span> <span class="kc">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="o">=</span> <span class="n">coords</span>
<span class="bp">self</span><span class="o">.</span><span class="n">touch</span><span class="p">()</span>
......@@ -117,7 +117,7 @@
<span class="sd"> :param coords: the given position</span>
<span class="sd"> :return: None</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">world</span><span class="o">.</span><span class="n">tile_map</span><span class="p">[</span><span class="n">coords</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">tile_map</span><span class="p">[</span><span class="n">coords</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coords</span> <span class="o">=</span> <span class="n">coords</span>
<span class="bp">self</span><span class="o">.</span><span class="n">__isCarried</span> <span class="o">=</span> <span class="kc">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">touch</span><span class="p">()</span></div>
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,12 +23,12 @@ and instert the following code inside:
direction = [E, SE, SW, W, NW, NE] #direction list
def solution(self, world):
def solution(self, sim):
"""
All the magic starts from here
:param self: The object instance of the sim.py
:param world: The object instance of the created world
:param sim: The object instance of the created sim
"""
......
How to add a World
How to add a sim
===============
Before the ORN Simulator can be started, its simulation world has to be created.
At lease one particle should be created that takse the action of the world.
For creating a particle just create a python file e.g. one_particle_world.py
in the folder robtotsOnTiles/worlds/ and insert the following code:
Before the ORN Simulator can be started, its simulation sim has to be created.
At lease one particle should be created that takse the action of the sim.
For creating a particle just create a python file e.g. one_particle_sim.py
in the folder robtotsOnTiles/sims/ and insert the following code:
def create_world(self):
def create_sim(self):
self.add_particle(0,0)
......@@ -16,10 +16,10 @@ That is all and you created a particle.
The same thing you can do it with creating locations and tiles. E.g creating two particles, tiles, and locations.
You have to create a python file e.g. two_particles_tiles_locations.py in robtotsOnTiles/worlds/ and insert the following code:
You have to create a python file e.g. two_particles_tiles_locations.py in robtotsOnTiles/sims/ and insert the following code:
def create_world(self):
def create_sim(self):
self.add_particle(0, 0)
self.add_particle(1, 0)
self.add_location(2, 0)
......
......@@ -12,11 +12,11 @@ Contents:
:maxdepth: 2
installation
addingWorld
addingsim
addingSolutions
main
sim
world
sim
matter
location
tile
......
......@@ -12,4 +12,4 @@ lib
sim
tile
vis
world
sim