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