Agent City is a program for demonstrating how multiple rule-based agents can behave in an environment. Agent City is a fictive city inhabited by three types of agents; green, blue and red. Each agent lives in a house in the city. The city also has some houses for sale (white squares), roads (gray) and areas without houses (white large areas). There are in total 774 houses in the city, and 8 is always for sale. The idea behind the program is that green agents prefer to live next door to other green agents, blue next to blue agents and red next to red agents. When an agent does not like its neighborhood (too many blue's around me and I am green) the can choose to move to a house for sale. By running the simulation it is shown that the city becomes more and more segregated.


Each agent follows these rules:

  • Each month an agent calculates a score for how good its neighborhood is. In a 5x5 square, 0.3 is added for each agent with the same color and 0.4 is subtracted for each agent with the wrong color. This gives a neighborhood score between -9.6 to 7.2.
  • If the score is 0 or above, the agent never decides to move.
  • If the score is between 0 and -1 the agent has 0.5% chance to move.
  • If the score is between -1 and -2 the agent has 1% chance to move.
  • If the score is between -2 and -3 the agent has 2% chance to move.
  • If the score is lower than -3 the agent has 6% chance to move.
  • An agent never moves to a house with lower neighborhood score than the current.
  • An agent always stays at least 6 months in a new house.

Agent City