From 7f5827bc9a81a22db9782171c9d962769c0f82fb Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 11:44:56 +0100 Subject: [PATCH 01/12] draft playground parameters --- abm/parameters/__init__.py | 0 abm/parameters/playground_parameters.py | 57 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 abm/parameters/__init__.py create mode 100644 abm/parameters/playground_parameters.py diff --git a/abm/parameters/__init__.py b/abm/parameters/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/abm/parameters/playground_parameters.py b/abm/parameters/playground_parameters.py new file mode 100644 index 00000000..01b16f1c --- /dev/null +++ b/abm/parameters/playground_parameters.py @@ -0,0 +1,57 @@ +from pydantic import BaseSettings + + +class PlaygroundEnvironmentParameters(BaseSettings): + """Environment variables""" + width: int = 500 + height: int = 500 + framerate: int = 30 # interactive + window_pad: int = 30 + use_ram_logging: bool = False + use_zarr: bool = True + save_csv_files: bool = False + parallel: bool = False + allow_border_patch_overlap: bool = True + + +class PlaygroundUIParameters(BaseSettings): + """Playground parameters""" + with_visualization: bool = True + show_vis_field: bool = False + show_vis_field_return: bool = True + show_vision_range: bool = True + + +class PlaygroundAgentParameters(BaseSettings): + """Agent variables""" + pooling_time: int = 0 + pooling_prob: int = 0 + agent_radius: int = 10 + agent_consumption: int = 1 + vision_range: int = 2000 + agent_fov: float = 1 # interactive + visual_exclusion: bool = True # interactive + ghost_mode: bool = True # interactive + patchwise_exclusion: bool = True + collide_agents: bool = False + + +class PlaygroundResourceParameters(BaseSettings): + """Resource variables""" + min_resc_perpatch: int = 200 + max_resc_perpatch: int = 201 + min_resc_quality: float = 0.25 + max_resc_quality: float = 0.25 + patch_radius: int = 15 # interactive + regenerate_patches: bool = True + teleport_exploit: bool = False + + +class PlaygroundParameters(BaseSettings): + environment_parameters: PlaygroundEnvironmentParameters = \ + PlaygroundEnvironmentParameters() + ui_parameters: PlaygroundUIParameters = PlaygroundUIParameters() + agent_parameters: PlaygroundAgentParameters = \ + PlaygroundAgentParameters() + resource_parameters: PlaygroundResourceParameters = \ + PlaygroundResourceParameters() From d19cac6b11ff29226220a83432e996ab84b8993c Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 11:45:16 +0100 Subject: [PATCH 02/12] add pydantic in the setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 6fb290a1..3da91db6 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ package_data={'p34abm': ['*.txt']}, python_requires=">=3.7", install_requires=[ + 'pydantic', 'pygame', 'pygame-widgets', 'numpy', From b9a500c42292e68cec45b8ebd82c3f0e3cd1d54c Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 11:46:00 +0100 Subject: [PATCH 03/12] draft agent parameters --- abm/parameters/agent_parameters.py | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 abm/parameters/agent_parameters.py diff --git a/abm/parameters/agent_parameters.py b/abm/parameters/agent_parameters.py new file mode 100644 index 00000000..5dc87c60 --- /dev/null +++ b/abm/parameters/agent_parameters.py @@ -0,0 +1,60 @@ +from pydantic import BaseSettings + + +class DecisionParameters(BaseSettings): + """Decision variables""" + # W + T_w: float = 0.5 + Eps_w: float = 3 + g_w: float = 0.085 + B_w: float = 0 + w_max: float = 1 + + # U + T_u: float = 0.5 + Eps_u: float = 3 + g_u: float = 0.085 + B_u: float = 0 + u_max: float = 1 + + # Inhibition + S_wu: float = 0.25 + S_uw: float = 0.01 + + # Calculating Private Information + Tau: int = 10 + F_N: float = 2 + F_R: float = 1 + + class Config: + env_prefix = 'DET_' + env_file = '.env' + env_file_encoding = 'utf-8' + + +class MovementParameters(BaseSettings): + """Movement variables""" + + # Exploration movement parameters + exp_vel_min: float = 1 + exp_vel_max: float = 1 + exp_theta_min: float = -0.3 + exp_theta_max: float = 0.3 + + # Relocation movement parameters + reloc_des_vel: float = 1 + reloc_theta_max: float = 0.5 + + # Exploitation params + # deceleration when a patch is reached + exp_stop_ratio: float = 0.08 + + class Config: + env_prefix = 'MOV_' + env_file = '.env' + env_file_encoding = 'utf-8' + + +class AgentParameters(BaseSettings): + movement_parameters: MovementParameters = MovementParameters() + decision_parameters: DecisionParameters = DecisionParameters() From 8be8cfd0fa501a543450d365c431273beded5117 Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 14:41:37 +0100 Subject: [PATCH 04/12] test agent params --- abm/parameters/agent_parameters.py | 71 +++++++++---------- abm/parameters/tests/__init__.py | 0 abm/parameters/tests/data/test.env | 2 + abm/parameters/tests/test_agent_parameters.py | 17 +++++ 4 files changed, 52 insertions(+), 38 deletions(-) create mode 100644 abm/parameters/tests/__init__.py create mode 100644 abm/parameters/tests/data/test.env create mode 100644 abm/parameters/tests/test_agent_parameters.py diff --git a/abm/parameters/agent_parameters.py b/abm/parameters/agent_parameters.py index 5dc87c60..8819025e 100644 --- a/abm/parameters/agent_parameters.py +++ b/abm/parameters/agent_parameters.py @@ -1,38 +1,33 @@ -from pydantic import BaseSettings +from pydantic import BaseSettings, BaseModel -class DecisionParameters(BaseSettings): +class DecisionParameters(BaseModel): """Decision variables""" # W - T_w: float = 0.5 - Eps_w: float = 3 - g_w: float = 0.085 - B_w: float = 0 - w_max: float = 1 - - # U - T_u: float = 0.5 - Eps_u: float = 3 - g_u: float = 0.085 - B_u: float = 0 - u_max: float = 1 - - # Inhibition - S_wu: float = 0.25 - S_uw: float = 0.01 - - # Calculating Private Information - Tau: int = 10 - F_N: float = 2 - F_R: float = 1 - - class Config: - env_prefix = 'DET_' - env_file = '.env' - env_file_encoding = 'utf-8' - - -class MovementParameters(BaseSettings): + T_w: float + # Eps_w: float = 3 + # g_w: float = 0.085 + # B_w: float = 0 + # w_max: float = 1 + # + # # U + # T_u: float = 0.5 + # Eps_u: float = 3 + # g_u: float = 0.085 + # B_u: float = 0 + # u_max: float = 1 + # + # # Inhibition + # S_wu: float = 0.25 + # S_uw: float = 0.01 + # + # # Calculating Private Information + # Tau: int = 10 + # F_N: float = 2 + # F_R: float = 1 + + +class MovementParameters(BaseModel): """Movement variables""" # Exploration movement parameters @@ -49,12 +44,12 @@ class MovementParameters(BaseSettings): # deceleration when a patch is reached exp_stop_ratio: float = 0.08 - class Config: - env_prefix = 'MOV_' - env_file = '.env' - env_file_encoding = 'utf-8' - class AgentParameters(BaseSettings): - movement_parameters: MovementParameters = MovementParameters() - decision_parameters: DecisionParameters = DecisionParameters() + test: str + # movement_parameters: MovementParameters + # dec: DecisionParameters + + class Config: + env_nested_delimiter = '__' + diff --git a/abm/parameters/tests/__init__.py b/abm/parameters/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/abm/parameters/tests/data/test.env b/abm/parameters/tests/data/test.env new file mode 100644 index 00000000..b67ce4c1 --- /dev/null +++ b/abm/parameters/tests/data/test.env @@ -0,0 +1,2 @@ +DEC__T_W=0.2 +TEST=t \ No newline at end of file diff --git a/abm/parameters/tests/test_agent_parameters.py b/abm/parameters/tests/test_agent_parameters.py new file mode 100644 index 00000000..914c2cfb --- /dev/null +++ b/abm/parameters/tests/test_agent_parameters.py @@ -0,0 +1,17 @@ +from pathlib import Path + +from abm.parameters.agent_parameters import AgentParameters + + +def test_agent_parameters(): + """ + Testing agent parameters + SEE: https://pydantic-docs.helpmanual.io/usage/settings/#dotenv-env-support + """ + test_env_file = Path(__file__).parent / 'data' / 'test.env' + + # NOTE: _env_file overrides the default Config in the class + params = AgentParameters(_env_file=test_env_file) + + # assert params.dec.T_w == 0.2 + assert params.test == 't' From 187c7577e2c2b1b34af76213e93c4c773a3d160b Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 17:24:33 +0100 Subject: [PATCH 05/12] add nested params and fix bug --- abm/parameters/agent_parameters.py | 49 ++++++++++--------- abm/parameters/tests/data/test.env | 32 +++++++++++- abm/parameters/tests/test_agent_parameters.py | 8 ++- 3 files changed, 61 insertions(+), 28 deletions(-) diff --git a/abm/parameters/agent_parameters.py b/abm/parameters/agent_parameters.py index 8819025e..7d050226 100644 --- a/abm/parameters/agent_parameters.py +++ b/abm/parameters/agent_parameters.py @@ -3,28 +3,30 @@ class DecisionParameters(BaseModel): """Decision variables""" + # NOTE: error when trying to parse an uppercase variables from .env + # SEE: https://github.com/pydantic/pydantic/issues/3936#issuecomment-1152903692 # W - T_w: float - # Eps_w: float = 3 - # g_w: float = 0.085 - # B_w: float = 0 - # w_max: float = 1 - # - # # U - # T_u: float = 0.5 - # Eps_u: float = 3 - # g_u: float = 0.085 - # B_u: float = 0 - # u_max: float = 1 - # - # # Inhibition - # S_wu: float = 0.25 - # S_uw: float = 0.01 - # - # # Calculating Private Information - # Tau: int = 10 - # F_N: float = 2 - # F_R: float = 1 + t_w: float = 0.5 + eps_w: float = 3 + g_w: float = 0.085 + b_w: float = 0 + w_max: float = 1 + + # U + t_u: float = 0.5 + eps_u: float = 3 + g_u: float = 0.085 + b_u: float = 0 + u_max: float = 1 + + # Inhibition + s_wu: float = 0.25 + s_uw: float = 0.01 + + # Calculating Private Information + tau: int = 10 + f_n: float = 2 + f_r: float = 1 class MovementParameters(BaseModel): @@ -46,9 +48,8 @@ class MovementParameters(BaseModel): class AgentParameters(BaseSettings): - test: str - # movement_parameters: MovementParameters - # dec: DecisionParameters + agent_movement: MovementParameters + agent_decision: DecisionParameters class Config: env_nested_delimiter = '__' diff --git a/abm/parameters/tests/data/test.env b/abm/parameters/tests/data/test.env index b67ce4c1..84470de4 100644 --- a/abm/parameters/tests/data/test.env +++ b/abm/parameters/tests/data/test.env @@ -1,2 +1,30 @@ -DEC__T_W=0.2 -TEST=t \ No newline at end of file +# Decision process parameters +AGENT_DECISION__T_W=0.2 +AGENT_DECISION__EPS_W=2 +AGENT_DECISION__G_W=0.085 +AGENT_DECISION__B_W=0 +AGENT_DECISION__W_MAX=1 + +AGENT_DECISION__T_U=0.5 +AGENT_DECISION__EPS_U=3 +AGENT_DECISION__G_U=0.085 +AGENT_DECISION__B_U=0 +AGENT_DECISION__U_MAX=1 + +AGENT_DECISION__S_WU=0.25 +AGENT_DECISION__S_UW=0.01 + +AGENT_DECISION__TAU=10 +AGENT_DECISION__F_N=2 +AGENT_DECISION__F_R=1 + +# Movement parameters +# Exploration +AGENT_MOVEMENT__EXP_VEL_MIN=0.5 +AGENT_MOVEMENT__EXP_VEL_MAX=1 +AGENT_MOVEMENT__EXP_THETA_MIN=-0.3 +AGENT_MOVEMENT__EXP_THETA_MAX=0.3 + +# Relocation +AGENT_MOVEMENT__RELOC_DES_VEL=0.5 +AGENT_MOVEMENT__RELOC_THETA_MAX=0.5 diff --git a/abm/parameters/tests/test_agent_parameters.py b/abm/parameters/tests/test_agent_parameters.py index 914c2cfb..6300c0d7 100644 --- a/abm/parameters/tests/test_agent_parameters.py +++ b/abm/parameters/tests/test_agent_parameters.py @@ -13,5 +13,9 @@ def test_agent_parameters(): # NOTE: _env_file overrides the default Config in the class params = AgentParameters(_env_file=test_env_file) - # assert params.dec.T_w == 0.2 - assert params.test == 't' + # testing whether the nested parameters are parsed correctly + assert params.agent_decision.t_w == 0.2 + assert params.agent_decision.eps_w == 2.0 + assert params.agent_movement.exp_vel_min == 0.5 + assert params.agent_movement.reloc_des_vel == 0.5 + From 64cd0343a5e7c241875d7c75a6810e67dc6d4f35 Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 18:15:04 +0100 Subject: [PATCH 06/12] update playground params --- abm/parameters/playground_parameters.py | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/abm/parameters/playground_parameters.py b/abm/parameters/playground_parameters.py index 01b16f1c..950f843b 100644 --- a/abm/parameters/playground_parameters.py +++ b/abm/parameters/playground_parameters.py @@ -1,8 +1,9 @@ -from pydantic import BaseSettings +from pydantic import BaseSettings, BaseModel -class PlaygroundEnvironmentParameters(BaseSettings): +class PlaygroundEnvironmentParameters(BaseModel): """Environment variables""" + t: int = 1000 width: int = 500 height: int = 500 framerate: int = 30 # interactive @@ -11,10 +12,9 @@ class PlaygroundEnvironmentParameters(BaseSettings): use_zarr: bool = True save_csv_files: bool = False parallel: bool = False - allow_border_patch_overlap: bool = True -class PlaygroundUIParameters(BaseSettings): +class PlaygroundUIParameters(BaseModel): """Playground parameters""" with_visualization: bool = True show_vis_field: bool = False @@ -22,10 +22,11 @@ class PlaygroundUIParameters(BaseSettings): show_vision_range: bool = True -class PlaygroundAgentParameters(BaseSettings): +class PlaygroundAgentParameters(BaseModel): """Agent variables""" + n: int = 3 pooling_time: int = 0 - pooling_prob: int = 0 + pooling_prob: float = 0 agent_radius: int = 10 agent_consumption: int = 1 vision_range: int = 2000 @@ -36,7 +37,7 @@ class PlaygroundAgentParameters(BaseSettings): collide_agents: bool = False -class PlaygroundResourceParameters(BaseSettings): +class PlaygroundResourceParameters(BaseModel): """Resource variables""" min_resc_perpatch: int = 200 max_resc_perpatch: int = 201 @@ -45,13 +46,15 @@ class PlaygroundResourceParameters(BaseSettings): patch_radius: int = 15 # interactive regenerate_patches: bool = True teleport_exploit: bool = False + allow_border_patch_overlap: bool = True class PlaygroundParameters(BaseSettings): - environment_parameters: PlaygroundEnvironmentParameters = \ - PlaygroundEnvironmentParameters() - ui_parameters: PlaygroundUIParameters = PlaygroundUIParameters() - agent_parameters: PlaygroundAgentParameters = \ - PlaygroundAgentParameters() - resource_parameters: PlaygroundResourceParameters = \ - PlaygroundResourceParameters() + environment: PlaygroundEnvironmentParameters + ui: PlaygroundUIParameters + agent: PlaygroundAgentParameters + resource: PlaygroundResourceParameters + + class Config: + env_file = '.env' + env_nested_delimiter = '__' From dd45536c2a6e95957a52f27133ebabaa5c8714e6 Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 18:15:22 +0100 Subject: [PATCH 07/12] minor updates --- abm/parameters/agent_parameters.py | 1 + abm/parameters/tests/test_agent_parameters.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/abm/parameters/agent_parameters.py b/abm/parameters/agent_parameters.py index 7d050226..4f2e35b3 100644 --- a/abm/parameters/agent_parameters.py +++ b/abm/parameters/agent_parameters.py @@ -52,5 +52,6 @@ class AgentParameters(BaseSettings): agent_decision: DecisionParameters class Config: + env_file = '.env' env_nested_delimiter = '__' diff --git a/abm/parameters/tests/test_agent_parameters.py b/abm/parameters/tests/test_agent_parameters.py index 6300c0d7..1f0742b6 100644 --- a/abm/parameters/tests/test_agent_parameters.py +++ b/abm/parameters/tests/test_agent_parameters.py @@ -18,4 +18,3 @@ def test_agent_parameters(): assert params.agent_decision.eps_w == 2.0 assert params.agent_movement.exp_vel_min == 0.5 assert params.agent_movement.reloc_des_vel == 0.5 - From 36dde521ab6393b3ca3d900dadc650641f592fc9 Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 18:15:36 +0100 Subject: [PATCH 08/12] test simulation initialization --- abm/simulation/tests/__init__.py | 0 abm/simulation/tests/data/test.env | 67 +++++++++++++++++++++++++ abm/simulation/tests/test_simulation.py | 30 +++++++++++ 3 files changed, 97 insertions(+) create mode 100644 abm/simulation/tests/__init__.py create mode 100644 abm/simulation/tests/data/test.env create mode 100644 abm/simulation/tests/test_simulation.py diff --git a/abm/simulation/tests/__init__.py b/abm/simulation/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/abm/simulation/tests/data/test.env b/abm/simulation/tests/data/test.env new file mode 100644 index 00000000..6d9e03a6 --- /dev/null +++ b/abm/simulation/tests/data/test.env @@ -0,0 +1,67 @@ +UI__WITH_VISUALIZATION=1 +UI__SHOW_VISUAL_FIELDS=0 +UI__SHOW_VISUAL_FIELDS_RETURN=1 +UI__SHOW_VISION_RANGE=1 + +# Simulation time +ENVIRONMENT__T=1000 +ENVIRONMENT__WIDTH=600 +ENVIRONMENT__HEIGHT=600 +ENVIRONMENT__FRAMERATE=25 +ENVIRONMENT__WINDOW_PAD=30 +ENVIRONMENT__USE_RAM_LOGGING=1 +ENVIRONMENT__USE_IFDB_LOGGING=0 +ENVIRONMENT__USE_ZARR=1 +ENVIRONMENT__SAVE_CSV_FILES=0 + +RESOURCE__PATH_RADIUS=45 +RESOURCE__MIN_RES_PERPATCH=400 +RESOURCE__MAX_RES_PERPATCH=450 +RESOURCE__REGENERATE_PATCHES=1 +RESOURCE__ALLOW_BORDER_PATCH_OVERLAP=1 +RESOURCE__TELEPORT_EXPLOIT=1 +RESOURCE__MIN_RESC_QUALITY=0.05 +RESOURCE__MAX_RESC_QUALITY=0.3 + +AGENT__N=3 +AGENT__POOLING_TIME=0 +AGENT__POOLING_PROB=0.05 +AGENT__RADIUS_AGENT=10 +AGENT__AGENT_CONSUMPTION=1 +AGENT__VISION_RANGE=200 +AGENT__AGENT_FOV=0.45 +AGENT__VISUAL_EXCLUSION=1 +AGENT__GHOST_MODE=1 +AGENT__PATCHWISE_EXCLUSION=1 +AGENT__COLLIDE_AGENTS=0 + +# Decision process parameters +AGENT_DECISION__T_W=0.2 +AGENT_DECISION__EPS_W=2 +AGENT_DECISION__G_W=0.085 +AGENT_DECISION__B_W=0 +AGENT_DECISION__W_MAX=1 + +AGENT_DECISION__T_U=0.5 +AGENT_DECISION__EPS_U=3 +AGENT_DECISION__G_U=0.085 +AGENT_DECISION__B_U=0 +AGENT_DECISION__U_MAX=1 + +AGENT_DECISION__S_WU=0.25 +AGENT_DECISION__S_UW=0.01 + +AGENT_DECISION__TAU=10 +AGENT_DECISION__F_N=2 +AGENT_DECISION__F_R=1 + +# Movement parameters +# Exploration +AGENT_MOVEMENT__EXP_VEL_MIN=0.5 +AGENT_MOVEMENT__EXP_VEL_MAX=1 +AGENT_MOVEMENT__EXP_THETA_MIN=-0.3 +AGENT_MOVEMENT__EXP_THETA_MAX=0.3 + +# Relocation +AGENT_MOVEMENT__RELOC_DES_VEL=0.5 +AGENT_MOVEMENT__RELOC_THETA_MAX=0.5 diff --git a/abm/simulation/tests/test_simulation.py b/abm/simulation/tests/test_simulation.py new file mode 100644 index 00000000..2ba33ce5 --- /dev/null +++ b/abm/simulation/tests/test_simulation.py @@ -0,0 +1,30 @@ +from pathlib import Path + +from abm.parameters.agent_parameters import AgentParameters +from abm.parameters.playground_parameters import PlaygroundParameters +from abm.simulation.sims import Simulation + + +def test_init_simulation(): + """ + Testing simulation + """ + test_env_file = Path(__file__).parent / 'data' / 'test.env' + + agent_params = AgentParameters(_env_file=test_env_file) + playground_params = PlaygroundParameters(_env_file=test_env_file) + + # merge all parameters into one dict + kwargs = { + # **agent_params.agent_movement.dict(), + # **agent_params.agent_decision.dict(), + **playground_params.environment.dict(), + **playground_params.ui.dict(), + **playground_params.agent.dict(), + **playground_params.resource.dict() + } + + n = kwargs.pop('n') + t = kwargs.pop('t') + + sim = Simulation(n, t, **kwargs) From f4cee6ed07eb445eb47648d91f4fc39c2746be81 Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 18:16:56 +0100 Subject: [PATCH 09/12] clean up the simulation test --- abm/simulation/tests/test_simulation.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/abm/simulation/tests/test_simulation.py b/abm/simulation/tests/test_simulation.py index 2ba33ce5..7faccb06 100644 --- a/abm/simulation/tests/test_simulation.py +++ b/abm/simulation/tests/test_simulation.py @@ -1,6 +1,5 @@ from pathlib import Path -from abm.parameters.agent_parameters import AgentParameters from abm.parameters.playground_parameters import PlaygroundParameters from abm.simulation.sims import Simulation @@ -11,13 +10,10 @@ def test_init_simulation(): """ test_env_file = Path(__file__).parent / 'data' / 'test.env' - agent_params = AgentParameters(_env_file=test_env_file) playground_params = PlaygroundParameters(_env_file=test_env_file) # merge all parameters into one dict kwargs = { - # **agent_params.agent_movement.dict(), - # **agent_params.agent_decision.dict(), **playground_params.environment.dict(), **playground_params.ui.dict(), **playground_params.agent.dict(), From cb78b947d0523bffc1d5be8c4f1cfda71029b02b Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 18:31:08 +0100 Subject: [PATCH 10/12] run tests without visualization (breaks github workflow) --- abm/simulation/tests/data/test.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abm/simulation/tests/data/test.env b/abm/simulation/tests/data/test.env index 6d9e03a6..385b97c3 100644 --- a/abm/simulation/tests/data/test.env +++ b/abm/simulation/tests/data/test.env @@ -1,4 +1,4 @@ -UI__WITH_VISUALIZATION=1 +UI__WITH_VISUALIZATION=0 UI__SHOW_VISUAL_FIELDS=0 UI__SHOW_VISUAL_FIELDS_RETURN=1 UI__SHOW_VISION_RANGE=1 From 7d3c0a89555c2815b03d37de8a83e4e12d8a3a0d Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 18:48:07 +0100 Subject: [PATCH 11/12] fix headless mode for testing bug --- abm/simulation/tests/test_simulation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/abm/simulation/tests/test_simulation.py b/abm/simulation/tests/test_simulation.py index 7faccb06..74a9809b 100644 --- a/abm/simulation/tests/test_simulation.py +++ b/abm/simulation/tests/test_simulation.py @@ -1,5 +1,7 @@ from pathlib import Path +from xvfbwrapper import Xvfb + from abm.parameters.playground_parameters import PlaygroundParameters from abm.simulation.sims import Simulation @@ -23,4 +25,6 @@ def test_init_simulation(): n = kwargs.pop('n') t = kwargs.pop('t') - sim = Simulation(n, t, **kwargs) + with Xvfb(width=playground_params.environment.width, + height=playground_params.environment.height) as _: + sim = Simulation(n, t, **kwargs) From a0ba2c745f6ea621c4fed5c3e0e5c2406cdef273 Mon Sep 17 00:00:00 2001 From: vagechirkov Date: Fri, 18 Nov 2022 18:56:41 +0100 Subject: [PATCH 12/12] fix test init simulation --- abm/simulation/tests/test_simulation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/abm/simulation/tests/test_simulation.py b/abm/simulation/tests/test_simulation.py index 74a9809b..3639c88e 100644 --- a/abm/simulation/tests/test_simulation.py +++ b/abm/simulation/tests/test_simulation.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from xvfbwrapper import Xvfb @@ -24,7 +25,7 @@ def test_init_simulation(): n = kwargs.pop('n') t = kwargs.pop('t') - + os.environ['SDL_VIDEODRIVER'] = 'dummy' with Xvfb(width=playground_params.environment.width, height=playground_params.environment.height) as _: sim = Simulation(n, t, **kwargs)