{"id":18497579,"url":"https://github.com/csb6/event-simulator","last_synced_at":"2025-10-26T19:02:19.258Z","repository":{"id":115656208,"uuid":"187140816","full_name":"csb6/event-simulator","owner":"csb6","description":"Simulation module using Markov chains","archived":false,"fork":false,"pushed_at":"2019-05-17T20:04:46.000Z","size":37,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T19:44:31.840Z","etag":null,"topics":["finite-state-machine","markov-chain","simulation"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csb6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-17T03:32:50.000Z","updated_at":"2022-03-17T21:53:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2a9f4fd-72bd-4005-b2b2-7424d320c7a0","html_url":"https://github.com/csb6/event-simulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fevent-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fevent-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fevent-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csb6%2Fevent-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csb6","download_url":"https://codeload.github.com/csb6/event-simulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247949659,"owners_count":21023364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finite-state-machine","markov-chain","simulation"],"created_at":"2024-11-06T13:35:00.875Z","updated_at":"2025-10-26T19:02:19.153Z","avatar_url":"https://github.com/csb6.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event Simulator\n\nA module that allows the creation of a Markov chain-based simulations. It is designed to\nmake simulations where transitions between different states depend on weighted probabilities.\n\n## Key Ideas\n\n- **States** (which I'll also call **events**) are specified in a JSON file with a name, description, and list of **suffixes** (events that can happen afterwards).\n\n- Each suffix is also labelled with a probability. For example, the event \"walk_forward\" might have two suffixes \"walk_backward\" and \"walk_sideways\", each labelled with a 50% probability of occurring.\n\n- After importing the module, define a `start()`, `update()`, and `end()` function with custom code that is loaded when the sim runs. These functions must be packaged together into an object called a `SimKit`.\n\n- `SimKit`s store all of the custom code for a simulation. For example, to simulate a person's life, you would create a `SimKit` with `start()`, `update()`, and `end()` functions that track the state of the person throughout the simulation.\n\n- Any code in `start()` is run before any events in the sim occur; code in `update()` is called after each event occurs, and `end()` is called after the last event in the sim occurs.\n\n- All three of these functions have access to a `data` dictionary. All three functions can freely add, read, and remove key/value pairs to this data structure.\n\n- Typically, `start()` will initialize some key/value pairs to empty values or to zero, `update()` alters or adds to these values based on the type of event that occurs, and `end()` prints out a summary of the contents of the `data` dictionary. All of this code depends on what you want to simulate.\n\n- In order to run a simulation, you must create an `Agent`. An `Agent` is an object that supervises a simulation, calling the `SimKit` functions at appropriate times and selecting the next event based on the probabilities given in JSON. Pass an `Agent` your `SimKit` object and call `agent.run()` (also passing an upper limit in the total number of events allowed).\n\n## Examples\n\n- Look through multiplication-sim.py and life-sim.py to get an idea on how to write custom code for a simulation. Their corresponding JSON files show all of the different states and their suffixes/probabilities.\n\n### life-sim.py\n\nA fairly simple simulation of a person's life, from birth until death.\n\n*Flow chart of different states in life-sim.py*:\n\n![Image](life-sim-diagram.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsb6%2Fevent-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsb6%2Fevent-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsb6%2Fevent-simulator/lists"}