15,900,461 members
See more:
what algorithm for decision about simulation's movement escape from on fire by multi thread(many people).

Thank,

[I hope this is an accuracte rephrasing of the question]
I want to build an application to simulate how people respond during a fire. Imagine we have a building full of people and we want to simulate a fire alarm. We need to create a different thread for each person and have an algorithm figure out where the person should go to escape and simulate the movement in some way.

What is the best algorithm to use to simulate this?
Posted
Updated 3-Aug-10 7:53am
v2
Tom Deketelaere 3-Aug-10 5:40am
You'll have to explain a bit better what you want because this makes no sense to me.
Explain what you want / need your program to do, where you are stuck and what you'v done so far.

## Solution 1

You seem to mix up threads and simulation. With a simulation you try to create a controlled situation where you controls the steps by predefined rules. A simulation can run slower or faster than real-time without a problem. The time is relative to the simulation and therefore to the steps and are only noticed by the observer of the simulation. To keep it simple, the simulation runs in cycles and each entity within that simulation can do one step at a time. So all the people do a step and the "fire units" do a step. This all happens in a very controlled way and can be kept in track with time even when there get more or less entities. This means that a single cycle could be defined as a single second and if your simulation needs 10 seconds or 1 millisecond this only means that the observer has to wait longer or less to see the end results.

A simulation is a single game where every entity moves one step per cycle and makes it's decision on the previous state. So the entities do their main decision making based on the state it was just right before the cycle and only do for example collision checks to make sure nothing happens that cannot be possible, although people can run into each other in your case. A single cycle must be seen as a single moment in time and every entity makes a move at that same time. Of course the processing is done sequential and they move one after one, this again is only noticed by the observer. Look at it as if our life is divided into steps and even though I have the feeling it is all happening in a fluently motion, maybe our creator looks down and must wait one hour to see that you have slightly moved. It is all relative and has nothing to do with using threads to create a sense that everything happens at the same time, because that is just what a simulation simulates ;)

Start by defining the elements (entities) and what moves they can do. Then think out the rules (Like: If fire closer than three tiles away then move away from fire). Start out with very simple and basic rules and work from there. It's nice to first create a simple but visual engine to convert the simulation data to images on screen. With this you can easily work towards a more complex simulation. Step by step, one step at a time, keep that in mind.

Good luck!