Model Complex Systems with HASH: A Practical Simulation Guide
Introduction
Ever tried to understand why a warehouse runs smoothly with four employees but grinds to a halt with five? Or why increasing the hot water flow in a mixture doesn't always lead to a simple temperature rise? Basic math works for some problems, but many real-world systems are too intricate for simple formulas. That's where simulation modeling comes in. HASH is a free, online platform that lets you build simulations using JavaScript—no advanced math degree required. By modeling the behaviors of individual agents (like workers, customers, or particles), you can uncover hidden dynamics, test 'what-if' scenarios, and solve complex challenges. This guide walks you through creating your first HASH simulation, step by step.

What You Need
- A modern web browser (Chrome, Firefox, Edge, or Safari)
- An internet connection
- A free HASH account (sign up at hash.ai)
- Basic familiarity with JavaScript (variables, functions, loops)
- A curious mindset and a problem you'd like to explore
Step-by-Step Guide to Building Your First Simulation
Step 1: Sign Up and Explore the HASH Workspace
Navigate to hash.ai and click the Sign Up button. You can register with your email or via Google/GitHub. After confirming your account, log in. You'll land on the Home Dashboard. Take a moment to explore the interface: you'll see options to create a new project, browse sample simulations, and access tutorials. For this guide, we'll start from scratch.
Step 2: Create a New Project
Click the New Project button on the dashboard. A dialog box will appear asking for a project name. Choose something descriptive, like 'Warehouse Staffing Sim' or 'Customer Queue Model'. Click Create. HASH will generate a blank simulation environment with a default init.json file and a behavior.js file. These files define the initial state of your simulation and the rules your agents will follow.
Step 3: Define Your Agents in init.json
The init.json file describes the starting conditions. For a warehouse simulation, you might define agents representing employees. Open init.json and replace its contents with JSON that creates, say, 4 employees. Each agent should have properties like id, position, speed, and a task_state. For example:
{
"agents": [
{"id": 1, "position": [0, 0], "speed": 1, "task_state": "idle"},
{"id": 2, "position": [2, 0], "speed": 1, "task_state": "idle"},
...
]
}
You can also define global parameters like shelf_count or order_queue. Save the file.
Step 4: Write Agent Behaviors in behavior.js
Now open behavior.js. This is where you code the rules each agent follows every simulation tick. For the warehouse example, you might write JavaScript that makes an idle employee pick up the next order from a queue, move to the shelf, retrieve the item, and return. Use HASH's built-in functions like agent.setPosition() and agent.getNeighbors(). A simple behavior could be:
function behavior(state, context) {
const agent = state.agent;
const orders = state.orders;
if (agent.task_state === 'idle' && orders.length > 0) {
const nextOrder = orders.shift();
agent.task_state = 'picking';
agent.target = nextOrder.location;
}
// ... movement logic ...
return state;
}
Remember to handle agent interactions. For instance, when five agents are all trying to move through a narrow aisle, collisions occur—model this with a simple rule: if an adjacent cell is occupied, wait. This will naturally cause the slowdown you observed in real life.
Step 5: Set Up the Simulation Parameters
In the HASH interface, click on the Settings tab (gear icon). Here you can define the simulation duration (number of ticks), the environment size, and visualization options. For example, set the environment to a 20x20 grid and run for 500 ticks. You can also enable agent trails to see movement paths. Adjust these to match the scale of your problem—start small and increase complexity as you go.
Step 6: Run the Simulation and Observe
Click the Run button (play icon) to start the simulation. Watch the agents move on the grid canvas. Data panels will update in real-time showing metrics like total orders completed, average task time, and agent positions. Pause the simulation with the pause button to inspect individual agents. This observation phase is crucial—it's where you'll see the unexpected behaviors emerge, such as the jam with five agents.

Step 7: Analyze Outputs and Iterate
After the simulation completes, examine the generated logs and charts. HASH provides a built-in analysis view. Compare runs by varying the number of agents. For instance, run the simulation with 4 employees, then 5, then 6. Note the throughput changes. You might discover that adding the fifth worker actually reduces throughput due to congestion. This insight leads to step 8.
Step 8: Tweak Parameters and Rules
Use what you learned to improve the system. In your behavior.js, you can change movement rules—maybe agents can take alternative paths to avoid bottlenecks. Or adjust global parameters in init.json, like warehouse_width or order_arrival_rate. Re-run the simulation to test each change. Document your modifications in the project notes. HASH also supports multi-run experiments (batch simulations) in the Experiments tab, which automatically varies parameters and collects statistics.
Step 9: Share and Collaborate
Once you have a working simulation, consider sharing it. Click the Share button to generate a link. You can also publish your project to the HASH community gallery, where others can view, fork, and learn from your model. Collaboration features allow team members to comment on code and suggest edits. This is especially useful if you're modeling a business process or scientific phenomenon with colleagues.
Tips for Successful Simulation Modeling with HASH
- Start simple. Begin with minimal agents and basic rules. Complexity can always be added later.
- Use version control. HASH automatically saves history, but you can also manually save snapshots before major changes.
- Validate with real-world data. Compare simulation outputs to actual observations to ensure your model captures key dynamics.
- Leverage community examples. The HASH gallery has many pre-built simulations—study them to learn coding patterns.
- Think in agents. Any process with individual decision-makers (people, robots, animals) is a good candidate for agent-based modeling.
- Debug with visualization. Use HASH's visual debugger to step through ticks one at a time, inspecting agent states.
- Document your assumptions. Clearly note which behaviors are simplified—this helps others understand your model's limitations.
Now you're ready to explore your own complex problems using HASH. Whether you're simulating traffic flow, epidemic spread, or employee productivity, the platform gives you the power to experiment and learn. For more details, check out HASH's launch blog post and start building your simulations today!
Related Discussions