Mad Pod Racing - Puzzle Discussion

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…

P

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.

Many thanks!

Piquet

what is the thrust value for boost? just want to use it to make calculations, too lazy to simulate…

I’m beating the boss easily in wood 1 league, yet it is not allowing me to advance to Bronze, why is this?

It’s said in gold, that

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.

Same for me…

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.

Hello there,

I’m using c#.

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);
           

        }
    }
}

thank’s

try to reset your code with the revolving arrow button at the top right of the IDE:
image

Even if you don’t use it, your code must read all the data given in the input stream.

1 Like

I progressed almost instantly :slight_smile:

So how collision really works? is it really 400 units force field, there is something more?

i’m using (C#):

distanceBetweenPods = Math.Sqrt((x - opponentX) * (x - opponentX) + (y -
opponentY) * (y - opponentY));

so with that line i will find the distance between the two pods right?

so i coded this to check if the pods collided (it’s 800 because the player’s pod shield and enemy pod’s field):

if (distanceBetweenPods <= 800){
collide = true;
}

In the simulation the pods collide but collide (variable) never became true.

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 :slight_smile:

1 Like

I often get this error (Javascript). What could be the reason?

    /usr/local/lib/nodejs/bin/node[1]: ../src/node_platform.cc:58:std::unique_ptr<long unsigned int> node::BackgroundTaskRunner::DelayedTaskScheduler::Start(): Assertion `(0) == (uv_thread_create(t.get(), start_thread, this))' failed.
 1: 0x8dc510 node::Abort() [/usr/local/lib/nodejs/bin/node]
 2: 0x8dc5e5  [/usr/local/lib/nodejs/bin/node]
 3: 0x965cba node::BackgroundTaskRunner::BackgroundTaskRunner(int) [/usr/local/lib/nodejs/bin/node]
 4: 0x965d6b node::NodePlatform::NodePlatform(int, node::tracing::TracingController*) [/usr/local/lib/nodejs/bin/node]
 5: 0x8e507b node::Start(int, char**) [/usr/local/lib/nodejs/bin/node]
 6: 0x7f2cc44d609b __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
 7: 0x89ed85  [/usr/local/lib/nodejs/bin/node]

replay/402674697

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 :sweat_smile:
Could we have a more accurate delay?
Sorry if I continue to flood your calculator during next times until I find the limit delay :blush:
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
}

// You have to output the target position
// followed by the power (0 <= thrust <= 100)
// i.e.: “x y thrust”

In your code sample you are printing twice the thrust

We have an issue with some languages on the platform. Check this thread: https://www.codingame.com/forum/t/java-random-error-occurred-during-initialization-of-vm/120354/5

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.