Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sugarscape Chapter 3- Draft Pull Request #106

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

apranav22
Copy link

  • creating the base code for chapter 3 of sugarscape, attempt to keep as a superset of chapter 2. Ideally, once this example is in a releasable state I would like to remove chapter 2's dedicated example.

TODO:

  • Refactor the example code into AgentSets.

Current Issues:

  • Struggling with agent reporters, I'd like to access agents' age data from agents.py using the data collector datacollector in models.py to visualise a bar chart. However, the bar chart does not show up.

  • x----

  • On branch sugarscape Changes to be committed:
    new file: examples/sugarscape_scc/README.md
    new file: examples/sugarscape_scc/sugarscape_scc/init.py
    new file: examples/sugarscape_scc/sugarscape_scc/resources/ant.png
    new file: examples/sugarscape_scc/sugarscape_scc/sugar-map.txt
    Changes not staged for commit:
    modified: examples/sugarscape_cg/sugarscape_cg/model.py
    Untracked files:
    examples/sugarscape_scc/sugarscape_scc/agents.py
    examples/sugarscape_scc/sugarscape_scc/model.py

  • modified: examples/sugarscape_cg/sugarscape_cg/model.py

  • Changes to be committed:
    new file: examples/sugarscape_scc/sugarscape_scc/model.py
    Untracked files:
    examples/sugarscape_scc/sugarscape_scc/agents.py

  • new file: examples/sugarscape_scc/sugarscape_scc/agents.py

  • modified: examples/sugarscape_scc/README.md

  • modified: examples/sugarscape_cg/sugarscape_cg/model.pymodified: examples/sugarscape_scc/README.md

* creating the base code for chapter 3 of sugarscape, attempt to keep as a superset of chapter 2

* On branch sugarscape
Changes to be committed:
	new file:   examples/sugarscape_scc/README.md
	new file:   examples/sugarscape_scc/sugarscape_scc/__init__.py
	new file:   examples/sugarscape_scc/sugarscape_scc/resources/ant.png
	new file:   examples/sugarscape_scc/sugarscape_scc/sugar-map.txt
Changes not staged for commit:
	modified:   examples/sugarscape_cg/sugarscape_cg/model.py
Untracked files:
	examples/sugarscape_scc/sugarscape_scc/agents.py
	examples/sugarscape_scc/sugarscape_scc/model.py

* modified:   examples/sugarscape_cg/sugarscape_cg/model.py

* Changes to be committed:
	new file:   examples/sugarscape_scc/sugarscape_scc/model.py
Untracked files:
	examples/sugarscape_scc/sugarscape_scc/agents.py

* new file:   examples/sugarscape_scc/sugarscape_scc/agents.py

* modified:   examples/sugarscape_scc/README.md

* modified:   examples/sugarscape_cg/sugarscape_cg/model.pymodified:   examples/sugarscape_scc/README.md
@apranav22 apranav22 changed the title Sugarscape Chapter 3- Draft Pull Request (#1) Sugarscape Chapter 3- Draft Pull Request Feb 27, 2024
* creating the base code for chapter 3 of sugarscape, attempt to keep as a superset of chapter 2

* On branch sugarscape
Changes to be committed:
	new file:   examples/sugarscape_scc/README.md
	new file:   examples/sugarscape_scc/sugarscape_scc/__init__.py
	new file:   examples/sugarscape_scc/sugarscape_scc/resources/ant.png
	new file:   examples/sugarscape_scc/sugarscape_scc/sugar-map.txt
Changes not staged for commit:
	modified:   examples/sugarscape_cg/sugarscape_cg/model.py
Untracked files:
	examples/sugarscape_scc/sugarscape_scc/agents.py
	examples/sugarscape_scc/sugarscape_scc/model.py

* modified:   examples/sugarscape_cg/sugarscape_cg/model.py

* Changes to be committed:
	new file:   examples/sugarscape_scc/sugarscape_scc/model.py
Untracked files:
	examples/sugarscape_scc/sugarscape_scc/agents.py

* new file:   examples/sugarscape_scc/sugarscape_scc/agents.py

* modified:   examples/sugarscape_scc/README.md

* modified:   examples/sugarscape_cg/sugarscape_cg/model.pymodified:   examples/sugarscape_scc/README.md

* modified:   examples/sugarscape_scc/sugarscape_scc/model.py

* Update agents.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@rht
Copy link
Contributor

rht commented Feb 28, 2024

@apranav22 how much smaller would the code be if it were to inherit from the existing sugarscape_cg classes? Let me know, and if it is sufficiently small, we may publish sugarscape_cg to be importable from mesa_models. Only 4 models are published for now: https://github.com/projectmesa/mesa-examples/blob/main/setup.cfg.

@apranav22
Copy link
Author

@rht I think it would reduce redundant code by an order of magnitude actually. Shall I rewrite the code to inherit from the existing files?

I also wanted to refactor a little bit keeping AgentSets in mind. Is writing examples with experimental features encourages?

rht added a commit to rht/mesa-examples that referenced this pull request Feb 29, 2024
This is needed so that
projectmesa#106 can inherit from
sugarscape_cg, to reduce code duplication.
@rht
Copy link
Contributor

rht commented Feb 29, 2024

I published the sugarscape_cg in #108. Once merged, you can do from mesa_models.sugarscape_cg.model import SugarscapeCg and from mesa_models.sugarscape_cg.agents import SsAgent.

Shall I rewrite the code to inherit from the existing files?

Yes, sounds good to me.

I also wanted to refactor a little bit keeping AgentSets in mind. Is writing examples with experimental features encourages?

I suppose it is fine for new examples. I have only used AgentSet for the experimental examples. What do you think, @projectmesa/maintainers @quaquel ?

rht added a commit that referenced this pull request Feb 29, 2024
This is needed so that
#106 can inherit from
sugarscape_cg, to reduce code duplication.
@rht
Copy link
Contributor

rht commented Feb 29, 2024

@apranav22 #108 has been merged.

@EwoutH
Copy link
Member

EwoutH commented Mar 28, 2024

@apranav22 hey! Would you like to finish this PR? Is there anything we can do to help?

@apranav22
Copy link
Author

@apranav22 hey! Would you like to finish this PR? Is there anything we can do to help?

Hi! I've been meaning to get to it but I've been swamped of late. I will work on it right now. Sorry for the slack :(

@apranav22
Copy link
Author

There's a problem. Some of the relative file paths get mangled when I try to inherit from sugarscape_cg. For example, the function that generates the map using the relative file path no longer works.

apranav22 and others added 3 commits March 29, 2024 20:46
tried to inherit from sugarscape_cg: ran into problems immediately :(.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants