Programming Challenge 2
Shelling's Segregation
What to turn in:
- Floppy disk:
The executable file along with the six project files.
- Cover sheet:
Your name, the course number, a screen shot of the application.
- Source code:
Tweak, modify or write new code to produce a "meaningfully" different
functionality to model a "reasonable" story. Include a printout
of the section(s) of source code you wrote, tweaked or modified. Identify
the code you wrote with explanatory comments.
- Analysis:
A discursive description of what you did and an analysis of the behaviors
and patterns it produced. Also include screen shots of the relevant patterns.
Download the project ZIP files from our
Simulations page. UnZip the files and bring the entire project up in Borland.
In class on Tuesday I handed out a portion of the source code that contains
most of the "decisions" the agents make about moving to new locations.
The "sweet spot" is essentially the run()
function.
Suggestions as to what you may wish to
write or modify:
- Change existing decisions about when
to move or not.
- Add new options to the ComboBox
and new cases to the switch(choice)
block.
- Remember that you can create if()
statements that are quite long and complex using "and" &&,
"or" ||, "not"
!, as well as ==, >, <,
>= and <=.
- You could bypass the countNeighbors(int
e, int s) function entirely and let agents make decisions solely on
the basis of "who" is in a particular neighboring cell.
- In the version on our Website, only
the neighborhood around the "new" or "destination" cell
is checked. You might wish to check the neighborhood around the "old"
or "home" cell as well and use that as part of the decision. To
check the "old" or "home" neighborhood you will have to
modify not only the run()
function, but also the countNeighbors(int
e, int s) function and add a few more variables. It's really not too
hard to do.
- If you move the call to Form1->ComboBoxRules->ItemIndex
from the inner for (move...)
loop to the outer for(frame...)
loop it will speed things up.
- Consider not only the resulting pattern
of agent types, but the relative activity of the different agent types and
the "history" of changes you may have made during any one run.
- If you are familiar with PhotoShop and
color channels in images, you might create a bitmap image with different patterns
in the Red, Green and Blue channels and have agents of different types consult
different channels in the image.
- You might create an interesting bitmap
just in grays and use it with the existing source code.