/** * Hunter-Prey simulator version 1.1 * Copyright 2011 Kenneth Mackin */ public class Field { Agent[] agent; FieldView view; int width = 50; int height = 50; int agents = 5; boolean visible = false; int LOOP=1000; int RANGE=2; double[][] param; public static void main(String[] args){ boolean voption = false; if(args.length>0){ if(args[0].equals("-v")){ System.out.println("Visible mode"); voption = true; } } new Field(voption); } public Field(boolean visible){ agent = new Agent[agents]; agent[0] = new PreyAgent(this, width/2, height/2, 0); //adjustable Hunter parameters param = new double[][]{{0.4,-5,-4},{0.4,5,-4},{0.7,3,3},{0.7,-3,3}}; for(int i=1; i=width || agent[0].getY()<0 || agent[0].getY()>=height){ System.out.println("Escape!"); end=true; } if(counter>=LOOP){ System.out.println("Time up!"); end=true; } } if(visible){ view.showAgents(); } System.out.println("counter="+counter); } public int getWidth(){ return width; } public int getHeight(){ return height; } public int getX(int index){ return agent[index].getX(); } public int getY(int index){ return agent[index].getY(); } public int getAgents(){ return agents; } }