public static void BotForecast(IGraphics graphics, double X, double Y, double Heading, double Velocity, int Turns) { BotPosition bot = new BotPosition(X, Y, Heading, Velocity); BotPosition[][] moves = BotPosition.AllMoves(bot, Turns); foreach (BotPosition[] path in moves) { int i = 0; //float LastX = (float)X; //float LastY = (float)Y; foreach (BotPosition b in path) { if (i++ % 4 == Turns % 4) //if (i++ % 5 == Turns % 5 && Turns/i < 2) { BotDot(graphics, b.Location.X, b.Location.Y); //BotBox(graphics, new Pen(Color.FromArgb(100, 255, 255, 0)), b.Location.X, b.Location.Y, b.Heading); //graphics.DrawRectangle(new Pen(Color.FromArgb(100, 255, 255, 0)), b.Location.X - 18, b.Location.Y - 18, 36, 36); //graphics.DrawLine(new Pen(Color.FromArgb(100, 255, 255, 0)), LastX, LastY, (float)b.Location.X, (float)b.Location.Y); //LastX = (float)b.Location.X; //LastY = (float)b.Location.Y; } } } }
public static BotPosition[][] AllMoves(BotPosition bot, int turns) { List<BotPosition[]> moves = new List<BotPosition[]>(); moves.Add(BotPosition.Move(bot, Motion.Accelerate, Turn.TurnLeft, turns)); moves.Add(BotPosition.Move(bot, Motion.Accelerate, Turn.Straight, turns)); moves.Add(BotPosition.Move(bot, Motion.Accelerate, Turn.TurnRight, turns)); //moves.Add(BotPosition.Move(bot, Motion.Coast, Turn.TurnLeft, turns)); //moves.Add(BotPosition.Move(bot, Motion.Coast, Turn.Straight, turns)); //moves.Add(BotPosition.Move(bot, Motion.Coast, Turn.TurnRight, turns)); moves.Add(BotPosition.Move(bot, Motion.Reverse, Turn.TurnLeft, turns)); moves.Add(BotPosition.Move(bot, Motion.Reverse, Turn.Straight, turns)); moves.Add(BotPosition.Move(bot, Motion.Reverse, Turn.TurnRight, turns)); return moves.ToArray(); }
public static BotPosition[][] AllMoves(BotPosition bot, int turns) { List <BotPosition[]> moves = new List <BotPosition[]>(); moves.Add(BotPosition.Move(bot, Motion.Accelerate, Turn.TurnLeft, turns)); moves.Add(BotPosition.Move(bot, Motion.Accelerate, Turn.Straight, turns)); moves.Add(BotPosition.Move(bot, Motion.Accelerate, Turn.TurnRight, turns)); //moves.Add(BotPosition.Move(bot, Motion.Coast, Turn.TurnLeft, turns)); //moves.Add(BotPosition.Move(bot, Motion.Coast, Turn.Straight, turns)); //moves.Add(BotPosition.Move(bot, Motion.Coast, Turn.TurnRight, turns)); moves.Add(BotPosition.Move(bot, Motion.Reverse, Turn.TurnLeft, turns)); moves.Add(BotPosition.Move(bot, Motion.Reverse, Turn.Straight, turns)); moves.Add(BotPosition.Move(bot, Motion.Reverse, Turn.TurnRight, turns)); return(moves.ToArray()); }
public static BotPosition[] Move(BotPosition bot, Motion motion, Turn turn, int turns) { List <BotPosition> moves = new List <BotPosition>(turns); if (turns > 1) { var arr = BotPosition.Move(bot, motion, turn, turns - 1); moves.AddRange(arr); bot = arr[turns - 2]; } double velocity = bot.Velocity; double heading = bot.Heading; switch (motion) { case Motion.Reverse: if (velocity >= Rules.DECELERATION) { velocity = velocity - Rules.DECELERATION; } else if (velocity > 0) { velocity = 0; } else if (velocity * -1 + Rules.ACCELERATION >= Rules.MAX_VELOCITY) { velocity = -1 * Rules.MAX_VELOCITY; } else { velocity = velocity - Rules.ACCELERATION; } break; case Motion.Accelerate: if (velocity + Rules.ACCELERATION >= Rules.MAX_VELOCITY) { velocity = Rules.MAX_VELOCITY; } else { velocity = velocity + Rules.ACCELERATION; } break; } switch (turn) { case Turn.TurnLeft: if (motion == Motion.Reverse) { heading = heading + Rules.GetTurnRate(Math.Abs(velocity)); } else { heading = heading - Rules.GetTurnRate(Math.Abs(velocity)); } break; case Turn.TurnRight: if (motion == Motion.Reverse) { heading = heading - Rules.GetTurnRate(Math.Abs(velocity)); } else { heading = heading + Rules.GetTurnRate(Math.Abs(velocity)); } break; } moves.Add(new BotPosition(bot.Location.VectorProjection(heading, velocity), heading, velocity)); return(moves.ToArray()); }
public static BotPosition[] Move(BotPosition bot, Motion motion, Turn turn) { return(BotPosition.Move(bot, motion, turn, 1)); }
public static BotPosition[][] AllMoves(BotPosition bot) { return(BotPosition.AllMoves(bot, 1)); }
public static BotPosition[] Move(BotPosition bot, Motion motion, Turn turn, int turns) { List<BotPosition> moves = new List<BotPosition>(turns); if (turns > 1) { var arr = BotPosition.Move(bot, motion, turn, turns - 1); moves.AddRange(arr); bot = arr[turns - 2]; } double velocity = bot.Velocity; double heading = bot.Heading; switch (motion) { case Motion.Reverse: if (velocity >= Rules.DECELERATION) { velocity = velocity - Rules.DECELERATION; } else if (velocity > 0) { velocity = 0; } else if (velocity * -1 + Rules.ACCELERATION >= Rules.MAX_VELOCITY) { velocity = -1 * Rules.MAX_VELOCITY; } else { velocity = velocity - Rules.ACCELERATION; } break; case Motion.Accelerate: if (velocity + Rules.ACCELERATION >= Rules.MAX_VELOCITY) { velocity = Rules.MAX_VELOCITY; } else { velocity = velocity + Rules.ACCELERATION; } break; } switch (turn) { case Turn.TurnLeft: if (motion == Motion.Reverse) { heading = heading + Rules.GetTurnRate(Math.Abs(velocity)); } else { heading = heading - Rules.GetTurnRate(Math.Abs(velocity)); } break; case Turn.TurnRight: if (motion == Motion.Reverse) { heading = heading - Rules.GetTurnRate(Math.Abs(velocity)); } else { heading = heading + Rules.GetTurnRate(Math.Abs(velocity)); } break; } moves.Add(new BotPosition(bot.Location.VectorProjection(heading, velocity), heading, velocity)); return moves.ToArray(); }
public static BotPosition[] Move(BotPosition bot, Motion motion, Turn turn) { return BotPosition.Move(bot, motion, turn, 1); }
public static BotPosition[][] AllMoves(BotPosition bot) { return BotPosition.AllMoves(bot, 1); }