PseudoCode for Formation.java Written by Mark Rich April 12, 1999 Using Option 2 Formation: Create an empty Congress Create an empty Population For (i < numberOfDistricts) Create District[i] Find a random center for the district For (j < numberOfVoters) Create Voter[i,j] Find median utility Add District[i] to Population For (numberOfSessions) For (i < numberOfDistricts) Elect Rep for District[i] Find Candidates If there exists a CurrentRep If CurrentRep is too old Replace CurrentRep with new Voter Else Insert CurrentRep into position 0 of CandidatePool For 1/15 of the Voters randomly selected with Replacement If already a Candidate, do not add If CurrentRep's percent of the votes > ambition, don't add If Ideology is too similar to other Candidates, don't add Else add voter to CandidatePool Conduct a Vote For each Voter If Voter is not lazy Find Candidate[x] with best Utility Find Candidate[y] with best Tag If Candidate[x] == Candidate[y] Increase laziness Else Decrease laziness If Voter is lazy Find Candidate[x] with best Tag Adapt the Voter's tag to be similar to Candidate[x] Return a vote for Candidate[x] Candidate with most votes becomes CurrentRep Find centrality of the winner Genetically Adapt CandidatePool Reproduction of 50 platforms Pick two Candidates at random with replacement Place the one with more votes in the "Fishpond" Mutation for 1% of positions added to the fishpond write them down as a random position Selection For each Candidate[x] If (numberOfVoters - CurrentRep.votesReceived) / ` (numberOfCandidates in election + 1) > Candidate[x].votesReceived Drop out of the race Crossover For each Candidate[x] remaining Find a random "fish" Steal Candidate[x].votesReceived / CurrentRep.votesReceived % of the fish's platform Place winning Rep[i] in Congress Conduct Business of Congress Propose Legislation Find a Rep who's positions is different from the Status Quo Propose that position as a Bill Each Member votes yes or no on the Bill vs Status Quo If Bill wins, it becomes new status Quo For each Rep Find a random member to adapt Adapt other member's tag proportional to similartiy of voting records Update Tags of Each Rep Send Member of Congress Home