added magnetic field
This commit is contained in:
parent
5f56e91549
commit
b9401698e3
|
@ -78,6 +78,7 @@ let trackDistance = read_float meta metai in (*
|
||||||
float (between 0.0 and 0.5) - this is the width of the black area on both side of the tracks
|
float (between 0.0 and 0.5) - this is the width of the black area on both side of the tracks
|
||||||
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 *)
|
||||||
|
|
||||||
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 ;;*)
|
||||||
|
|
BIN
bots/follow.cmi
BIN
bots/follow.cmi
Binary file not shown.
BIN
bots/follow.cmx
BIN
bots/follow.cmx
Binary file not shown.
|
@ -81,6 +81,7 @@ let trackDistance = read_float meta metai in (*
|
||||||
float (between 0.0 and 0.5) - this is the width of the black area on both side of the tracks
|
float (between 0.0 and 0.5) - this is the width of the black area on both side of the tracks
|
||||||
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 *)
|
||||||
|
|
||||||
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 ;;*)
|
||||||
|
|
BIN
bots/follow.o
BIN
bots/follow.o
Binary file not shown.
BIN
bots/follow1
BIN
bots/follow1
Binary file not shown.
BIN
bots/follow2
BIN
bots/follow2
Binary file not shown.
BIN
bots/follow3
BIN
bots/follow3
Binary file not shown.
BIN
bots/follow4
BIN
bots/follow4
Binary file not shown.
135
lastActions.txt
135
lastActions.txt
|
@ -1,67 +1,68 @@
|
||||||
15.283312 -168.132427
|
-18.422713 -176.076801
|
||||||
-3.875293 -217.394574
|
-7.020887 -230.177778
|
||||||
-2.300064 -222.591425
|
-4.520750 -219.581399
|
||||||
-15.045042 -169.714650
|
-4.463651 -166.253025
|
||||||
1.082855 -227.095122
|
185.488698 -20.745149
|
||||||
178.596429 21.737178
|
194.457151 -12.645542
|
||||||
-4.391650 -207.233032
|
15.536898 -214.021351
|
||||||
-12.266175 -227.148929
|
-14.661352 -229.591860
|
||||||
-16.871035 -209.846368
|
169.429180 -12.357431
|
||||||
187.346942 6.343882
|
205.176534 -25.599484
|
||||||
201.031828 14.624638
|
-11.796178 -230.418216
|
||||||
20.884507 -226.513802
|
24.377212 -213.365001
|
||||||
-23.428113 -219.487861
|
17.041185 179.830947
|
||||||
6.668101 177.977553
|
190.815708 20.580724
|
||||||
-8.282273 188.856052
|
189.314747 -12.899597
|
||||||
-8.118353 -220.432417
|
-11.629750 -211.150224
|
||||||
214.969311 8.139475
|
12.337279 -173.726717
|
||||||
-20.975506 -163.732759
|
0.000254 184.344335
|
||||||
19.505170 178.521445
|
-10.038741 198.842165
|
||||||
14.059300 -208.287419
|
5.666371 -213.933822
|
||||||
-13.582572 202.643783
|
-14.627645 -168.695567
|
||||||
165.257843 -14.161400
|
-14.523843 -173.186164
|
||||||
183.897469 2.030179
|
-16.809179 199.152874
|
||||||
232.650472 20.227691
|
5.907002 -211.095601
|
||||||
-8.214584 205.892621
|
-18.909848 -167.973241
|
||||||
184.797474 15.493847
|
19.054749 -163.897611
|
||||||
186.741640 -16.724432
|
7.139926 207.663326
|
||||||
20.334129 231.449697
|
0.272239 -224.970670
|
||||||
-15.194962 -197.016532
|
187.598498 16.404734
|
||||||
185.222560 20.876855
|
179.769347 -16.771815
|
||||||
164.962028 0.223672
|
-19.361183 -196.079116
|
||||||
-10.536891 227.902529
|
215.692477 -3.667610
|
||||||
-2.041096 -197.446820
|
15.616109 -189.003404
|
||||||
209.887356 -11.992982
|
-17.531907 182.190821
|
||||||
0.000248 165.684814
|
17.989057 -190.400513
|
||||||
23.335144 -220.548384
|
-9.511825 234.189681
|
||||||
192.922489 17.561281
|
199.192961 2.734451
|
||||||
218.486970 5.907496
|
-186.307904 17.161294
|
||||||
18.563320 169.000059
|
186.595470 -24.932493
|
||||||
-8.025218 -216.899723
|
210.766575 -27.416865
|
||||||
-19.987451 203.963417
|
220.868582 6.016359
|
||||||
220.426775 -11.794697
|
-163.798702 17.955681
|
||||||
-184.439240 -5.946276
|
14.836006 182.767932
|
||||||
202.999492 3.017057
|
216.437004 25.342977
|
||||||
-197.157589 5.350030
|
18.276022 217.322325
|
||||||
-19.131913 211.412648
|
-183.591585 -21.481311
|
||||||
-177.314902 -0.421059
|
-194.045676 -0.224849
|
||||||
8.650374 216.687713
|
234.467865 14.146990
|
||||||
-211.519919 -4.182964
|
-213.300653 -11.066723
|
||||||
-225.827554 19.255477
|
-180.329256 13.394246
|
||||||
-186.604445 -0.413666
|
-197.220384 -8.255668
|
||||||
-220.995867 1.579061
|
6.316474 208.755529
|
||||||
-196.286611 3.300536
|
-206.630095 11.522920
|
||||||
-215.596596 15.150045
|
-185.564188 -4.332933
|
||||||
-177.279262 -8.471317
|
9.899927 180.108674
|
||||||
-221.220200 -17.991671
|
-232.050486 -21.155205
|
||||||
-212.905471 -21.910692
|
-201.660961 -14.888540
|
||||||
-207.860142 19.681900
|
-164.773539 -8.076386
|
||||||
-167.551422 7.668736
|
-188.455821 -3.786201
|
||||||
-224.129291 -8.870528
|
-217.261009 -4.470115
|
||||||
17.515601 -183.742930
|
-212.863197 -3.619766
|
||||||
-211.725099 11.037961
|
-7.006592 -177.015214
|
||||||
-9.316739 -175.104654
|
15.446748 -180.253797
|
||||||
8.854149 223.062188
|
-209.173837 20.790962
|
||||||
-0.000750 -194.960110
|
-204.436731 14.747903
|
||||||
-216.098329 0.274767
|
-229.235179 19.156590
|
||||||
17.444249 -210.184344
|
-6.343615 -186.631927
|
||||||
|
-3.893746 -229.179855
|
||||||
|
|
|
@ -5,7 +5,7 @@ name, elo
|
||||||
./bots/dumb4 1392
|
./bots/dumb4 1392
|
||||||
./bots/dumb5 540
|
./bots/dumb5 540
|
||||||
./bots/dumb6 562
|
./bots/dumb6 562
|
||||||
./bots/follow1 525
|
./bots/follow1 562
|
||||||
./bots/follow2 499
|
./bots/follow2 600
|
||||||
./bots/follow3 548
|
./bots/follow3 612
|
||||||
./bots/follow4 509
|
./bots/follow4 545
|
||||||
|
|
BIN
obj/base.o
BIN
obj/base.o
Binary file not shown.
BIN
obj/cars.o
BIN
obj/cars.o
Binary file not shown.
BIN
obj/collisions.o
BIN
obj/collisions.o
Binary file not shown.
BIN
obj/display.o
BIN
obj/display.o
Binary file not shown.
BIN
obj/main.o
BIN
obj/main.o
Binary file not shown.
BIN
obj/music.o
BIN
obj/music.o
Binary file not shown.
BIN
obj/rooms.o
BIN
obj/rooms.o
Binary file not shown.
BIN
obj/structure.o
BIN
obj/structure.o
Binary file not shown.
12
output.txt
12
output.txt
|
@ -1,8 +1,8 @@
|
||||||
4
|
4
|
||||||
0 (1 2) (74.74 30.15)
|
0 (1 3) (25.15 20.43)
|
||||||
1 (1 2) (64.27 43.70)
|
1 (1 2) (46.28 29.61)
|
||||||
2 (1 2) (41.29 41.90)
|
2 (1 2) (9.84 44.40)
|
||||||
3 (1 3) (74.08 81.17)
|
3 (1 4) (30.06 26.11)
|
||||||
3
|
3
|
||||||
|
|
||||||
5 9
|
5 9
|
||||||
|
@ -12,6 +12,6 @@ S...035.0
|
||||||
.0..31115
|
.0..31115
|
||||||
.2115....
|
.2115....
|
||||||
|
|
||||||
100 200 5 0.90 0.80 0.20
|
100 200 5 0.90 0.80 0.20 0.60
|
||||||
|
|
||||||
Room Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge,
|
Room Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge, Magnetic Field
|
|
@ -257,6 +257,31 @@ void apply_friction(int nPl) {
|
||||||
players[nPl].c->vel.fy *= (1.0 - FRICTION*DT);
|
players[nPl].c->vel.fy *= (1.0 - FRICTION*DT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double addVX = 0.0;
|
||||||
|
double addVY = 0.0;
|
||||||
|
void addEnviroSpeed(int nPl) {
|
||||||
|
car* c = players[nPl].c;
|
||||||
|
|
||||||
|
// Wind
|
||||||
|
if(WIND_X*WIND_X + WIND_Y*WIND_Y >= 0.001) {
|
||||||
|
c->vel.fx += WIND_X*DT;
|
||||||
|
c->vel.fx += WIND_Y*DT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// B
|
||||||
|
if(B > 0.001) {
|
||||||
|
addVX = c->vel.fy*B;
|
||||||
|
addVY = -c->vel.fx*B;
|
||||||
|
|
||||||
|
c->vel.fx += addVX*DT;
|
||||||
|
c->vel.fy += addVY*DT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeEnviroSpeed(int nPl) {
|
||||||
|
// no
|
||||||
|
}
|
||||||
|
|
||||||
// -- //
|
// -- //
|
||||||
|
|
||||||
// return true iif the car has moved
|
// return true iif the car has moved
|
||||||
|
@ -268,56 +293,80 @@ bool updateCar(level* lvl, int nPl) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case START:
|
case START:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_START(nPl);
|
move_on_START(nPl);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case END:
|
case END:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_FINISH(nPl);
|
move_on_FINISH(nPl);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case STR_V:
|
case STR_V:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_STR_V(nPl);
|
move_on_STR_V(nPl);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case STR_H:
|
case STR_H:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_STR_H(nPl);
|
move_on_STR_H(nPl);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case TURN_NE:
|
case TURN_NE:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_TURN(nPl, ROOM_SIZE, 0);
|
move_on_TURN(nPl, ROOM_SIZE, 0);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case TURN_NW:
|
case TURN_NW:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_TURN(nPl, 0, 0);
|
move_on_TURN(nPl, 0, 0);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case TURN_SE:
|
case TURN_SE:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_TURN(nPl, ROOM_SIZE, ROOM_SIZE);
|
move_on_TURN(nPl, ROOM_SIZE, ROOM_SIZE);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case TURN_SW:
|
case TURN_SW:
|
||||||
|
addEnviroSpeed(nPl);
|
||||||
move_on_TURN(nPl, 0, ROOM_SIZE);
|
move_on_TURN(nPl, 0, ROOM_SIZE);
|
||||||
|
removeEnviroSpeed(nPl);
|
||||||
|
|
||||||
bumpOtherCars(nPl);
|
bumpOtherCars(nPl);
|
||||||
apply_friction(nPl);
|
apply_friction(nPl);
|
||||||
updateChunk(lvl, nPl);
|
updateChunk(lvl, nPl);
|
||||||
|
|
|
@ -61,7 +61,7 @@ void cameraActions(level* lvl, bool* halt, int* cx, int* cy, int* dezoom, int* s
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_m:
|
case SDLK_m:
|
||||||
*dezoom = min(3, *dezoom+1);
|
*dezoom = min(5, *dezoom+1);
|
||||||
*sizeR = min(WIDTH, HEIGHT)/(2*(*dezoom)+1)+1;
|
*sizeR = min(WIDTH, HEIGHT)/(2*(*dezoom)+1)+1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -245,6 +245,7 @@ int main(int argc, char** argv) {
|
||||||
} else {
|
} else {
|
||||||
// no movement
|
// no movement
|
||||||
placeRectToRenderer(rend, 0, HEIGHT-50, 50, 50, 255, 32, 32, 192);
|
placeRectToRenderer(rend, 0, HEIGHT-50, 50, 50, 255, 32, 32, 192);
|
||||||
|
//B *= -1.0;
|
||||||
updateWins(ranks);
|
updateWins(ranks);
|
||||||
if(remainingTurns != 0)parse_all_players(stage, execs);
|
if(remainingTurns != 0)parse_all_players(stage, execs);
|
||||||
if(remainingTurns > 0) {
|
if(remainingTurns > 0) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ const int MAX_SPEED = 200; // m/s
|
||||||
const double DIST_EDGE = 0.2;
|
const double DIST_EDGE = 0.2;
|
||||||
const double START_EDGE = 0.05;
|
const double START_EDGE = 0.05;
|
||||||
const double RESTITUTION_WALL = 0.8;
|
const double RESTITUTION_WALL = 0.8;
|
||||||
const double RESTITUTION_PLAYER = 0.8; // keep equal to prevouis constant
|
const double RESTITUTION_PLAYER = 0.8; // keep equal to previous constant
|
||||||
|
|
||||||
const int PLAYER_R = 5;
|
const int PLAYER_R = 5;
|
||||||
const int MAX_THETA_SPAWN = 80; // degrees
|
const int MAX_THETA_SPAWN = 80; // degrees
|
||||||
|
@ -30,6 +30,11 @@ const double EPSILON = 1.0/4096.0;
|
||||||
const double DELTA_V = 7.0; // %
|
const double DELTA_V = 7.0; // %
|
||||||
const double DELTA_THETA = 7.0; // degrees
|
const double DELTA_THETA = 7.0; // degrees
|
||||||
|
|
||||||
|
const double WIND_X = 0.0;
|
||||||
|
const double WIND_Y = 0.0;
|
||||||
|
|
||||||
|
double B = 0.6; // 0.6 works fine
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------ //
|
// ------------------------------------------------------------------------------------------ //
|
||||||
|
|
||||||
void write_output(char* stream, level* lvl, int nPl) {
|
void write_output(char* stream, level* lvl, int nPl) {
|
||||||
|
@ -63,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\n", ROOM_SIZE, MAX_SPEED, PLAYER_R, FRICTION, RESTITUTION_WALL, DIST_EDGE);
|
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, ");
|
fprintf(ptr, "\nRoom Size, Maximum speed, Player Radius, Friction, Restitution factor, Track Distance to Edge, Magnetic Field");
|
||||||
fclose(ptr);
|
fclose(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,11 @@ extern double* remainingD;
|
||||||
extern double minRemD;
|
extern double minRemD;
|
||||||
extern double maxRemD;
|
extern double maxRemD;
|
||||||
|
|
||||||
|
extern const double WIND_X;
|
||||||
|
extern const double WIND_Y;
|
||||||
|
|
||||||
|
extern double B;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------------- //
|
||||||
|
|
||||||
void write_output(char* stream, level* lvl, int nPl);
|
void write_output(char* stream, level* lvl, int nPl);
|
||||||
|
|
|
@ -5,7 +5,7 @@ name, elo
|
||||||
./bots/dumb4 1392
|
./bots/dumb4 1392
|
||||||
./bots/dumb5 540
|
./bots/dumb5 540
|
||||||
./bots/dumb6 562
|
./bots/dumb6 562
|
||||||
./bots/follow1 525
|
./bots/follow1 562
|
||||||
./bots/follow2 499
|
./bots/follow2 600
|
||||||
./bots/follow3 548
|
./bots/follow3 612
|
||||||
./bots/follow4 509
|
./bots/follow4 545
|
||||||
|
|
Loading…
Reference in New Issue