Ends after 5 houses are built. You can zoom with the mousewheel (maybe, I didn’t test it in many browsers) and click and drag to pan around.
blue = lumberjack
green = tree
A scaffold of a house is light colored + pulsing, and becomes solid when built
grayish = floor tile of a house, can be walked through
brownish = wall tile of a house, cannot be walked through
The roof and front door are ignored for the sake of the simulation, as they make things too hard to see.
Occasionally someone gets built right into a wall — this will cause everyone to stop working soon thereafter. Refreshing the page will restart the simulation, and most of the time it works out.
The workers now obey reasonable pathfinding, and (somewhat) handle changes when their paths get blocked.
All of the little workers now share some information which allows them to complete their tasks. In the code, I refer to this as a community. A community keeps track of work, trees, houses, and soon danger. When a worker decides to go cut down a tree (or build a tile of a house) it gets registered within a community, and other workers from that same community won’t attempt to complete the same tasks. This leads to a division of tasks that allows for a more efficient work.
The community holds its own little decision set, which decides if more houses need built. At the moment it builds 5 houses. Later on it will build one house per npc, and the houses will be specialized for the npc.
When a worker looks for a tree (or something to build) the worker can only choose from tasks known to the community as a whole. In this simulation, all of the trees “belong” to the community. In the real game, trees and other resources would be added to the community’s knowledge as its members scout them out. Scouting will crudely emulate ant behavior.
This same notion of communal knowledge is going to be used to store a concept of danger. Just the way the community knows where trees are, or where a house is, it will also know where a dangerous creature is (after a member sees it). The community will forbid regular work from occurring in the vicinity of the danger. Danger will decay over time if not reinforced, so workers won’t avoid a patch of trees forever just because a zombie walked by. Danger may also be used in the future to send off an npc guard, or maybe just whine to the player.