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

state_table in progmem vs. trigger cycling 8 times #90

Open
rehevkor5 opened this issue Jan 7, 2023 · 0 comments
Open

state_table in progmem vs. trigger cycling 8 times #90

rehevkor5 opened this issue Jan 7, 2023 · 0 comments

Comments

@rehevkor5
Copy link

I can only think of two ways to introduce some non-determinism (eg. branching on random number) without also introducing a large number of extra event types. The first way is to push events to a randomly selected connector or connector slot (decipherable by reading source code). The second way, which I'll discuss further, is to mutate the state_table at runtime.

However, the state_table must be stored in progmem, and as such my understanding is that it's read-only. To make it writable by not storing it in progme4m, that would require redefining the read_state( addr ) macro globally. Sadly, it cannot be redefined to call a method on the Machine itself (which could have instance- or class-specific logic), without breaking Atm_step.cpp, which also calls read_state( from outside Machine. So, unfortunately it doesn't seem possible to have some Machine's state_table in progmem, and some on the heap, you have to pick one or the other globally.

I also see that trigger(int) will call cycle() eight times regardless of whether there is a valid transition for that event or not. It seems like the only reason to do that would be in the case of a mutable state_table which event()/loop() code can mutate at runtime? In that case, it seems like that should not be the default behavior since read_state will always return the same output no matter how many times cycle is called?

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

No branches or pull requests

1 participant