//========================================================================== // SEGREGATION & ASSIMILATION / Version 28 // 18 November 2012 //=========================================================================== //=========================================================================== // DEFINES & VARIABLES //=========================================================================== #define BLACK 0 // an empty cell #define EMPTY 0 // an empty cell #define CYAN 1 // a default agent #define MAGENTA 2 // a default agent #define YELLOW 3 // a default agent #define SILVER 4 // an extra agent #define WHITE 5 // a barrier #define BARRIER 5 // a barrier class agent { public: int type; // cell type int excitedness; // for cops & rioters rule int tracking; // for tracking }; agent world[200][200]; // our world int bmpRed[200][200]; ] Red int bmpGreen[200][200]; ] Green BITMAP color channels int bmpBlue[200][200]; ] Blue int likeMe; // type of agent whose turn it is int hE, hS; // coordinates of agent's home int dE, dS; // coordinates of agent's destination int tE, tS; // coordinates of right-clicked target //=========================================================================== // SENSE //=========================================================================== call: countHome8Neighbors()... [ 8 cell to get: home8Neighbors[6] [ call: countDest8Neighbors()... [ to get: dest8Neighbors[6] [ call: countHome24Neighbors()... [ 24 cell to get: home24Neighbors[6] [ call: countDest24Neighbors()... [ to get: dest24Neighbors[6] [ call: countHome16RingNeighbors()... ] 16 cell ring to get: home16RingNeighbors[6] ] call: countDest16RingNeighbors()... ] to get: dest16RingNeighbors[6] ] call: countHome48Neighbors()... ] 48 cell to get: home48Neighbors[6] ] call: countDest48Neighbors()... ] to get: dest48Neighbors[6] ] call: countHome24RingNeighbors()... ] 24 cell ring to get: home24RingNeighbors[6] ] call: countDest24RingNeighbors()... ] dto get: est24RingNeighbors[6] ] call: countHome48bmpRedNeighbors()... ] 48 cell Bitmap red channel to get: home48bmpRedNeighbors[6] ] call: countDest48bmpRedNeighbors()... ] to get: dest48bmpRedNeighbors[6] ] //=========================================================================== // THINK //=========================================================================== rules beging at about line 1000 ] add your magic here //=========================================================================== // ACT //=========================================================================== moveMe(); ] canonical segregation changeMeTo(CYAN); ] canonical assimilation changeMeTo(CYAN); moveMe(); ] segregation / assimmilation mix moveMe(); changeMeTo(CYAN); ] CAUTION: creates another agent moveMe(); moveMe(); ] CAUTION: deletes the agent