A Simple Discrete-Event Simulation: Part 3

Here is an entity object that knows how to be created and activated from external calls. It updates itself and puts itself back into the future events queue is appropriate. This is in keeping with my original concept of how an entity would work. The key, of course, is to keep rewriting and simplifying this thing until more and more of the mechanics are hidden from the coder. Languages like SLX do this implicitly, but if we’re building a framework from scratch, given the limitations imposed by JavaScript, there’s only so far we’re going to be able to go with that. Still, it’ll be fun to see how far we get.

In the meantime the forms here mean I’ll have to streamline some of the existing code. Since the state information is all kept within the entity itself it no longer has to be kept with the future events queue elements (since those elements contain a reference to the entity), so those data structures and calls will be pruned.

I’ll make this all run tomorrow, but here’s the rough code for now:

This entry was posted in Simulation and tagged , . Bookmark the permalink.

Leave a Reply