Hmm… am I seeing some odd behaviour of the codingame runtime?
I’ve created a class to represent a pod - initialise it with the targetID… but when I then retrieve that value, it’s changed?
class Pod
{
…
int _targetID;
public Pod( int id, int x, int y, int vx, int vy, int angle, int targetID )
{
...
_targetID = targetID;
Console.Error.WriteLine("Pod " + _id + " setup Target=" + _targetID );
}
public int TargetID
{
get
{
return _targetID;
}
}
public string Act( ... )
{
Console.Error.WriteLine("Pod " + _id + " recover target=" + _targetID);
...
I initialise the object with ‘2’… but when I come to invoke Act(), it’s revised to ‘1’? There’s no other code that interacts with _targetID anywhere…
Hi all, can you help? Is there a way to regress to previous levels and / or previous versions of code within Codingame?
I’ve made the n00b mistake of hacking code that was working well in the single pod scenario, and want to get back to that so I can check how I ran that, to help me with the two pod version.
A boost is in fact an acceleration of 650 . The number of boost available is common between pods. If no boost is available, the maximum thrust is used.
You need to be above the Boss after your ranking (in the arena). Beating the boss in the IDE is a good indicator, but it’s sometime not enougth to be promoted. You may need to beat another people too.
Since i’m in wood league, the error output tell me that my code insn’t correct for the line 0 (strange) and sometimes for the line 28 (int nextCheckpointX = int.Parse(inputs[2]);
I tried to remove my code and to compile it with the starting code but the result is the same. when I put my code on visual studio there is no error, could you tell me if there is a particular reason or check if anithing is okay (with my code and yours) ?
error : “at Player.main on line 28”
my code :
`using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
/**
* This code automatically collects game data in an infinite loop.
* It uses the standard input to place data into the game variables such as x and y.
* YOU DO NOT NEED TO MODIFY THE INITIALIZATION OF THE GAME VARIABLES.
**/
class Player
{
static void Main(string[] args)
{
// game loop
while (true)
{
string[] inputs = Console.ReadLine().Split(' ');
//for (int i = 0; i < inputs.Length ; i++){
// Console.Error.WriteLine(inputs[i]);
//}
int x = int.Parse(inputs[0]); // x position of your pod
int y = int.Parse(inputs[1]); // y position of your pod
int nextCheckpointX = int.Parse(inputs[2]); // x position of the next check point
int nextCheckpointY = int.Parse(inputs[3]); // y position of the next check point
int nextCheckpointDist = int.Parse(inputs[4]);
int nextCheckpointAngle = int.Parse(inputs[5]);
Console.WriteLine(nextCheckpointX + " " + nextCheckpointY + " " + 100);
}
}
}
The collision is computed by the server running the game, so you will (almost) never receive a frame where pods are interpenetrating, as they will rebound before that.
You also receive a lot less frames than the viewer is showing. You need to pause and use the < and > buttons to get the exact inputs you are receiving.
It would be very unusual for 2 pods to be touching at the exact moment that the turn ends. Most collisions happen in between turns.
For a detailed description of how to detect collisions, check out Magus’s writeup. It should be linked on the entry page for the game.
If you’d prefer to come up with the code yourself, the general method is to predict what time (or fraction of a turn) the collision will occur and back-calculate the positions from there. Brush up on your trig
Hi,
I’m testing game functionality to know its limits… just as to find the limit clock before game declare us inactive.
Although in explanation it’s spoke about 1s for first execution, I constate it’s less than 1s…
So I try to find the real time… but understand after several test I flood your calculator thanks a warning message
Could we have a more accurate delay?
Sorry if I continue to flood your calculator during next times until I find the limit delay
Have a nice day
Hello you can help me on my code in javascript I’m stuck on the strick back part you will find my code below
let isStart = true
// game loop
while (true) {
let inputs = readline().split(' ');
const x = parseInt(inputs[0]);
const y = parseInt(inputs[1]);
const nextCheckpointX = parseInt(inputs[2]); // x position of the next check point
const nextCheckpointY = parseInt(inputs[3]); // y position of the next check point
const nextCheckpointDist = parseInt(inputs[4]); // distance to the next checkpoint
const nextCheckpointAngle = parseInt(inputs[5]); // angle between your pod orientation and the direction of the next checkpoint
let input = readline().split(' ');
const opponentX = parseInt(input[0]);
const opponentY = parseInt(input[1]);
let thrust = 100
if (isStart) {
thrust = "BOOST"
}
if (nextCheckpointAngle > 90 || nextCheckpointAngle < -90) {
thrust = 0
}
// You have to output the target position
// followed by the power (0 <= thrust <= 100)
// i.e.: "x y thrust"
print(nextCheckpointX + ' ' + nextCheckpointY + ' ' + thrust + ' ' + thrust);
isStart = false
}
Hi,
I’ve got a problem with the second exercise with the if statement on the thrust in Js.
When adding a space between the nexCheckpointY value and the thrust value, nextCheckpointX and Y become NaN. But when removing the space, it prints the right values.
Here is my code:
while (true) {
var inputs = readline().split(' ');
const x = parseInt(inputs[0]); // x position of your pod
const y = parseInt(inputs[1]); // y position of your pod
const nextCheckpointX = parseInt(inputs[2]); // x position of the next check point
const nextCheckpointY = parseInt(inputs[3]); // y position of the next check point
const nextCheckpointDist = parseInt(inputs[4]);
const nextCheckpointAngle = parseInt(inputs[5]);
let thrust = nextCheckpointAngle > 90 || nextCheckpointAngle < -90 ? 50 : 100;
console.log(nextCheckpointX + ' ' + nextCheckpointY + ' ' + thrust);
}
The checkpoint coordinates keep changing on each turn, and thus my pod never reaches its targets on time.
This is the replay: https://www.codingame.com/replay/404237456
The only change I made to the input was taking in the angle of the next checkpoint after the other four inputs. Please advise.