private void DrawRace(Graphics g) { Pen p = new Pen(Color.Black, 1); int iX = 0, iY = 0; for (iX = 0; iX < Width; iX++) { for (iY = 0; iY < Height; iY++) { if (CarState != null && iX == CarState.X && iY == CarState.Y) { g.FillRectangle(Brushes.Yellow, iX * SCALE, iY * SCALE, SCALE, SCALE); } else if (m_rtTrack.IsRaceStart(iX, iY)) { g.FillRectangle(Brushes.Red, iX * SCALE, iY * SCALE, SCALE, SCALE); } else if (m_rtTrack.IsRaceEnd(iX, iY)) { g.FillRectangle(Brushes.Green, iX * SCALE, iY * SCALE, SCALE, SCALE); } else if (m_rtTrack.ValidPoint(iX, iY)) { g.FillRectangle(Brushes.Black, iX * SCALE, iY * SCALE, SCALE, SCALE); } } } Text = CarState.ToString(); }
public override double Reward(Action a) { if (m_rtTrack.IsRaceEnd(this)) { return(m_rtTrack.MaxReward); } if (m_rtTrack.IsGoalState(this)) { return(0.0); } RaceCarState sTagApply = new RaceCarState(this); bool bNoCollision = sTagApply.Apply((VelocityAction)a, true); if (bNoCollision) { return(-0.01); } else { return(-sTagApply.Velocity); } }