Last night, I was in that weird halfway state between waking and sleeping, and for some reason, I started thinking about NetLogo. I had an idea for how to program a simulation of contact inhibition in human cells, which is the mechanism that stops cells from reproducing when they’re surrounded by other cells. When this mechanism goes awry, cancer can result, because the cells keep reproducing and reproducing wher they’re not needed, spreading and using up resources. So after I got up and got woken up, I got to work.
The simulation works like this: there are a bunch of blue cells scattered around the simulated world. At every step, they check to see if there’s another cell within a certain distance of them. If there is, then they pick another random cell nearby, turn to face it, then point the opposite way and move forward a little. Also, as long as there are cells within that distance, the cells don’t reproduce.
Well, the normal cells don’t reproduce, becaus their contact-inhibition variable is set to “true.” However, each time a cell reproduces, there’s a small chance that its daughter cell will have its contact-inhibition variable set to “false.” When this happens, the cell keeps dividing and spreading even when it’s surrounded. Since every cell uses nutrients (which are produced by randomly-placed patches meant to simulate blood vessels), thsese fast-reproducing cancerous cells quickly spread out of control, disrupting the surrounding tissue and starving it until the tissue eventually dies.
In the venerable Life of a Math Major tradition (Venerable. Ha!), here are some screenshots (sorry about all the white space):

The tissue has been created and organized itself. Few of the cells divide because they’re all surrounded by other cells.
Now, the tissue has been seeded with a cell with defective contact inhibition (shown in red).
The cancerous cells begin to reproduce, until…
… the tumor begins to disrupt the surrounding tissue. Note how the green background has become darker in the area around the tumor, because the fast-spreading cancerous cells are using up all the nutrients.
As they proliferate, the cancerous cells compress the cells around the tumor. The tumor is now consuming nutrients so quickly that the cells in its interior have started to die. This mirrors the necrosis sometimes found in real tumors.
The cancer progresses. The necrosis continues to worsen as the tumor consumes more and more nutrients. Note how the population graph for healthy cells has started to turn sharply downwards.
The tumor has spread and effectively destroyed all the surrounding tissue. The healthy cell population has crashed, and the cancer has metastasized to other areas.
I’m quite happy with how it worked out. The code is incredibly lightweight, and even when there are a lot of cells onscreen, it runs fairly quickly. There are still some problems to be worked out, however, the main one being that the nutrients seem to get depleted on their own, even when no cancer is presents. I might or might not upload this to the NetLogo community models page, depending on how satisfied I am with it tomorrow.