/*
  Copyright 2006 by Sean Luke
  Licensed under the Academic Free License version 3.0
  See the file "LICENSE" for more information
*/


package ec.app.lawnmower;
import ec.util.*;
import ec.*;
import ec.gp.*;
import ec.gp.koza.*;
import ec.simple.*;

/* 
 * Lawnmower.java
 * 
 * Created: Mon Nov  1 15:46:19 1999
 * By: Sean Luke
 */

/**
 * Lawnmower implements the Koza-II Lawnmower problem.
 *
 

Parameters

base.data
classname, inherits or == ec.app.lawnmower.LawnmowerData
(the class for the prototypical GPData object for the Lawnmower problem)
base.file
String
(filename of the .trl file for the Lawnmower problem)
base.turns
int >= 1
(maximal number of moves the lawnmower may make)

Parameter bases

base.data species (the GPData object)
* * @author Sean Luke * @version 1.0 */ public class Lawnmower extends GPProblem implements SimpleProblemForm { private static final long serialVersionUID = 1; public static final String P_X = "x"; public static final String P_Y = "y"; // map point descriptions public static final int UNMOWED = 0; // orientations public static final int O_UP = 0; public static final int O_LEFT = 1; public static final int O_DOWN = 2; public static final int O_RIGHT = 3; // our map public int map[][]; // map[][]'s bounds public int maxx; public int maxy; // our current position public int posx; public int posy; // how many points we've gotten public int sum; // our orientation public int orientation; // how many moves we've made public int moves; // print modulo for doing the abcdefg.... thing at print-time public int pmod; public Object clone() { Lawnmower myobj = (Lawnmower) (super.clone()); myobj.map = new int[map.length][]; for(int x=0;x0", base.push(P_X)); maxy = state.parameters.getInt(base.push(P_Y),null,1); if (maxy==0) state.output.error("The length (y dimension) of the lawn must be >0", base.push(P_Y)); state.output.exitIfErrors(); // set up the map map = new int[maxx][maxy]; for(int x=0;x", log); for(int x=0;x

Ads help maintain this website.