
Solving State Explosion with Petri-Nets and Vector Clocks - orksliver
https://github.com/bitwrap/bitwrap-io/blob/master/whitepaper.md
======
teleclimber
> The Problem: [https://barrgroup.com/Embedded-Systems/How-To/State-
> Machines...](https://barrgroup.com/Embedded-Systems/How-To/State-Machines-
> Event-Driven-Systems)

The article linked spends a lot of time looking at an event-based calculator
in VBScript that evidently has a lot of bugs. This is used as a justification
for doing what they do (whatever that is? I don't really get it).

My problem with this is the calculator program is very poorly written. One
could probably get rid of most of the bugs by using a "single source of truth"
state object that includes all state data necessary for all events to act
correctly.

The calculator program is buggy because the programmer is apparently not
thinking holistically, and is patching bugs as they are found by adding
another little state variable here and there. The result is just what you'd
expect.

But this is largely a solved problem. The React folks developed Flux[0] to get
away from these kinds of situations.

I guess my point is I can't be bothered to go study what a bitwrap is all
about given the problem it solves is moot when using good design techniques.

But if someone can explain the problem better, I'm all ears.

[0] [https://facebook.github.io/flux/](https://facebook.github.io/flux/)

~~~
orksliver
> But if someone can explain the problem better, I'm all ears.

Assuming you mean it...

Here's a youtube video about the benefits and attributes of event-sourcing.
[https://www.youtube.com/watch?v=8JKjvY4etTY](https://www.youtube.com/watch?v=8JKjvY4etTY)

Though the demo project is presented in the browser, I'm trying to demonstrate
that I can model the game of Tic-Tac-Toe using a much _smaller_ and
_comprehensible_ (I hope) graph.

Additionally - because these are mathematical graphs I'm speaking of - it
means the 'program' that the graph represents - can be expressed as _pure
math_ ( which is nifty to say the least )

A classic DFA would have to represent all the permutations of the board like
so: [https://upload.wikimedia.org/wikipedia/commons/1/1f/Tic-
tac-...](https://upload.wikimedia.org/wikipedia/commons/1/1f/Tic-tac-toe-full-
game-tree-x-rational.jpg)

~~~
teleclimber
Ah, seeing the tic-tac-toe graph and comparing to yours gives a much better
idea what you're trying to do. Interesting! Thanks.

------
orksliver
[https://www.reddit.com/r/compsci/comments/5yktdo/tictactoe_s...](https://www.reddit.com/r/compsci/comments/5yktdo/tictactoe_state_machine_petrinet/)
<\- Related post focusing only on the TicTacToe State machine.

~~~
orksliver
"Cool! I'm doing DFAs with my fifth graders right now and I'm definitely
showing them this." :)

------
stabbles
Never heard of petri-nets before, but familiar with ES. Do you have some good
references as an intro to petri-nets?

~~~
orksliver
I'm afraid I've learned about them mostly by tinkering - the tool I use is:
[https://github.com/sarahtattersall/PIPE](https://github.com/sarahtattersall/PIPE)

I believe "Dining Philosophers" is the usual problem used to introduce the
need and concept of Petri-Nets - googled for some examples I found:

[http://www.cs.cmu.edu/afs/cs/academic/class/15671-f97/www/le...](http://www.cs.cmu.edu/afs/cs/academic/class/15671-f97/www/lectures/18-PetriNets2/ppframe.htm)

Also here's the link to the PNML source used for tic-tac-toe:
[https://github.com/bitwrap/bitwrap-
io/blob/master/bitwrap_io...](https://github.com/bitwrap/bitwrap-
io/blob/master/bitwrap_io/pnml/octothorpe.xml)

