Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String rule(char a, char b, char c){
- String rval = "0";
- if(a!=c){
- rval = "1";
- }
- return rval;
- }
- char fancyGet(int index){//gets a value from old at a given position
- if(index>=0){
- return old.charAt(index%(old.length()));
- } else {
- return old.charAt(old.length()-1);
- }
- }
- void run(){//the method that executes the rule
- old=program;//save the old program and begin mutation
- program = "";//empty the current program
- for(int i = 0; i < old.length(); i++){
- program = program + rule(fancyGet(i-1),fancyGet(i),fancyGet(i+1));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement