- Timestamp:
- 08/05/13 12:23:31 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Resources/LawnMower.txt
r9846 r9847 1 1 PROBLEM LawnMower 2 2 /* the lawn mower problem with syntax to enforce that constants and sums are only used 3 * in sub-trees under the "frog" symbol. Interestingly, this increases success rates in 4 * comparison with the original formulation where functions could be combined freely. 3 * in sub-trees under the "frog" symbol. (Original formulation by Koza did not use a grammar) 5 4 */ 6 5 CODE << … … 20 19 class World { 21 20 private bool[,] mowed = new bool[Width, Height]; 22 public World() { 23 Reset(); 24 } 25 public void Reset() { 26 for(int col = 0; col < Width; col++) 27 for(int row = 0; row < Height; row++) { 28 mowed[col, row] = false; 29 } 30 } 21 31 22 public void SetCellMowed(Point p) { 32 23 mowed[p.x, p.y] = true; … … 108 99 } 109 100 110 World CreateWorld() {111 return new World();112 }113 114 World world;115 101 /* set of possible values for constants [-100, 100] */ 116 102 int[] ints = Enumerable.Range(-100, 201).ToArray(); 117 103 >> 118 104 INIT << 119 world = CreateWorld();120 105 >> 121 106 … … 165 150 MAXIMIZE 166 151 << 167 world.Reset();152 var world = new World(); 168 153 var state = new MowerState() {Position = new Point(0,0), 169 154 Energy = 2 * Height * Width, 170 155 Direction = Direction.South, 171 156 World = world}; 172 w hile(state.Energy > 0) {173 LawnMower(state);174 }157 world.SetCellMowed(state.Position); // set initial cell mowed 158 // execute the mower program once 159 LawnMower(state); 175 160 return (double)state.MowedCells; 176 161 >>
Note: See TracChangeset
for help on using the changeset viewer.