Mad Pod Racing - Puzzle Discussion

Hello,
I have a code with import time who doesn’t work:

import sys

import math

import time

Auto-generated code below aims at helping you parse

the standard input according to the problem statement.

t0 =0

enVirage = False

#game loop

while True:

# next_checkpoint_x: x position of the next check point

# next_checkpoint_y: y position of the next check point

# next_checkpoint_dist: distance to the next checkpoint

# next_checkpoint_angle: angle between your pod orientation and the direction of the next checkpoint

x, y, next_checkpoint_x, next_checkpoint_y, next_checkpoint_dist, next_checkpoint_angle = [int(i) for i in input().split()]

opponent_x, opponent_y = [int(i) for i in input().split()]

# Write an action using print

# To debug: print("Debug messages...", file=sys.stderr, flush=True)

# You have to output the target position

# followed by the power (0 <= thrust <= 100)

# i.e.: "x y thrust"

if next_checkpoint_dist>1000:

    accel = 100

    enVirage = False

    accel =int(accel - next_checkpoint_angle/3)

   

elif next_checkpoint_dist<2000:

    accel = int(next_checkpoint_dist/2000*100)

    accel =int(accel - next_checkpoint_angle/3.5)

    enVirage = True

    to = int(time.time())

***************** here the while never happens ******************************

    while ( time.time()-t0< 2.0  ):

        accel= 40

        print(str(next_checkpoint_x) + " " + str(next_checkpoint_y) + " " +str(accel))

if (accel <= 0):

    accel = 0

elif (accel>100):

    accel = 100
print(str(next_checkpoint_x) + " " + str(next_checkpoint_y) + " " +str(accel))

Would you please edit your message and format your code properly by using the </> button in the toolbar? We aren’t able to read your code easily in the present state.

Also, which league are you in?

I’m in wood 2 league .
i’ve tihs code but he doesn’t work

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/


// game loop
while (true) {
    var 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
    var inputs = readline().split(' ');
    const opponentX = parseInt(inputs[0]);
    const opponentY = parseInt(inputs[1]);

    // Write an action using console.log()
    // To debug: console.error('Debug messages...');


    // You have to output the target position
    // followed by the power (0 <= thrust <= 100)
    // i.e.: "x y thrust"
    console.log(nextCheckpointX + ' ' + nextCheckpointY + '100');
    console.log(opponentX + ' ' + opponentY+ '100');
   
}

can somone help me

You should output (i.e. console.log) once per turn (i.e. once per while loop), not twice. Also make sure there is a space character before the thrust.

G’day all!

I’m in silver league, and can consistently place 1st/2nd but am having issues figuring out where to further refine my code.

Currently I’m using vector steering: my position + (checkpoint position-my next position),
BOOST if more than 5000, and angle to next checkpoint is less than 15 degrees,
Cut power and start turning to centre of map if <2500 of the objective and angle is less than 15 degrees.

It’s working really well, but without the next next checkpoint coordinates, I just can’t figure out where to further refine the code to drive better to get those extra couple of points to beat the boss and advance to gold. Any suggestions?

Have you tried this target: next checkpoint position - current pod’s velocity. Velocity isn’t provided, so you’d have to calculate your own from the positions.

1 Like

Checkpoint coordinates can be collected and stored during the first lap for later reuse.

I did that, yeah. made me cruise through bronze.
currently exploring with current heading vs ideal heading.

I attempted that, store it in an array.
I’m working in C, it timed out pretty quickly, maybe I need to go back and find a more efficient method of storing and calling the locations.

How to switch back to initial game conditions from the wood league? Without collisions and boost

Hi all, is it existing a way to solve the problem offline ? (i mean something like an simulator env.) Thanks !

You can’t go back in league. At best, you can create new account and try not to promote.
There is optimization puzzle search race, with similar physics that can be seen as single-player mad pod racing.

Hi all, is it existing a way to solve the problem offline ? (i mean something like an simulator env.) Thanks !

You can try cg brutaltester with coders strike back (former mad pod racing name) referee.

1 Like

Thank you for your answer !

Hello i have this error

