Conversation
Move activation control fully into the model by removing the activation_order check from PDAgent.step(). Use method chaining and lambdas to express the three activation regimes clearly.
quaquel
approved these changes
Feb 19, 2026
Member
quaquel
left a comment
There was a problem hiding this comment.
This looks fine to me.
I don't see a need to change do. It is a very particular use case in this example so I am fine with the lambda.
At some point, I want to update this example drawing on my version of this model that I use in teaching which has more strategies and adds evolution.
|
Performance benchmarks:
|
EwoutH
added a commit
that referenced
this pull request
Mar 15, 2026
Move activation control fully into the model by removing the activation_order check from PDAgent.step(). Use method chaining and lambdas to express the three activation regimes clearly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleans up the pd_grid example by separating agent logic from activation control.
Motive
PDAgent.step()contained a check againstmodel.activation_orderto decide whether to callself.advance(). This couples the agent to the model's activation regime. Agents shouldn't need to know how they're being activated.Implementation
if activation_order != "Simultaneous": self.advance()check fromPDAgent.step(), sostep()only computesnext_move.PdGrid.step()to use method chaining and lambdas for clear activation semantics:do(lambda a: (a.step(), a.advance()))shuffle_do(lambda a: (a.step(), a.advance()))do("step").do("advance")Additional Notes
increment_scorestill checksactivation_orderto decide whether to readmoveornext_movefrom neighbors. This is inherent to the simultaneous game semantics, not an activation concern.If we find this too ugly:
We might update do and shuffle_do to allow taking multiple method names or callables: