Skip to content

Commit

Permalink
#3 changing "world" to "system"
Browse files Browse the repository at this point in the history
  • Loading branch information
jschalk committed Aug 29, 2023
1 parent 39c50c8 commit 23e380d
Show file tree
Hide file tree
Showing 41 changed files with 720 additions and 657 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ dmypy.json
cython_debug/

# automatica_lly generated testing environments on each run
src/world/examples/worlds/ex3/
src/world/examples/worlds/ex4/
src/world/examples/worlds/ex5/
src/world/examples/worlds/ex6/
src/world/examples/worlds/river_env/
src/world/test_world/sql_worksheet01.sql
src/system/examples/systems/ex3/
src/system/examples/systems/ex4/
src/system/examples/systems/ex5/
src/system/examples/systems/ex6/
src/system/examples/systems/river_env/
src/system/test_system/sql_worksheet01.sql
src/agent/examples/js_agent.json
4 changes: 2 additions & 2 deletions Edit5Issue.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# command to for converting ui form to python file: pyuic5 ui\World5IssueUI.ui -o ui\World5IssueUI.py
# command to for converting ui form to python file: pyuic5 ui\System5IssueUI.ui -o ui\System5IssueUI.py
import sys
from ui.World5IssueUI import Ui_Form
from ui.System5IssueUI import Ui_Form
from PyQt5 import QtWidgets as qtw
from PyQt5 import QtCore as qtc
from src.pyqt5_tools.pyqt_func import lw_diplay
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ screenshots and explanatory text.
base attributes vs required attributess

<!-- TODO: Add explanations -->
WorldUnit objects
SystemUnit objects

WorldUnit PersonUnit objects
SystemUnit PersonUnit objects

WorldUnit PersonUnit AgentLink objects
SystemUnit PersonUnit AgentLink objects

WorldUnit Bank objects
SystemUnit Bank objects

<!-- TODO: Add explanations -->
AgentUnit objects
Expand Down
138 changes: 71 additions & 67 deletions main_world.py → main_system.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# # command to for converting ui form to python file: pyuic5 ui\WorldMainUI.ui -o ui\WorldMainUI.py
from ui.WorldMainUI import Ui_MainWindow
# # command to for converting ui form to python file: pyuic5 ui\SystemMainUI.ui -o ui\SystemMainUI.py
from ui.SystemMainUI import Ui_MainWindow
from Edit5Issue import Edit5Issue
from EditMain import EditMainView
from PyQt5 import QtCore as qtc
Expand All @@ -10,16 +10,16 @@
QApplication,
QMainWindow,
)
from src.world.world import WorldUnit
from src.world.examples.env_tools import (
create_example_worlds_list,
from src.system.system import SystemUnit
from src.system.examples.env_tools import (
create_example_systems_list,
setup_test_example_environment,
create_example_world,
delete_dir_example_world,
rename_example_world,
get_test_worlds_dir,
create_example_system,
delete_dir_example_system,
rename_example_system,
get_test_systems_dir,
)
from src.world.agentlink import get_agentlink_types, agentlink_shop
from src.system.agentlink import get_agentlink_types, agentlink_shop
from src.agent.x_func import (
open_file as x_func_open_file,
dir_files as x_func_dir_files,
Expand Down Expand Up @@ -76,10 +76,10 @@ def __init__(self):
self.setupUi(self)
# signals for opening windows
self.refresh_all_button.clicked.connect(self.refresh_all)
self.world_insert_button.clicked.connect(self.world_insert)
self.world_load_button.clicked.connect(self.world_load_from_file)
self.world_update_button.clicked.connect(self.world_update_name)
self.world_delete_button.clicked.connect(self.world_delete)
self.system_insert_button.clicked.connect(self.system_insert)
self.system_load_button.clicked.connect(self.system_load_from_file)
self.system_update_button.clicked.connect(self.system_update_name)
self.system_delete_button.clicked.connect(self.system_delete)
self.agent_insert_button.clicked.connect(self.agent_insert)
self.agent_update_button.clicked.connect(self.agent_update_name)
self.agent_delete_button.clicked.connect(self.agent_delete)
Expand Down Expand Up @@ -110,15 +110,15 @@ def __init__(self):
self.agentlinks_table.itemClicked.connect(self.agentlinks_table_select)
self.five_issue_button.clicked.connect(self.open_edit5issue)

self.world_x = None
self.system_x = None
self.person_x = None
self.ignore_agent_x = None
setup_test_example_environment()
first_env = "ex5"
self.world_x = WorldUnit(name=first_env, worlds_dir=get_test_worlds_dir())
self.refresh_world()
self.world_name_combo_refresh()
self.world_name_combo.setCurrentText(first_env)
self.system_x = SystemUnit(name=first_env, systems_dir=get_test_systems_dir())
self.refresh_system()
self.system_name_combo_refresh()
self.system_name_combo.setCurrentText(first_env)
self._person_load(person_name="ernie")

def save_starting_digest(self):
Expand All @@ -127,8 +127,8 @@ def save_starting_digest(self):
self.refresh_person()

def reload_all_src_agents(self):
if self.world_x != None:
self.world_x.reload_all_persons_src_agentunits()
if self.system_x != None:
self.system_x.reload_all_persons_src_agentunits()

def set_public_and_reload_srcs(self):
self.set_dest_agent_to_public_agent()
Expand All @@ -137,14 +137,16 @@ def set_public_and_reload_srcs(self):
def set_dest_agent_to_public_agent(self):
if self.person_x != None:
self.person_x.set_dest_agent_to_public_agent()
self.refresh_world()
self.refresh_system()

def world_load_from_file(self):
world_selected = self.world_name_combo.currentText()
self.world_x = WorldUnit(name=world_selected, worlds_dir=get_test_worlds_dir())
self.world_x.create_dirs_if_null(in_memory_bank=False)
self.world_name.setText(world_selected)
self.refresh_world()
def system_load_from_file(self):
system_selected = self.system_name_combo.currentText()
self.system_x = SystemUnit(
name=system_selected, systems_dir=get_test_systems_dir()
)
self.system_x.create_dirs_if_null(in_memory_bank=False)
self.system_name.setText(system_selected)
self.refresh_system()

def agents_table_select(self):
self.agent_name.setText(
Expand All @@ -166,8 +168,8 @@ def persons_table_select(self):
self._person_load(person_name=person_x_name)

def _person_load(self, person_name: str):
self.world_x.load_personunit(name=person_name)
self.person_x = self.world_x._personunits.get(person_name)
self.system_x.load_personunit(name=person_name)
self.person_x = self.system_x._personunits.get(person_name)
self.person_name.setText(self.person_x.name)
self.refresh_person()

Expand All @@ -186,14 +188,14 @@ def ignores_table_select(self):
ignore_agent_desc = self.ignores_table.item(
self.ignores_table.currentRow(), 0
).text()
# self.ignore_agent_x = self.world_x.get_agent_from_agents_dir(
self.ignore_agent_x = self.world_x.get_agent_from_ignores_dir(
# self.ignore_agent_x = self.system_x.get_agent_from_agents_dir(
self.ignore_agent_x = self.system_x.get_agent_from_ignores_dir(
person_name=self.person_x.name, _desc=ignore_agent_desc
)
self.edit_agent = self.ignore_agent_x

def ignore_agent_file_update(self):
self.world_x.set_ignore_agent_file(
self.system_x.set_ignore_agent_file(
person_name=self.person_x.name, agent_obj=self.ignore_agent_x
)
self.refresh_person()
Expand All @@ -206,47 +208,49 @@ def show_digests_table(self):
self.ignores_table.setHidden(True)
self.digests_table.setHidden(False)

def world_insert(self):
create_example_world(world_name=self.world_name.text())
self.world_name_combo_refresh()
def system_insert(self):
create_example_system(system_name=self.system_name.text())
self.system_name_combo_refresh()

def world_update_name(self):
rename_example_world(world_obj=self.world_x, new_name=self.world_name.text())
self.world_name_combo_refresh()
def system_update_name(self):
rename_example_system(
system_obj=self.system_x, new_name=self.system_name.text()
)
self.system_name_combo_refresh()

def world_delete(self):
delete_dir_example_world(world_obj=self.world_x)
self.world_x = None
self.world_name_combo_refresh()
self.refresh_world()
def system_delete(self):
delete_dir_example_system(system_obj=self.system_x)
self.system_x = None
self.system_name_combo_refresh()
self.refresh_system()

def agent_insert(self):
self.world_x.save_agentunit_obj_to_agents_dir(
self.system_x.save_agentunit_obj_to_agents_dir(
agent_x=AgentUnit(_desc=self.agent_name.text())
)
self.refresh_world()
self.refresh_system()

def agent_update_name(self):
currently_selected = self.agents_table.item(
self.agents_table.currentRow(), 0
).text()
typed_in = self.agent_name.text()
if currently_selected != typed_in:
self.world_x.rename_agent_in_agents_dir(
self.system_x.rename_agent_in_agents_dir(
old_desc=currently_selected, new_desc=typed_in
)
self.refresh_world()
self.refresh_system()

def agent_delete(self):
self.world_x.del_agentunit_from_agents_dir(
self.system_x.del_agentunit_from_agents_dir(
agent_x_desc=self.agents_table.item(
self.agents_table.currentRow(), 0
).text()
)
self.refresh_world()
self.refresh_system()

def person_insert(self):
self.world_x.create_new_personunit(person_name=self.person_name.text())
self.system_x.create_new_personunit(person_name=self.person_name.text())
self.refresh_persons()

def person_update_name(self):
Expand All @@ -255,13 +259,13 @@ def person_update_name(self):
).text()
typed_in = self.person_name.text()
if currently_selected != typed_in:
self.world_x.rename_personunit(
self.system_x.rename_personunit(
old_desc=currently_selected, new_desc=typed_in
)
self.refresh_persons()

def person_delete(self):
self.world_x.del_person_dir(
self.system_x.del_person_dir(
person_name=self.persons_table.item(
self.persons_table.currentRow(), 0
).text()
Expand All @@ -280,7 +284,7 @@ def agentlink_insert(self):
link_type=self.link_type_combo.currentText(),
weight=self.agentlink_weight.text(),
)
self.world_x.save_person_file(person_name=self.person_x.name)
self.system_x.save_person_file(person_name=self.person_x.name)
self.refresh_person()

def agentlink_update(self):
Expand All @@ -291,34 +295,34 @@ def agentlink_update(self):
weight=self.agentlink_weight.text(),
)

self.world_x.update_agentlink(
self.system_x.update_agentlink(
person_name=person_name_x,
agentlink=new_agentlink,
)
self.world_x.save_person_file(person_name=person_name_x)
self.system_x.save_person_file(person_name=person_name_x)
self.refresh_person()

def agentlink_delete(self):
person_name_x = self.person_x.name
self.world_x.del_agentlink(
self.system_x.del_agentlink(
person_name=person_name_x, agentunit_desc=self.agentlink_name.text()
)
self.world_x.save_person_file(person_name=person_name_x)
self.system_x.save_person_file(person_name=person_name_x)
self.refresh_person()

def get_agent_desc_list(self):
agents_desc_list = []
if self.world_x != None:
if self.system_x != None:
agents_desc_list.extend(
[agent._desc] for agent in self.world_x.get_agents_dir_list_of_obj()
[agent._desc] for agent in self.system_x.get_agents_dir_list_of_obj()
)
return agents_desc_list

def get_person_desc_list(self):
persons_desc_list = []
if self.world_x != None:
if self.system_x != None:
persons_desc_list.extend(
[person_dir] for person_dir in self.world_x.get_person_dir_paths_list()
[person_dir] for person_dir in self.system_x.get_person_dir_paths_list()
)
return persons_desc_list

Expand Down Expand Up @@ -440,7 +444,7 @@ def get_p_agenda_list(self):
return x_list

def refresh_all(self):
self.refresh_world()
self.refresh_system()

def _sub_refresh_persons_table(self):
self.refresh_x(
Expand Down Expand Up @@ -557,9 +561,9 @@ def _sub_refresh_p_agenda_table(self):
column_width=[50, 200, 300],
)

def world_name_combo_refresh(self):
self.world_name_combo.clear()
self.world_name_combo.addItems(create_example_worlds_list())
def system_name_combo_refresh(self):
self.system_name_combo.clear()
self.system_name_combo.addItems(create_example_systems_list())

def refresh_persons(self):
self.person_x = None
Expand All @@ -581,7 +585,7 @@ def refresh_person(self):
self._sub_refresh_p_acptfacts_table()
self._sub_refresh_p_agenda_table()

def refresh_world(self):
def refresh_system(self):
self.refresh_x(self.agents_table, ["Agents Table"], self.get_agent_desc_list())
self.refresh_persons()

Expand Down
2 changes: 1 addition & 1 deletion src/agent/examples/example_agent1.json

Large diffs are not rendered by default.

Loading

0 comments on commit 23e380d

Please sign in to comment.