Watched a video of a guy working with the game and getting things started.
Code Studies- Reading and analyzing code as if it were a text. We're about to go through and read some code.
The following is what Cade Taylor, Anna Romano, and I found interesting in the code for Micropolis:
/** Smooth police station map and compute crime rate */ void Micropolis::crimeScan() { smoothStationMap(&policeStationMap); smoothStationMap(&policeStationMap); smoothStationMap(&policeStationMap); Quad totz = 0; int numz = 0; int cmax = 0; for (int x = 0; x < WORLD_W; x += crimeRateMap.MAP_BLOCKSIZE) { for (int y = 0; y < WORLD_H; y += crimeRateMap.MAP_BLOCKSIZE) { int z = landValueMap.worldGet(x, y); if (z > 0) { ++numz; z = 128 - z; z += populationDensityMap.worldGet(x, y); z = min(z, 300); z -= policeStationMap.worldGet(x, y); z = clamp(z, 0, 250); crimeRateMap.worldSet(x, y, (Byte)z); totz += z; // Update new crime hot-spot if (z > cmax || (z == cmax && (getRandom16() & 3) == 0)) { cmax = z; crimeMaxX = x; crimeMaxY = y; } } else { crimeRateMap.worldSet(x, y, 0); } } } if (numz > 0) { crimeAverage = (short)(totz / numz); } else { crimeAverage = 0; } policeStationEffectMap = policeStationMap; newMapFlags[MAP_TYPE_CRIME] = 1; newMapFlags[MAP_TYPE_POLICE_RADIUS] = 1; newMapFlags[MAP_TYPE_DYNAMIC] = 1; }
Basically, we read that the more influential your police station/force is in the world you're given by the game, the less crime there is. However, you can update new crime hot spots, truly tapping into the God-ness that the player experiences in this game. The crime, then, is proportional to the population of the world and the influence of the police force. In addition, the crime rate is affected by police stations, powered, police funding ratio, and road access. Here's a picture of Micropolis:
Laura looked at what we just wrote, said that it was basically awesome, and immediately promised us all A's. Also, we're listening to The Black Keys because I suggested it, and this is the best class we've ever had because of it. Love me dem Black Keys.
Laura then took some code and tried to make it into a poem. There's a lot of artistic capability involved in the reading and writing of code, and it's possible to make a working code with a beautiful idea, like the anguish of a man longing for a woman to love him as he loves her; to just kiss her face.
That's all for today...
No comments:
Post a Comment