class Ribbon extends Edge { public Ribbon(Node n0, Node n1, color c, String label, String type) { super(n0,n1,c,label,type); } } class RibbonNode extends Node { public RibbonNode (color c, float rad, int shape, String label, String type, AList l) { super(c,rad,shape,label,type,l); } } class RibbonAgent extends Agent { Node fieldExit = null; boolean beenOnField = false; boolean followFieldMode = false; public RibbonAgent(Edge edge, color c, int shape, String label, String type, float speed, float percent) { super(edge,c,shape,label,type,speed,percent); } public RibbonAgent(Edge edge, color c, int shape, float speed, float percent) { // an agent w/ no label or type super(edge,c,shape,speed,percent); } public void step() { if (graph.steps() < 20) { setXYZ(); return; } if (!beenOnField && edge().type == "Corridor") { beenOnField = true; followFieldMode = false; } if (fieldExit != null) { stepToward(fieldExit); } else if (edge().subtype == "BottomRow" && random(1)>0.95 && !beenOnField && fieldEgress) { chooseFieldExit(); setHere(fieldExit); beenOnField = true; followFieldMode = false; } else { super.step(); } } int setAgentExit(boolean confused) { int exitChoice; float d1,d2; float randNum; int ran = 0; if (fieldEgress && !beenOnField && toNode().distToBottom < 5 && random(1)>0.20) { followFieldMode = true; return 1; } if (fieldEgress && !beenOnField && toNode().distToBottom < 10 && random(1)>0.80) { followFieldMode = true; return 1; } if (fieldEgress && !beenOnField && toNode().distToBottom < 15 && random(1)>0.99) { followFieldMode = true; return 1; } if (getCurrentExit() == -1) this.setData(Agent.CurrentExit,randomInt(ExitNodes.size())); if (confused) return 0; d1 = getDistanceToExit(); randNum = random(1.0f); exitChoice = ((Integer)this.toNode().getData(Graph.MinExit)).intValue(); if ( randNum(Agents.size()>2500?0.25:0)) { int i = getIntData(CurrentExit); Edge edge = n.getMinEdge(Graph.ExitDistances, i); if (edge == null) println("Couldn't find next edge for node: " +n.id); return edge; } return (Edge) n.getEdges().get(floor(random(n.getEdges().size()))); } void flee(float x, float y, float z) { if (fieldExit == null) super.flee(x,y,z); } Edge getFieldExitCorridor(Node fieldExit) { Edge edge; for (int i=0; i