Back
Close

Basic simulation and evaluation

MadKnight
3,149 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());
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants