Compare commits

..

No commits in common. "20bdf01a008b23922eddf3046e0b3767410cb692" and "741f63e2afeecb615b9bf9b605400c3f4aa5dbb3" have entirely different histories.

16 changed files with 107 additions and 221 deletions

View File

@ -5,7 +5,7 @@ LFLAGS = -lSDL2 -lSDL2_image -lm
all: bin/back all: bin/back
replay: bin/back replay: bin/back
bin/back levels/test.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4 bin/back levels/test.txt REP bots/dumb bots/dumb2 bots/dumb3 bots/dumb4
testL: bin/back testL: bin/back
bin/back levels/test.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4 bots/dumb5 bots/dumb6 bin/back levels/test.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4 bots/dumb5 bots/dumb6

View File

@ -1 +1 @@
40 100 270 100

View File

@ -79,7 +79,6 @@ let trackDistance = read_float meta metai in (*
in other words, the width of the track is (except for start and finish) roomSize*(1-2*trackDistance) in other words, the width of the track is (except for start and finish) roomSize*(1-2*trackDistance)
*) *)
let magneticField = read_float meta metai in (* workd just like in induction : v ^ B is added to the speed each tick *) let magneticField = read_float meta metai in (* workd just like in induction : v ^ B is added to the speed each tick *)
let slowZoneWidth = read_float meta metai in (* slow area width (see schematic) *)
close_in file ; close_in file ;
(*Printf.printf "%d %d %d %f %f %f\n" roomSize maximumSpeed playerRadius friction restitutionFactor trackDistance ;;*) (*Printf.printf "%d %d %d %f %f %f\n" roomSize maximumSpeed playerRadius friction restitutionFactor trackDistance ;;*)

View File

@ -1,80 +1,68 @@
-126.965777 105.016079 -4.520035 -153.010954
178.506987 157.483510 21.769531 -238.471209
79.937093 241.211724 -19.987625 -241.204125
-160.774653 -38.383354 -19.500799 -168.039659
-167.593415 -29.904529 14.728318 -231.892620
-7.294048 -246.314004 -1.146169 -211.802657
1.925443 225.657331 160.346794 -12.942202
-83.767622 138.353905 14.734663 -229.843788
85.819605 202.420133 183.187726 -20.067243
82.714981 -146.254252 191.008872 -6.736352
-113.224829 -183.040838 170.348954 0.561499
-44.292231 239.426093 14.343889 -247.122293
73.408148 -201.606239 20.500323 190.947536
136.403228 78.074414 203.536940 20.430462
-118.750657 -212.011229 -16.283639 158.826220
-199.504334 -148.063798 238.344449 12.606080
-61.943425 -155.586957 177.328188 4.682923
-94.406224 124.392990 186.150359 3.312978
-118.474016 134.581478 156.149007 -14.652285
176.787805 -145.003525 -0.279201 226.257003
-0.963485 167.948868 155.454736 7.969019
-147.156717 -49.324155 -15.445195 -203.505108
124.324729 198.216477 154.883574 -19.965314
86.737908 -232.027331 2.886820 249.026500
-108.706596 116.156123 193.744106 9.469789
-111.198585 199.679652 224.583212 11.928862
4.233347 -154.343522 158.436164 -17.376616
53.134941 219.045650 -16.274097 -246.655139
52.531427 188.860283 201.930360 18.198730
199.759825 142.236295 211.031319 13.971414
-153.335297 33.127230 167.641503 2.279956
109.768908 -156.403842 240.821867 -1.488584
191.522197 69.161770 15.075325 169.095356
220.062526 70.577410 -7.630298 196.102117
41.550781 164.810963 -16.364244 182.033073
-48.473045 -144.188006 235.854636 -0.618213
-182.774442 -73.038390 -3.898845 151.466209
-49.452259 -244.218394 11.772678 255.408435
-13.630715 162.124555 14.850871 172.844069
39.864674 150.674710 -18.121169 196.343427
-188.697044 -71.996776 -159.980078 -16.452435
209.144759 -94.677939 -1.103776 223.906609
68.331180 -148.688378 -164.136493 2.665638
-152.071067 -16.616042 -188.419881 11.708277
27.734569 244.386576 -168.416232 3.726386
23.194074 224.207761 -246.001750 26.159777
-121.424647 -99.335541 -162.864443 -16.413678
-81.004541 -144.285027 -185.432804 -17.595811
-54.705548 197.298754 10.500652 172.253365
-158.456711 185.805850 -246.953352 -25.972959
-195.595346 53.989574 2.389557 169.349638
155.441325 -30.768053 11.802635 177.146925
131.351333 -190.332676 -150.628957 1.655484
151.633615 -144.272948 -21.620570 212.484655
-215.382455 100.160594 -174.943953 17.815758
-16.877039 150.231786 10.246061 250.882924
-244.040463 41.574689 -159.806539 11.576918
-30.789249 -164.256939 -230.847475 -27.358011
243.535105 -70.333548 -156.905847 -16.074234
-123.309534 -93.410730 -232.901653 13.792754
141.183147 198.054222 -13.141665 -171.881205
111.648590 -121.110859 17.978969 -168.541785
159.960839 119.300008 10.998418 -163.890031
152.093937 -56.629404 -226.053584 27.174607
117.736144 -192.205400 19.537432 -182.302590
-67.552365 143.397390 0.707694 -182.975442
-144.829862 55.225338 -25.737269 -245.385320
137.854776 73.989149 -22.985682 -253.425572
107.712460 -220.424780
-72.295537 -188.604800
-157.285398 158.442411
18.084724 166.016643
-4.225048 204.566741
202.324807 -62.010358
-119.442761 208.986514
-116.518561 -106.891697
-52.721865 -192.322387
-124.217802 -133.451340
191.087537 -159.194411
127.328099 107.726608

