/// <summary> /// Draws the maze, robots, etc. to the screen. /// </summary> public override void draw(Graphics g, CoordinateFrame scale) { foreach (Robot robot in robots) { robot.draw(g, scale); } double[] obj = null; if (environment != null) { environment.draw(g, scale); } instance_pack ip = new instance_pack(); ip.robots = robots; ip.env = environment; ip.timeSteps = this.timeSteps; ip.agentBrain = agentBrain; ip.collisionManager = collisionManager; ip.elapsed = this.elapsedTime; ip.ff = this.fitnessFunction; ip.bc = this.behaviorCharacterization; ip.timestep = timestep; g.DrawString("Fitness: " + this.fitnessFunction.calculate(this, this.environment, ip, out obj), new Font("Tahoma", 12), Brushes.Black, 10, 90); g.DrawString("Elapsed time: " + this.elapsedTime, new Font("Tahoma", 12), Brushes.Black, 10, 60); }
public virtual void draw(Graphics g, CoordinateFrame frame) { Point a = frame.convertToDisplay((float)(Owner.Location.X), (float)(Owner.Location.Y)); Point b = frame.convertToDisplay((float)(Owner.Location.X + Math.Cos(Angle + Owner.Heading) * DistanceToClosestObject), (float)(Owner.Location.Y + Math.Sin(Angle + Owner.Heading) * DistanceToClosestObject)); g.DrawLine(EngineUtilities.GreendPen, a, b); }
/// <summary> /// Draws the wall to the screen. /// </summary> public void draw(Graphics graphics, CoordinateFrame frame) { float ax,ay,bx,by; frame.convertToDisplay((float)Line.Endpoint1.X,(float)Line.Endpoint1.Y,out ax, out ay); frame.convertToDisplay((float)Line.Endpoint2.X,(float)Line.Endpoint2.Y,out bx, out by); if (Visible) graphics.DrawLine(EngineUtilities.BluePen, ax,ay, bx,by); else graphics.DrawLine(EngineUtilities.GreendPen, ax,ay,bx, by); }
/// <summary> /// Draws the radar to the screen. /// </summary> public void draw(Graphics g, CoordinateFrame frame) { Brush b = new SolidBrush(Color.Green); Size s = new Size((int)((MaxRange) / frame.Scale), (int)((MaxRange) / frame.Scale)); if (Type == "directedVoiceNOTASENSOR") // Special drawing rules for this Type of sensor (used for showing communication) { if (Activation < 0.1) { s = new Size((int)((MaxRange * 1.0) / frame.Scale), (int)((MaxRange * 1.0) / frame.Scale)); b = new SolidBrush(Color.FromArgb((int)(0), 128, 128, 128)); } else { s = new Size((int)((MaxRange * Activation) / frame.Scale), (int)((MaxRange * Activation) / frame.Scale)); b = new SolidBrush(Color.FromArgb((int)(80), 200, 0, 200)); } g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); return; } Rectangle r = new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)), s); if (Activation == 0) { if (Type == "goal") { g.DrawPie(EngineUtilities.GreendPen, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); } else { g.DrawPie(EngineUtilities.RedPen, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); } } else { if (Type == "goal") { b = new SolidBrush(Color.FromArgb((int)(Activation * 255), 0, 255, 0)); g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); } else { b = new SolidBrush(Color.FromArgb((int)(Activation * 255), 255, 0, 0)); g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); } } }
/// <summary> /// Draws the wall to the screen. /// </summary> public void draw(Graphics graphics, CoordinateFrame frame) { float ax, ay, bx, by; frame.convertToDisplay((float)Line.Endpoint1.X, (float)Line.Endpoint1.Y, out ax, out ay); frame.convertToDisplay((float)Line.Endpoint2.X, (float)Line.Endpoint2.Y, out bx, out by); if (Visible) { graphics.DrawLine(EngineUtilities.BluePen, ax, ay, bx, by); } else { graphics.DrawLine(EngineUtilities.GreendPen, ax, ay, bx, by); } }
/// <summary> /// Draws the CurrentEnvironment to the screen. /// </summary> public void draw(Graphics g, CoordinateFrame frame) { float sx, sy; float gx, gy; frame.convertToDisplay((float)start_point.X, (float)start_point.Y, out sx, out sy); frame.convertToDisplay((float)goal_point.X, (float)goal_point.Y, out gx, out gy); Rectangle startrect = new Rectangle((int)sx - 3, (int)sy - 3, 6, 6); Rectangle goalrect = new Rectangle((int)gx - 3, (int)gy - 3, 6, 6); float rx, ry, rsx, rsy; frame.convertToDisplay((float)AOIRectangle.X, (float)AOIRectangle.Y, out rx, out ry); frame.convertToDisplayOffset((float)AOIRectangle.Width, (float)AOIRectangle.Height, out rsx, out rsy); Rectangle AOIDisplay = new Rectangle((int)rx, (int)ry, (int)rsx, (int)rsy); //Display Area of Interest rectangle g.DrawRectangle(EngineUtilities.DashedPen, AOIDisplay); g.DrawEllipse(EngineUtilities.BluePen, startrect); g.DrawEllipse(EngineUtilities.RedPen, goalrect); //Display Point Of Interests int index = 0; foreach (Point p in POIPosition) { Point p2 = frame.convertToDisplay(p); g.DrawEllipse(EngineUtilities.GreendPen, new Rectangle((int)p2.X - 3, (int)p2.Y - 3, 6, 6)); g.DrawString(index.ToString(), new Font("Verdana", 8), new SolidBrush(Color.Black), p2.X, p2.Y); index++; } foreach (Wall wall in walls) { wall.draw(g, frame); } }
public virtual void draw(Graphics g, CoordinateFrame scale) { }
public SimulatorVisualizer(string experimentName,string genome) { frame = new CoordinateFrame(0.0f, 0.0f, 5.0f, 0.0f); ExperimentWrapper wr = ExperimentWrapper.load(experimentName); experiment = wr.experiment; if(genome!=null) { experiment.loadGenome(genome); } experiment.initialize(); frame.syncFromEnvironment(experiment.environment); selected_POI = -1; bDrawFOV = false; bDrawFOV = false; bDrawLabel = true; displayAOIRectangle = false; displayEvolution = true; bEvolve = false; //by default we are not evolving, just displaying the CurrentEnvironment drawMode = drawModes.selectMode; //default mode is selecting and moving walls selectMode = selectModes.dragMode; display_tempwall = false; //no temporary wall exists at creation display_snap = false; //we have nothing to snap to at creation InitializeComponent(); this.Text = "MultiAgent-HyperSharpNEAT Simulator - " + experimentName; //set up double buffering this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); }
/// <summary> /// Draws the robot to the screen. /// </summary> public virtual void draw(Graphics g, CoordinateFrame frame) { Point upperleft = frame.convertToDisplay((float)(AreaOfImpact.Position.X - Radius), (float)(AreaOfImpact.Position.Y - Radius)); int size = (int)((Radius * 2) / frame.Scale); Rectangle r = new Rectangle(upperleft.X, upperleft.Y, size, size); double voiceRadius = Radius + (CurrentVoiceLevel * 8.5 * Radius); Point upperleftVoice = frame.convertToDisplay((float)(AreaOfImpact.Position.X - voiceRadius), (float)(AreaOfImpact.Position.Y - voiceRadius)); int sizeVoice = (int)((voiceRadius * 2) / frame.Scale); Rectangle rv = new Rectangle(upperleftVoice.X, upperleftVoice.Y, sizeVoice, sizeVoice); double maxVoiceRadius = Radius + (8.5 * Radius); Point upperleftMaxVoice = frame.convertToDisplay((float)(AreaOfImpact.Position.X - maxVoiceRadius), (float)(AreaOfImpact.Position.Y - maxVoiceRadius)); int sizeMaxVoice = (int)((maxVoiceRadius * 2) / frame.Scale); Rectangle rmv = new Rectangle(upperleftMaxVoice.X, upperleftMaxVoice.Y, sizeMaxVoice, sizeMaxVoice); if (Disabled) { g.DrawEllipse(EngineUtilities.YellowPen, r); } else if (HasCollided) { g.DrawEllipse(EngineUtilities.RedPen, r); } else if (Stopped) { g.DrawEllipse(EngineUtilities.RedPen, r); } else { g.DrawEllipse(EngineUtilities.BluePen, r); } int sensCount = 0; if (DisplayDebug) { // Print "other GoalSensors" not in the main GoalSensors list foreach (RangeFinder rf in WallSensors) { rf.draw(g, frame); } foreach (float f in NetworkOutputCopy) { float f1 = (f + 1) / 2.0f; Color col = Color.FromArgb(0, 0, (int)(f1 * 255)); SolidBrush newpen = new SolidBrush(col); g.DrawString(f.ToString(), SystemFonts.DefaultFont, Brushes.Black, sensCount * 60 + 400, 500 + 10 * ID); sensCount += 1; } sensCount = 0; // Color in the voice level for this robot g.FillEllipse(EngineUtilities.voiceColorBrush, rv); } float rad = (float)Radius * frame.Scale; g.DrawLine(EngineUtilities.BluePen, frame.convertToDisplay((float)AreaOfImpact.Position.X, (float)AreaOfImpact.Position.Y), frame.convertToDisplay((float)AreaOfImpact.Position.X + (float)Math.Cos(Heading) * 2 * (float)(Radius), (float)AreaOfImpact.Position.Y + (float)Math.Sin(Heading) * 2 * (float)(Radius))); }
/// <summary> /// Draws the robot to the screen. /// </summary> public virtual void draw(Graphics g, CoordinateFrame frame) { Point upperleft = frame.convertToDisplay((float)(AreaOfImpact.Position.X - Radius), (float)(AreaOfImpact.Position.Y - Radius)); int size = (int)((Radius * 2) / frame.Scale); Rectangle r = new Rectangle(upperleft.X, upperleft.Y, size, size); double voiceRadius = Radius + (CurrentVoiceLevel * 8.5 * Radius); Point upperleftVoice = frame.convertToDisplay((float)(AreaOfImpact.Position.X - voiceRadius), (float)(AreaOfImpact.Position.Y - voiceRadius)); int sizeVoice = (int)((voiceRadius * 2) / frame.Scale); Rectangle rv = new Rectangle(upperleftVoice.X, upperleftVoice.Y, sizeVoice, sizeVoice); double maxVoiceRadius = Radius + (8.5 * Radius); Point upperleftMaxVoice = frame.convertToDisplay((float)(AreaOfImpact.Position.X - maxVoiceRadius), (float)(AreaOfImpact.Position.Y - maxVoiceRadius)); int sizeMaxVoice = (int)((maxVoiceRadius * 2) / frame.Scale); Rectangle rmv = new Rectangle(upperleftMaxVoice.X, upperleftMaxVoice.Y, sizeMaxVoice, sizeMaxVoice); if (Disabled) g.DrawEllipse(EngineUtilities.YellowPen, r); else if (HasCollided) g.DrawEllipse(EngineUtilities.RedPen, r); else if (Stopped) g.DrawEllipse(EngineUtilities.RedPen, r); else { g.DrawEllipse(EngineUtilities.BluePen, r); } int sensCount = 0; if (DisplayDebug) { // Print "other GoalSensors" not in the main GoalSensors list foreach (RangeFinder rf in WallSensors) { rf.draw(g, frame); } foreach (float f in NetworkOutputCopy) { float f1 = (f + 1) / 2.0f; Color col = Color.FromArgb(0, 0, (int)(f1 * 255)); SolidBrush newpen = new SolidBrush(col); g.DrawString(f.ToString(), SystemFonts.DefaultFont, Brushes.Black, sensCount * 60 + 400, 500 + 10 * ID); sensCount += 1; } sensCount = 0; // Color in the voice level for this robot g.FillEllipse(EngineUtilities.voiceColorBrush, rv); } float rad = (float)Radius * frame.Scale; g.DrawLine(EngineUtilities.BluePen, frame.convertToDisplay((float)AreaOfImpact.Position.X, (float)AreaOfImpact.Position.Y), frame.convertToDisplay((float)AreaOfImpact.Position.X + (float)Math.Cos(Heading) * 2 * (float)(Radius), (float)AreaOfImpact.Position.Y + (float)Math.Sin(Heading) * 2 * (float)(Radius))); }
public virtual void draw(Graphics g, CoordinateFrame frame) { Point a = frame.convertToDisplay((float)(Owner.Location.X),(float)(Owner.Location.Y)); Point b = frame.convertToDisplay((float)(Owner.Location.X+Math.Cos(Angle+Owner.Heading)*DistanceToClosestObject), (float)(Owner.Location.Y+Math.Sin(Angle+Owner.Heading)*DistanceToClosestObject)); g.DrawLine(EngineUtilities.GreendPen, a, b); }
/// <summary> /// Draws the radar to the screen. /// </summary> public void draw(Graphics g, CoordinateFrame frame) { Brush b = new SolidBrush(Color.Green); Size s = new Size((int)((MaxRange) / frame.Scale), (int)((MaxRange) / frame.Scale)); if (Type == "directedVoiceNOTASENSOR") // Special drawing rules for this Type of sensor (used for showing communication) { if (Activation < 0.1) { s = new Size((int)((MaxRange * 1.0) / frame.Scale), (int)((MaxRange * 1.0) / frame.Scale)); b = new SolidBrush(Color.FromArgb((int)(0), 128, 128, 128)); } else { s = new Size((int)((MaxRange * Activation) / frame.Scale), (int)((MaxRange * Activation) / frame.Scale)); b = new SolidBrush(Color.FromArgb((int)(80), 200, 0, 200)); } g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); return; } Rectangle r = new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)),s); if (Activation == 0) { if(Type == "goal") g.DrawPie(EngineUtilities.GreendPen, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); else g.DrawPie(EngineUtilities.RedPen, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); } else { if (Type == "goal") { b = new SolidBrush(Color.FromArgb((int)(Activation * 255), 0, 255, 0)); g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); } else { b = new SolidBrush(Color.FromArgb((int)(Activation * 255), 255, 0, 0)); g.FillPie(b, new Rectangle(frame.convertToDisplay((float)(Owner.AreaOfImpact.Position.X), (float)(Owner.AreaOfImpact.Position.Y)) - new Size(s.Width / 2, s.Height / 2), s), (float)StartAngle + (float)(Owner.Heading * 57.2957795), (float)(EndAngle - StartAngle)); } } }