This repository has the code to run a model of bacteria mixing in three-dimensions using random walker agents. The model is written in Rust and uses Atrix to run the server. The client is using the svelte framework to render the model.
To run the model, you need to have Rust installed. You can install Rust by following the instructions on the Rust website. Once you have Rust installed, you can run the model by running the following command in the terminal:
cd server
cargo watch -x run
This will start up a server on the port 8080. You can then open up a browser and go to the address localhost:8080/2d
to see the state of the model.
update this
WARNING: For now only the CPU endpoint is implemented. The GPU endpoint is still in development.
The server has two main endpoints
Returns for each universe dimension if it is Some or None. If it is Some, then the universe is alive and can be used. If it is None, then the universe is dead and cannot be used.
Get current state of the model as JSON Object. State includes:
size
: NUMBER - The size of the modelagents
: [NUMBER, NUMBER] - The number of agents in the modelseed
: NUMBER - The seed used to generate the modeliteration
: NUMBER - Number of updates the model has gone throughparams
: JSON - The parameters of the modelgamma
: NUMBER - TODOlambda
: TODObeta
: TODO
nodes
: ARRAY[JSON] - A list of nodes where each node is defined byindex
: NUMBER - The index of the nodeneighbours
: ARRAY[NUMBER] - The indices of the neighbours of the nodegrafitti
: [NUMBER, NUMBER]- The amount of red and blue grafitti in the nodered_agents
: NUMBER - The number of red agents in the nodeblue_agents
: NUMBER - The number of blue agents in the node
Get current state of the model as JSON Object. Is identical to the GET [1d|2d|3d]
endpoint except that the nodes
field is a list of agent nodes instead of nodes. Agent nodes are defined by:
nodes
: [{agents_red: NUMBER, agents_blue: NUMBER}]
Setup the model with a lattice size of <size>x<size>
for 2d and <size>x<size>x<size>
for 3d and <agents>
agents. The seed is optional and will default to 100 if not provided.
size
: NUMBER - The size of the latticeagents
: NUMBER - The number of agents in the model for each speciesseed?
: NUMBER - The seed used to generate the model
Set the parameters of the model
gamma
: NUMBER - TODOlambda
: NUMBER - TODObeta
: NUMBER - TODO
Iterate the model <amount>
times
# Create a 2d model with a size of 10x10 and 100 agents with a seed of 1234
POST localhost:8080/2d/10/100?seed=1234
# Set the parameters of the model
POST localhost:8080/2d/set_params?beta=0.1
# Iterate the model 100 times
PATCH localhost:8080/2d/iterate?amount=100
# Get the current state of the model as a json object
GET localhost:8080/2d