View File

@ -5,7 +5,7 @@ name, elo
./bots/dumb4 1466 ./bots/dumb4 1466
./bots/dumb5 540 ./bots/dumb5 540
./bots/dumb6 562 ./bots/dumb6 562
./bots/follow1 657 ./bots/follow1 616
./bots/follow2 726 ./bots/follow2 702
./bots/follow3 652 ./bots/follow3 641
./bots/follow4 671 ./bots/follow4 617

View File

@ -1,9 +1,9 @@
5 9 5 9
31714.314 31114.314
S...035.6 S...035.0
.E..25..0 .E..25..0
.6..37115 .0..31115
.2175.... .2115....
$ $
. = NULL . = NULL

View File

@ -1,17 +1,17 @@
4 4
0 (2 0) (33.61 47.56) 0 (1 2) (77.50 55.88)
1 (3 0) (11.28 52.68) 1 (1 2) (54.26 37.50)
2 (0 1) (84.28 14.94) 2 (1 2) (33.12 59.00)
3 (4 0) (50.30 85.67) 3 (1 3) (74.02 24.62)
3 3
5 9 5 9
31714.314 31114.314
S...035.6 S...035.0
.E..25..0 .E..25..0
.6..37115 .0..31115
.2175.... .2115....
100 200 5 0.90 0.80 0.20 0.00 0.20 100 200 5 0.90 0.80 0.20 0.00
Room Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge, Magnetic Field, Slow zone Width Room Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge, Magnetic Field

View File

@ -91,8 +91,6 @@ int return_directions(road r) {
case END: return 15; case END: return 15;
case STR_V: return 5; case STR_V: return 5;
case STR_H: return 10; case STR_H: return 10;
case STR_VB: return 5;
case STR_HB: return 10;
case TURN_NE: return 3; case TURN_NE: return 3;
case TURN_SE: return 6; case TURN_SE: return 6;
case TURN_SW: return 12; case TURN_SW: return 12;

View File

@ -138,27 +138,6 @@ void move_on_STR_V(int nPl) {
} }
} }
double absf(double x) {return (x<0.0)?(-x):(x);}
void move_on_STR_VB(int nPl) {
car* c = players[nPl].c;
c->pos.fx += c->vel.fx*DT;
c->pos.fy += c->vel.fy*DT;
if(c->pos.fx-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fx < 0.0) { // left wall
c->vel.fx *= -1.0;
c->pos.fx += 2.0*c->vel.fx*DT;
c->vel.fx *= RESTITUTION_WALL;
}
if(c->pos.fx+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fx > 0.0) { // right wall
c->vel.fx *= -1.0;
c->pos.fx += 2.0*c->vel.fx*DT;
c->vel.fx *= RESTITUTION_WALL;
}
if(absf(c->pos.fx - 0.5*ROOM_SIZE) < ROOM_SIZE*STR2_W/2.0) { // middle area
apply_friction(nPl);
apply_friction(nPl);
}
}
void move_on_STR_H(int nPl) { void move_on_STR_H(int nPl) {
car* c = players[nPl].c; car* c = players[nPl].c;
c->pos.fx += c->vel.fx*DT; c->pos.fx += c->vel.fx*DT;
@ -175,26 +154,6 @@ void move_on_STR_H(int nPl) {
} }
} }
void move_on_STR_HB(int nPl) {
car* c = players[nPl].c;
c->pos.fx += c->vel.fx*DT;
c->pos.fy += c->vel.fy*DT;
if(c->pos.fy-PLAYER_R <= ROOM_SIZE*DIST_EDGE && c->vel.fy < 0.0) { // top wall
c->vel.fy *= -1.0;
c->pos.fy += 2.0*c->vel.fy*DT;
c->vel.fy *= RESTITUTION_WALL;
}
if(c->pos.fy+PLAYER_R >= ROOM_SIZE*(1.0-DIST_EDGE) && c->vel.fy > 0.0) { // bottom wall
c->vel.fy *= -1.0;
c->pos.fy += 2.0*c->vel.fy*DT;
c->vel.fy *= RESTITUTION_WALL;
}
if(absf(c->pos.fy - 0.5*ROOM_SIZE) < ROOM_SIZE*STR2_W/2.0) { // middle area
apply_friction(nPl);
apply_friction(nPl);
}
}
void move_on_TURN(int nPl, int cenX, int cenY) { void move_on_TURN(int nPl, int cenX, int cenY) {
car* c = players[nPl].c; car* c = players[nPl].c;
ptf prev = (ptf){.fx = c->pos.fx, .fy = c->pos.fy}; ptf prev = (ptf){.fx = c->pos.fx, .fy = c->pos.fy};
@ -372,26 +331,6 @@ bool updateCar(level* lvl, int nPl) {
apply_friction(nPl); apply_friction(nPl);
updateChunk(lvl, nPl); updateChunk(lvl, nPl);
return true; return true;
case STR_VB:
addEnviroSpeed(nPl);
move_on_STR_VB(nPl);
removeEnviroSpeed(nPl);
bumpOtherCars(nPl);
apply_friction(nPl);
updateChunk(lvl, nPl);
return true;
case STR_HB:
addEnviroSpeed(nPl);
move_on_STR_HB(nPl);
removeEnviroSpeed(nPl);
bumpOtherCars(nPl);
apply_friction(nPl);
updateChunk(lvl, nPl);
return true;
case TURN_NE: case TURN_NE:
addEnviroSpeed(nPl); addEnviroSpeed(nPl);

View File

@ -4,6 +4,4 @@
bool updateCars(level* lvl); bool updateCars(level* lvl);
void updateWins(int* ranks); void updateWins(int* ranks);
void apply_friction(int nPl);
#endif #endif

View File

@ -365,18 +365,12 @@ void drawQuarterCircleToRenderer(SDL_Renderer * renderer, int32_t centreX, int32
++y; ++y;
error += ty; error += ty;
ty += 2; ty += 2;
++y;
error += ty;
ty += 2;
} }
if(error > 0) { if(error > 0) {
--x; --x;
tx += 2; tx += 2;
error += (tx - diameter); error += (tx - diameter);
--x;
tx += 2;
error += (tx - diameter);
} }
} }
} }
@ -429,36 +423,16 @@ void renderStraights(SDL_Renderer* renderer, level* lvl, int cx, int cy, int ran
64, 64, 64, 255); 64, 64, 64, 255);
break; break;
case STR_VB: case TURN_NE:
placeRectToRenderer(renderer, (WIDTH-rsize)/2+rsize*y, (HEIGHT-rsize)/2+rsize*x, rsize, rsize, 0, 0, 0, 255);
placeRectToRenderer(renderer,
(WIDTH-rsize)/2+rsize*y+(int)(DIST_EDGE*rsize),
(HEIGHT-rsize)/2+rsize*x,
rsize-(int)(2*DIST_EDGE*rsize),
rsize,
64, 64, 64, 255);
placeRectToRenderer(renderer,
(WIDTH-rsize)/2+rsize*y+(int)((1.0-STR2_W)/2.0*rsize),
(HEIGHT-rsize)/2+rsize*x,
(int)(STR2_W*rsize),
rsize,
64, 0, 0, 255);
break; break;
case STR_HB: case TURN_SE:
placeRectToRenderer(renderer, (WIDTH-rsize)/2+rsize*y, (HEIGHT-rsize)/2+rsize*x, rsize, rsize, 0, 0, 0, 255); break;
placeRectToRenderer(renderer,
(WIDTH-rsize)/2+rsize*y, case TURN_SW:
(HEIGHT-rsize)/2+rsize*x+(int)(DIST_EDGE*rsize), break;
rsize,
rsize-(int)(2*DIST_EDGE*rsize), case TURN_NW:
64, 64, 64, 255);
placeRectToRenderer(renderer,
(WIDTH-rsize)/2+rsize*y,
(HEIGHT-rsize)/2+rsize*x+(int)((1.0-STR2_W)/2.0*rsize),
rsize,
(int)(STR2_W*rsize),
64, 0, 0, 255);
break; break;
default: default:

View File

