Hi everyone,
How to find out the distance between aircraft and next checkpoint
I wrote this code to slow down my pod in the “Else” case, meaning:
I regulate the speed according to the angle:
- 0° → 100% power
- 90° → 10%
- 100° → 0% (braking)
thrust = max(0, 100 - abs(next_checkpoint_angle))
But right now, I don’t really know what to do in this challenge.
I’ve defeated Boss 4 several times, but my rank is still around 37K. ![]()
It means that one of the pod’s code has a bug in it, and if that is true, the race ends immediately.
its not that its off, its that it can be a negative value if it is on the other side. i would override the value you get with next check angle using absolute. in C++ its “next_checkpoint_angle = abs(next_checkpoint_angle)” this means im always working with a positive now and can ignore upper and lower range.
that would have been useful for me, really useful, but I left my code in wood 2, I unlocked boost, I left it, and when I came back the next day, I was gold, now I don´t know how to use shield and boost, and even less how to control 2 pods, I was like 1 hour correcting the inputs
I used PID, an absolute headache, I went from Wood to Gold the day after I started, now Im stuck, this is my code, my native language is spanish, thats why its in spanish,I hope its useful for you,as you can see, I used c++, ask me if you have any question:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
struct Vec {
double x, y;
Vec operator+(const Vec& otro) const {
return {x + otro.x, y + otro.y};
}
Vec operator-(const Vec& otro) const {
return {x - otro.x, y - otro.y};
}
Vec operator*(double escalar) const {
return {x * escalar, y * escalar};
}
double dist(const Vec& otro) const {
return sqrt(pow(x - otro.x, 2) + pow(y - otro.y, 2));
}
};
int main()
{
bool primer_turno = true;
Vec mi_pos_anterior = {0, 0};
while (1) {
int x, y, next_checkpoint_x, next_checkpoint_y, dist, angle;
cin >> x >> y >> next_checkpoint_x >> next_checkpoint_y >> dist >> angle; cin.ignore();
int opponent_x, opponent_y;
cin >> opponent_x >> opponent_y; cin.ignore();
Vec mi_pos = {(double)x, (double)y};
Vec objetivo = {(double)next_checkpoint_x, (double)next_checkpoint_y};
Vec mi_velocidad = {0, 0};
if (!primer_turno) {
mi_velocidad = mi_pos - mi_pos_anterior;
}
double K = 3.5;
Vec punto_compensado = objetivo - (mi_velocidad * K);
int thrust = 100;
if (abs(angle) > 90) {
thrust = 0;
}
cout << (int)punto_compensado.x << " " << (int)punto_compensado.y << " " << thrust << endl;
mi_pos_anterior = mi_pos;
primer_turno = false;
}
}
good catch There is a typo in the Wood 2 hint: thurst should be thrust
hi, i’m new and programming on js, however i don’t find how to use the boost ;-;
Please check out the previous answers on the same question.
I need help changing the thrust how do I do it?it confuses me a lot and it is on the 1st boss in the first level of the ai coding thing
can some one tell me?
You’re in Wood 2 League now, so you’ve beaten the 1st boss in the earlier league already.
Coding Games and Programming Challenges to Code Better how could I possibly use this to my advantage? winning by timeout xD