flatland.utils.editor moduleΒΆ

class flatland.utils.editor.Controller(model, view)[source]ΒΆ

Bases: object

Controller to handle incoming events from the ipywidgets Updates the editor/model. Calls the View directly for things which do not directly effect the model (this means the mouse drag path before it is interpreted as transitions)

clear(event)[source]ΒΆ
debug(*args, **kwargs)[source]ΒΆ
load(event)[source]ΒΆ
log(*args, **kwargs)[source]ΒΆ
on_click(wid, event)[source]ΒΆ
on_mouse_move(wid, event)[source]ΒΆ

Mouse motion event handler for drawing.

refresh(event)[source]ΒΆ
regenerate(event)[source]ΒΆ
reset(event)[source]ΒΆ
reset_agents(event)[source]ΒΆ
rotate_agent(event)[source]ΒΆ
save(event)[source]ΒΆ
save_image(event)[source]ΒΆ
set_debug(event)[source]ΒΆ
set_debug_move(event)[source]ΒΆ
set_draw_mode(event)[source]ΒΆ
set_filename(event)[source]ΒΆ
set_model(model)[source]ΒΆ
set_regen_height(event)[source]ΒΆ
set_regen_width(event)[source]ΒΆ
step(event)[source]ΒΆ
class flatland.utils.editor.EditorMVC(env=None, sGL='PIL', env_filename='temp.pkl')[source]ΒΆ

Bases: object

EditorMVC - a class to encompass and assemble the Jupyter Editor Model-View-Controller.

class flatland.utils.editor.EditorModel(env, env_filename='temp.pkl')[source]ΒΆ

Bases: object

add_target(rc_cell)[source]ΒΆ
clear()[source]ΒΆ
clear_cell(cell_row_col)[source]ΒΆ
click_agent(cell_row_col)[source]ΒΆ

The user has clicked on a cell - * If there is an agent, select it

  • If that agent was already selected, then deselect it
  • If there is no agent selected, and no agent in the cell, create one
  • If there is an agent selected, and no agent in the cell, move the selected agent to the cell
debug(*args, **kwargs)[source]ΒΆ
debug_cell(rc_cell)[source]ΒΆ
drag_path_element(rc_cell)[source]ΒΆ

Mouse motion event handler for drawing.

find_agent_at(cell_row_col)[source]ΒΆ
fix_env()[source]ΒΆ
interpolate_pair(rcLast, rc_cell)[source]ΒΆ
interpolate_path(lrcPath)[source]ΒΆ
load()[source]ΒΆ
log(*args, **kwargs)[source]ΒΆ
mod_path(bAddRemove)[source]ΒΆ
mod_rail_2cells(lrcCells, bAddRemove=True, iCellToMod=0, bPop=False)[source]ΒΆ

Add transitions for rail between two cells lrcCells – list of two rc cells bAddRemove – whether to add (True) or remove (False) the transition iCellToMod – the index of the cell to modify: either 0 or 1

mod_rail_3cells(lrcStroke, bAddRemove=True, bPop=True)[source]ΒΆ

Add transitions for rail spanning three cells. lrcStroke – list containing β€œstroke” of cells across grid bAddRemove – whether to add (True) or remove (False) the transition The transition is added to or removed from the 2nd cell, consistent with entering from the 1st cell, and exiting into the 3rd. Both the forward and backward transitions are added, eg rcCells [(3,4), (2,4), (2,5)] would result in the transitions N->E and W->S in cell (2,4).

mod_rail_cell_seq(lrcStroke, bAddRemove=True)[source]ΒΆ
redraw()[source]ΒΆ
regenerate(method=None, nAgents=0, env=None)[source]ΒΆ
reset(regenerate_schedule=False, nAgents=0)[source]ΒΆ
restart_agents()[source]ΒΆ
save()[source]ΒΆ
save_image()[source]ΒΆ
set_debug(debug)[source]ΒΆ
set_debug_move(debug)[source]ΒΆ
set_draw_mode(draw_mode)[source]ΒΆ
set_env(env)[source]ΒΆ

set a new env for the editor, used by load and regenerate.

set_filename(filename)[source]ΒΆ
set_regen_height(size)[source]ΒΆ
set_regen_width(size)[source]ΒΆ
class flatland.utils.editor.View(editor, sGL='MPL', screen_width=1200, screen_height=1200)[source]ΒΆ

Bases: object

The Jupyter Editor View - creates and holds the widgets comprising the Editor.

display()[source]ΒΆ
drag_path_element(x, y)[source]ΒΆ
draw_stroke()[source]ΒΆ
init_canvas()[source]ΒΆ
init_widgets()[source]ΒΆ
log(*args, **kwargs)[source]ΒΆ
new_env()[source]ΒΆ

Tell the view to update its graphics when a new env is created.

redisplay_image()[source]ΒΆ
redraw()[source]ΒΆ
xy_to_rc(x, y)[source]ΒΆ