@ -134,12 +134,12 @@ void parse_all_players(level* lvl, char** execs) {
int main(int argc, char** argv) { int main(int argc, char** argv) {
if(argc < 2) { if(argc < 2) {
fprintf(stderr, "usage : ./back ?<-R> <level_path> <P1 executable> <P2 executable> ...\n"); fprintf(stderr, "usage : ./back <level_path> <P1 executable> <P2 executable> ...\n");
exit(1); exit(1);
} }
int offsetP = 0; int offsetP = 0;
if(argv[1+offsetP][0] == '-' && argv[1+offsetP][1] == 'R' && argv[1+offsetP][2] == '\0') { if(argv[2][0] == 'R' && argv[2][1] == 'E' && argv[2][2] == 'P' && argv[2][3] == '\0') {
// replay mode // replay mode
noise = false; noise = false;
printf("---------------------------\n"); printf("---------------------------\n");
@ -192,7 +192,7 @@ int main(int argc, char** argv) {
init_music(); init_music();
// ---------------------------- // // ---------------------------- //
//stage_file("levels/stage.txt"); //stage_file("levels/stage.txt");
level* stage = parse_level(argv[1+offsetP]); level* stage = parse_level(argv[1]);
init_all(N_PLAYERS); init_all(N_PLAYERS);
printf("\n"); printf("\n");
path* pth = getPath(stage); path* pth = getPath(stage);
@ -304,5 +304,5 @@ TODO :
+ add hazards + add hazards
KNOWN ISSUES : KNOWN ISSUES :
- / - car can sometimes clip into walls (rare, seems turn-related)
*/ */

View File

@ -47,8 +47,6 @@ int read_int(FILE* ptr) {
3 = BottomRight (SE) 3 = BottomRight (SE)
4 = BottomLeft (SW) 4 = BottomLeft (SW)
5 = TopLeft (NW) 5 = TopLeft (NW)
6 = Vertical2
7 = Horizontal2
S = Start S = Start
E = End E = End
*/ */
@ -72,10 +70,6 @@ road get_type(char c) {
return TURN_SW; return TURN_SW;
case '5': case '5':
return TURN_NW; return TURN_NW;
case '6':
return STR_VB;
case '7':
return STR_HB;
default: default:
fprintf(stderr, "unrecognized character '%c' encountered in parsing", c); fprintf(stderr, "unrecognized character '%c' encountered in parsing", c);

View File

@ -33,8 +33,6 @@ const double DELTA_THETA = 7.0; // degrees
const double WIND_X = 0.0; const double WIND_X = 0.0;
const double WIND_Y = 0.0; const double WIND_Y = 0.0;
const double STR2_W = 0.2;
double B = 0.0; // 0.6 works fine double B = 0.0; // 0.6 works fine
// ------------------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------------------ //
@ -70,8 +68,8 @@ void write_output(char* stream, level* lvl, int nPl) {
fprintf(ptr, "\n"); fprintf(ptr, "\n");
} }
fprintf(ptr, "\n"); fprintf(ptr, "\n");
fprintf(ptr, "%d %d %d %.2lf %.2lf %.2lf %.2lf %.2lf\n", ROOM_SIZE, MAX_SPEED, PLAYER_R, FRICTION, RESTITUTION_WALL, DIST_EDGE, B, STR2_W); fprintf(ptr, "%d %d %d %.2lf %.2lf %.2lf %.2lf\n", ROOM_SIZE, MAX_SPEED, PLAYER_R, FRICTION, RESTITUTION_WALL, DIST_EDGE, B);
fprintf(ptr, "\nRoom Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge, Magnetic Field, Slow zone Width"); fprintf(ptr, "\nRoom Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge, Magnetic Field");
fclose(ptr); fclose(ptr);
} }

View File

@ -43,7 +43,7 @@ typedef struct color_t {
} color; } color;
// one chunk // one chunk
typedef enum road_t {NONE, START, END, STR_V, STR_H, TURN_NE, TURN_SE, TURN_SW, TURN_NW, STR_VB, STR_HB} road; typedef enum road_t {NONE, START, END, STR_V, STR_H, TURN_NE, TURN_SE, TURN_SW, TURN_NW} road;
typedef struct level_t { typedef struct level_t {
int lines; int lines;
@ -87,8 +87,6 @@ extern const int HEIGHT;
extern const int ROOM_SIZE; extern const int ROOM_SIZE;
extern const int MAX_SPEED; extern const int MAX_SPEED;
extern const double STR2_W;
extern int START_CHX; extern int START_CHX;
extern int START_CHY; extern int START_CHY;
extern int FINISH_CHX; extern int FINISH_CHX;

View File

@ -5,7 +5,7 @@ name, elo
./bots/dumb4 1466 ./bots/dumb4 1466
./bots/dumb5 540 ./bots/dumb5 540
./bots/dumb6 562 ./bots/dumb6 562
./bots/follow1 657 ./bots/follow1 616
./bots/follow2 726 ./bots/follow2 702
./bots/follow3 652 ./bots/follow3 641
./bots/follow4 671 ./bots/follow4 617