Basic simulation and evaluation
MadKnight
15.9K views
Overview
When making classes for basic objects you need to not forget to add some extra variables for the values that don't come with inputs like lap number for a pod.
Checkpoint class
class Checkpoint
{
public int id;
public Point position;
public Checkpoint prev, next;
public Checkpoint(int id) {
this.id = id;
position = new Point(Console.ReadLine());
}
}
Pod class
class Pod
{
Point position;
Vector velocity, direction;
float angle;
int lap;
Checkpoint target;
public Checkpoint() { }
public void Update() {
position = new Point(Console.ReadLine());
velocity = new Vector(Console.ReadLine());
angle = float.Parse(Console.ReadLine());
int ncpId = int.Parse(Console.ReadLine());
if (ncpId != target.id) {
target = target.next;
if (target.id == 1)
lap++;
}
}
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Suggested playgrounds