MCPcopy Create free account
hub / github.com/SimHacker/micropolis / voteProblems

Method voteProblems

MicropolisCore/src/MicropolisEngine/src/evaluate.cpp:278–298  ·  view source on GitHub ↗

* Vote on the problems of the city. * @param problemTable Storage of how bad each problem is. * * @post problemVotes contains the vote counts */

Source from the content-addressed store, hash-verified

276 * @post problemVotes contains the vote counts
277 */
278void Micropolis::voteProblems(const short problemTable[PROBNUM])
279{
280 for (int z = 0; z < PROBNUM; z++) {
281 problemVotes[z] = 0;
282 }
283
284 int problem = 0; // Problem to vote for
285 int voteCount = 0; // Number of votes
286 int loopCount = 0; // Number of attempts
287 while (voteCount < 100 && loopCount < 600) {
288 if (getRandom(300) < problemTable[problem]) {
289 problemVotes[problem]++;
290 voteCount++;
291 }
292 problem++;
293 if (problem > PROBNUM) {
294 problem = 0;
295 }
296 loopCount++;
297 }
298}
299
300
301/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected