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

View File

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

View File

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

View File

@ -1,17 +1,17 @@
4
0 (2 0) (33.61 47.56)
1 (3 0) (11.28 52.68)
2 (0 1) (84.28 14.94)
3 (4 0) (50.30 85.67)
0 (1 2) (77.50 55.88)
1 (1 2) (54.26 37.50)
2 (1 2) (33.12 59.00)
3 (1 3) (74.02 24.62)
3
5 9
31714.314
S...035.6
31114.314
S...035.0
.E..25..0
.6..37115
.2175....
.0..31115
.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 STR_V: return 5;
case STR_H: return 10;
case STR_VB: return 5;
case STR_HB: return 10;
case TURN_NE: return 3;
case TURN_SE: return 6;
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) {
car* c = players[nPl].c;
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) {
car* c = players[nPl].c;
ptf prev = (ptf){.fx = c->pos.fx, .fy = c->pos.fy};
@ -373,26 +332,6 @@ bool updateCar(level* lvl, int nPl) {
updateChunk(lvl, nPl);
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:
addEnviroSpeed(nPl);
move_on_TURN(nPl, ROOM_SIZE, 0);

View File

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

View File

@ -365,18 +365,12 @@ void drawQuarterCircleToRenderer(SDL_Renderer * renderer, int32_t centreX, int32
++y;
error += ty;
ty += 2;
++y;
error += ty;
ty += 2;
}
if(error > 0) {
--x;
tx += 2;
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);
break;
case STR_VB:
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);
case TURN_NE:
break;
case STR_HB:
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,
(HEIGHT-rsize)/2+rsize*x+(int)(DIST_EDGE*rsize),
rsize,
rsize-(int)(2*DIST_EDGE*rsize),
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);
case TURN_SE:
break;
case TURN_SW:
break;
case TURN_NW:
break;
default:

View File

@ -134,12 +134,12 @@ void parse_all_players(level* lvl, char** execs) {
int main(int argc, char** argv) {
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);
}
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
noise = false;
printf("---------------------------\n");
@ -192,7 +192,7 @@ int main(int argc, char** argv) {
init_music();
// ---------------------------- //
//stage_file("levels/stage.txt");
level* stage = parse_level(argv[1+offsetP]);
level* stage = parse_level(argv[1]);
init_all(N_PLAYERS);
printf("\n");
path* pth = getPath(stage);
@ -304,5 +304,5 @@ TODO :
+ add hazards
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)
4 = BottomLeft (SW)
5 = TopLeft (NW)
6 = Vertical2
7 = Horizontal2
S = Start
E = End
*/
@ -72,10 +70,6 @@ road get_type(char c) {
return TURN_SW;
case '5':
return TURN_NW;
case '6':
return STR_VB;
case '7':
return STR_HB;
default:
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_Y = 0.0;
const double STR2_W = 0.2;
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, "%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, "\nRoom Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge, Magnetic Field, Slow zone Width");
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");
fclose(ptr);
}

View File

@ -43,7 +43,7 @@ typedef struct color_t {
} color;
// 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 {
int lines;
@ -87,8 +87,6 @@ extern const int HEIGHT;
extern const int ROOM_SIZE;
extern const int MAX_SPEED;
extern const double STR2_W;
extern int START_CHX;
extern int START_CHY;
extern int FINISH_CHX;

View File

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