Une erreur est survenue (#73) : "Only 1 executor running at the same time for a test session"

and cannot run my code anymore…
Any fix?

2 Likes

so i have a mammoth of a code and still cant get out of silver…

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
class Player
{
    static void Main(string[] args)
    {
        string[] inputs;

        int b = 100;
        int boost1 = 0;
        int boost2 = 0;

        int C1X = 0;
        int C2X = 0;
        int C3X = 0;
        int C4X = 0;
        int C5X = 0;
        int C6X = 0;
        int C7X = 0;
        int C8X = 0;
        int C9X = 0;
        int C10X = 0;

        int C1Y = 0;
        int C2Y = 0;
        int C3Y = 0;
        int C4Y = 0;
        int C5Y = 0;
        int C6Y = 0;
        int C7Y = 0;
        int C8Y = 0;
        int C9Y = 0;
        int C10Y = 0;

        int checkpoints = 0;
        string nextcheckpoint = "";
        bool checkpointhaschanged = false;
        bool assignedcheckpoint = false;
        bool allcheckpointsfound = false;
        int lastcheckpointx = 0;
        int lastcheckpointy = 0;
        double checkpointangle = 0;
        float cpanglepercentage = 0;
        int overnextcpx = 0;
        int overnextcpy = 0;

        int turndist = 0;

        int boost = 1;
        bool usedboost = false;

        int wasx = 600;
        int wasy = 200;
        double wasa = 90;
        int startup = 5;

        // game loop
        while (true)
        {
            inputs = Console.ReadLine().Split(' ');
            int x = int.Parse(inputs[0]);
            int y = int.Parse(inputs[1]);
            int ncx = int.Parse(inputs[2]); // x position of the next check point
            int ncy = int.Parse(inputs[3]); // y position of the next check point
            int ncd = int.Parse(inputs[4]); // distance to the next checkpoint
            int nca = int.Parse(inputs[5]); // angle between your pod orientation and the direction of the next checkpoint
            inputs = Console.ReadLine().Split(' ');
            int opx = int.Parse(inputs[0]);
            int opy = int.Parse(inputs[1]);

            b = 100;
            checkpointhaschanged = false;
            assignedcheckpoint = false;
            bool usedability = false;

            if (nextcheckpoint != (ncx+" "+ncy)){
                nextcheckpoint = ncx+" "+ncy;
                checkpointhaschanged = true;
                if (ncx == C1X && ncy == C1Y){
                    allcheckpointsfound = true;
                }
            }

            if (checkpointhaschanged == true){
                if (ncx != C1X && ncy != C1Y && allcheckpointsfound == false){
                    if (C1X == 0 && C1Y == 0){
                        checkpoints = 1;
                        C1X = ncx;
                        C1Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C2X == 0 && C2Y == 0){
                        checkpoints = 2;
                        C2X = ncx;
                        C2Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C3X == 0 && C3Y == 0){
                        checkpoints = 3;
                        C3X = ncx;
                        C3Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C4X == 0 && C4Y == 0){
                        checkpoints = 4;
                        C4X = ncx;
                        C4Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C5X == 0 && C5Y == 0){
                        checkpoints = 5;
                        C5X = ncx;
                        C5Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C6X == 0 && C6Y == 0){
                        checkpoints = 6;
                        C6X = ncx;
                        C6Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C7X == 0 && C7Y == 0){
                        checkpoints = 7;
                        C7X = ncx;
                        C7Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C8X == 0 && C8Y == 0){
                        checkpoints = 8;
                        C8X = ncx;
                        C8Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C9X == 0 && C9Y == 0){
                        checkpoints = 9;
                        C9X = ncx;
                        C9Y = ncy;
                        assignedcheckpoint = true;
                        
                    }
                    if (assignedcheckpoint==false && C10X == 0 && C10Y == 0){
                        checkpoints = 10;
                        C10X = ncx;
                        C10Y = ncy;
                        
                    }
                }
            }
            //------------------------------------------------------------------------------
            if (allcheckpointsfound == true){
                if (ncx == C1X && ncy == C1Y && checkpoints >= 1){
                    if (checkpoints == 2){
                        lastcheckpointx = C2X;
                        lastcheckpointy = C2Y;
                    }
                    if (checkpoints == 3){
                        lastcheckpointx = C3X;
                        lastcheckpointy = C3Y;
                    }
                    if (checkpoints == 4){
                        lastcheckpointx = C4X;
                        lastcheckpointy = C4Y;
                    }
                    if (checkpoints == 5){
                        lastcheckpointx = C5X;
                        lastcheckpointy = C5Y;
                    }
                    if (checkpoints == 6){
                        lastcheckpointx = C6X;
                        lastcheckpointy = C6Y;
                    }
                    if (checkpoints == 7){
                        lastcheckpointx = C7X;
                        lastcheckpointy = C7Y;
                    }
                    if (checkpoints == 8){
                        lastcheckpointx = C8X;
                        lastcheckpointy = C8Y;
                    }
                    if (checkpoints == 9){
                        lastcheckpointx = C9X;
                        lastcheckpointy = C9Y;
                    }
                    if (checkpoints == 10){
                        lastcheckpointx = C10X;
                        lastcheckpointy = C10Y;
                    }
                }
                if (ncx == C2X && ncy == C2Y && checkpoints >= 2){
                    lastcheckpointx = C1X;
                    lastcheckpointy = C1Y;
                }
                if (ncx == C3X && ncy == C3Y && checkpoints >= 3){
                    lastcheckpointx = C2X;
                    lastcheckpointy = C2Y;
                }
                if (ncx == C4X && ncy == C4Y && checkpoints >= 4){
                    lastcheckpointx = C3X;
                    lastcheckpointy = C3Y;
                }
                if (ncx == C5X && ncy == C5Y && checkpoints >= 5){
                    lastcheckpointx = C4X;
                    lastcheckpointy = C4Y;
                }
                if (ncx == C6X && ncy == C6Y && checkpoints >= 6){
                    lastcheckpointx = C5X;
                    lastcheckpointy = C5Y;
                }
                if (ncx == C7X && ncy == C7Y && checkpoints >= 7){
                    lastcheckpointx = C6X;
                    lastcheckpointy = C6Y;
                }
                if (ncx == C8X && ncy == C8Y && checkpoints >= 8){
                    lastcheckpointx = C7X;
                    lastcheckpointy = C7Y;
                }
                if (ncx == C9X && ncy == C9Y && checkpoints >= 9){
                    lastcheckpointx = C8X;
                    lastcheckpointy = C8Y;
                }
                if (ncx == C10X && ncy == C10Y && checkpoints >= 10){
                    lastcheckpointx = C9X;
                    lastcheckpointy = C9Y;
                }
                if (ncx == C1X && ncy == C1Y && checkpoints > 1){
                    overnextcpx = C2X;
                    overnextcpy = C2Y;
                }
                else if (ncx == C2X && ncy == C2Y && checkpoints > 2){
                    overnextcpx = C3X;
                    overnextcpy = C3Y;
                }
                else if (ncx == C3X && ncy == C3Y && checkpoints > 3){
                    overnextcpx = C4X;
                    overnextcpy = C4Y;
                }
                else if (ncx == C4X && ncy == C4Y && checkpoints > 4){
                    overnextcpx = C5X;
                    overnextcpy = C5Y;
                }
                else if (ncx == C5X && ncy == C5Y && checkpoints > 5){
                    overnextcpx = C6X;
                    overnextcpy = C6Y;
                }
                else if (ncx == C6X && ncy == C6Y && checkpoints > 6){
                    overnextcpx = C7X;
                    overnextcpy = C7Y;
                }
                else if (ncx == C7X && ncy == C7Y && checkpoints > 7){
                    overnextcpx = C8X;
                    overnextcpy = C8Y;
                }
                else if (ncx == C8X && ncy == C8Y && checkpoints > 8){
                    overnextcpx = C9X;
                    overnextcpy = C9Y;
                }
                else if (ncx == C9X && ncy == C9Y && checkpoints > 9){
                    overnextcpx = C10X;
                    overnextcpy = C10Y;
                }
                else{
                    overnextcpx = C1X;
                    overnextcpy = C1Y;
                }
                if (ncx == C10X && ncy == C10Y){
                    overnextcpx = C1X;
                    overnextcpy = C1Y;
                }

                double dif1to2x = x - ncx;
                if (dif1to2x<0) {dif1to2x = dif1to2x * -1;}

                double dif1to2y = y - ncy;
                if (dif1to2y<0) {dif1to2y = dif1to2y * -1;}

                double leng1to2 = Math.Sqrt((dif1to2x*dif1to2x)+(dif1to2y*dif1to2y));

                double dif1to3x = x - overnextcpx;
                if (dif1to3x<0) {dif1to3x = dif1to3x * -1;}

                double dif1to3y = y - overnextcpy;
                if (dif1to3y<0) {dif1to3y = dif1to3y * -1;}

                double leng1to3 = Math.Sqrt((dif1to3x*dif1to3x)+(dif1to3y*dif1to3y));

                double dif2to3x = ncx - overnextcpx;
                if (dif2to3x<0) {dif2to3x = dif2to3x * -1;}

                double dif2to3y = ncy - overnextcpy;
                if (dif2to3y<0) {dif2to3y = dif2to3y * -1;}

                double leng2to3 = Math.Sqrt((dif2to3x*dif2to3x)+(dif2to3y*dif2to3y));

                double a1 = 0-((leng1to3*leng1to3)/(2*leng2to3*leng1to2));
                double a2 = (leng2to3/(2*leng1to2));
                double a3 = (leng1to2/(2*leng2to3));

                checkpointangle = Math.Acos(a1+a2+a3);

                if (checkpointangle > 180){
                    checkpointangle = 180-(checkpointangle-180);
                }
                cpanglepercentage = (float)(checkpointangle/1.8);
                Console.Error.WriteLine("checkpointangle= "+((int)(checkpointangle*100)).ToString());
                Console.Error.WriteLine("cpanglepercentage= "+((int)(cpanglepercentage*100)).ToString());
                dif1to2x = lastcheckpointx - ncx;
                if (dif1to2x<0) {dif1to2x = dif1to2x * -1;}
                dif1to2y = lastcheckpointy - ncy;
                if (dif1to2y<0) {dif1to2y = dif1to2y * -1;}
                leng1to2 = Math.Sqrt((dif1to2x*dif1to2x)+(dif1to2y*dif1to2y));
                turndist = (int)(leng1to2 * (cpanglepercentage/100));

                double a1x = lastcheckpointx - ncx;
                if (a1x<0) {a1x=a1x*-1;}

                double a1y = lastcheckpointy - ncy;
                if (a1y<0) {a1y=a1y*-1;}

                double c1 = Math.Sqrt((a1x*a1x)+(a1y*a1y));
                Console.Error.WriteLine("between last and me= "+c1.ToString());

                double b1x = x - ncx;
                if (b1x<0) {b1x=b1x*-1;}

                double b1y = y - ncy;
                if (b1y<0) {b1y=b1y*-1;}

                double a12 = Math.Sqrt((b1x*b1x)+(b1y*b1y));
                Console.Error.WriteLine("between next and last= "+a12.ToString());

                double c1x = lastcheckpointx - x;
                if (c1x<0){c1x=c1x*-1;}

                double c1y = lastcheckpointy - y;
                if (c1y<0){c1y=c1y*-1;}

                double b1 = Math.Sqrt((c1x*c1x)+(c1y*c1y));
                Console.Error.WriteLine("between me and next= "+b1.ToString());

                double a23 = 0-((a12*a12)/(2*b1*c1));
                double b2 = (b1/(2*c1));
                double c2 = (c1/(2*b1));

                wasa = Math.Acos(a23+b2+c2);
                if (wasa>180){
                    wasa = 180-(wasa-180);
                }
                Console.Error.WriteLine("wasa= "+wasa.ToString());
            }
            Console.Error.WriteLine("Last cp= "+lastcheckpointx.ToString()+" "+lastcheckpointy.ToString());
            Console.Error.WriteLine("next cp= "+ncx.ToString()+" "+ncy.ToString());
            Console.Error.WriteLine("overnext cp= "+overnextcpx.ToString()+" "+overnextcpy.ToString());
            // Write an action using Console.WriteLine()
            // To debug: Console.Error.WriteLine(""+.ToString());


            // you have to output the target position
            // followed by the power (0 <= thrust <= 100) or "BOOST" or "SHIELD"
            // i.e.: "x y thrust"
            if (allcheckpointsfound == true){
                Console.Error.WriteLine("turn dist= "+turndist.ToString());
                if (turndist < 0){
                    turndist = turndist * -1;
                }
                turndist = turndist * 50;
                if (turndist > 2000){
                    turndist = 2000;
                }
                if (ncd<turndist){
                    ncx = overnextcpx;
                    ncy = overnextcpy;
                }
            }
            if (startup==0){
                //b = (int)(100-(wasa/1.8));
                b = 100-((nca/180)*100);
                Console.Error.WriteLine("boost= "+b.ToString());
                if (b<0){b=b*-1;}
                Console.Error.WriteLine("boost= "+b.ToString());
            }
            if (b>90){
                b=100;
            }
            Console.Error.WriteLine("boost= "+b.ToString());
            if (startup>0){
                b=100;
                startup=startup-1;
            }
            if (nca == 0 && ncd > 3500 && allcheckpointsfound == true && boost == 1){
                Console.WriteLine(ncx + " " + ncy + " BOOST");
                boost = 0;
                usedability = true;
                usedboost = true;
            }
            if (usedability == false){
                Console.WriteLine(ncx + " " + ncy + " " + b.ToString());
            }
            Console.Error.WriteLine("Checkpoints= "+checkpoints.ToString());
            Console.Error.WriteLine("allcheckpointsfound? "+allcheckpointsfound.ToString());
            Console.Error.WriteLine("boost= "+b.ToString());
            Console.Error.WriteLine("turn dist= "+turndist.ToString());
            Console.Error.WriteLine("usedboost? "+usedboost.ToString());
            wasx = x;
            wasy = y;
        }
    }
}

pls someone help

Hi, I have a little question about this game. Excuse me, this racing game first pass how. However, I’m using ‘Python’ thank you

Have you followed the interactive tutorial when you first start the game? If so, do you think you have fixed the issue in the code as highlighted during the tutorial?

did you get the answer ? i’m still stuck int the same level

Hey, I am stuck in bronze league and I don’t know how to proceed from here so can anyone help me how can I solve this.

Hey, I am stuck in bronze league and I don’t know how to proceed from here so can anyone help me in this how to solve this and go to next.