added oneAtATime mode (turn based)

This commit is contained in:
Alexandre 2025-06-07 21:59:40 +02:00
parent 7f59d725b7
commit de1a6b42c9
16 changed files with 74 additions and 33 deletions

View File

@ -11,7 +11,7 @@ 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
test: bin/back test: bin/back
bin/back levels/long.txt bots/follow1 bots/follow2 bots/follow3 bots/follow4 bin/back levels/test.txt bots/follow1 bots/follow2 bots/follow3 bots/dumb4
ez: bin/back ez: bin/back
bin/back levels/simple.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4 bin/back levels/simple.txt bots/dumb bots/dumb2 bots/dumb3 bots/dumb4

View File

@ -1 +1 @@
154 100 0 100

View File

@ -103,6 +103,8 @@ let getDirs = function
| '3' -> 6 | '3' -> 6
| '4' -> 12 | '4' -> 12
| '5' -> 9 | '5' -> 9
| '6' -> 5
| '7' -> 10
| 'S' -> 15 | 'S' -> 15
| _ -> 0 | _ -> 0
in in

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,17 @@
141.540083 58.477089 150.590944 11.683077
0.780967 252.062877 194.999333 -9.535755
-182.018720 143.712962 246.196400 8.324630
-128.738125 83.680353 -147.165241 -169.202436
247.618479 -14.399831
14.099198 161.239629
9.253936 206.557192
22.808371 -181.895997
247.722635 17.382579
-166.102866 13.162238
-178.044456 21.755561
194.894848 94.175693
227.159481 15.950874
-167.106667 9.399277
-186.773941 -18.340155
53.315949 -185.413595
251.568772 21.525103

View File

@ -2,10 +2,10 @@ name, elo
./bots/dumb 1347 ./bots/dumb 1347
./bots/dumb2 1404 ./bots/dumb2 1404
./bots/dumb3 1355 ./bots/dumb3 1355
./bots/dumb4 1466 ./bots/dumb4 1345
./bots/dumb5 540 ./bots/dumb5 540
./bots/dumb6 562 ./bots/dumb6 562
./bots/follow1 657 ./bots/follow1 722
./bots/follow2 726 ./bots/follow2 801
./bots/follow3 652 ./bots/follow3 772
./bots/follow4 671 ./bots/follow4 648

View File

@ -1,16 +1,16 @@
4 4
0 (0 1) (79.84 55.26) 0 (2 0) (88.52 81.49)
1 (0 1) (63.60 77.08) 1 (1 3) (72.05 50.53)
2 (0 1) (36.40 77.08) 2 (1 3) (42.30 36.76)
3 (0 1) (20.16 55.26) 3 (3 0) (28.47 26.93)
3 0
5 9 5 5
31714.314 ..S14
S...035.6 ....0
.E..25..0 ...35
.6..37115 .E15.
.2175.... .....
100 200 5 0.90 0.80 0.20 0.00 0.20 100 200 5 0.90 0.80 0.20 0.00 0.20

View File

@ -25,6 +25,8 @@ bool matchDone = false;
bool noise = true; bool noise = true;
int playerToMove = 0;
FILE* save; FILE* save;
void cameraActions(level* lvl, bool* halt, int* cx, int* cy, int* dezoom, int* sizeR) { void cameraActions(level* lvl, bool* halt, int* cx, int* cy, int* dezoom, int* sizeR) {
@ -175,6 +177,7 @@ int main(int argc, char** argv) {
double elapsed = 0.0; double elapsed = 0.0;
bool halt = false; bool halt = false;
srand(time(NULL)); srand(time(NULL));
playerToMove = rand()%(max(1,nPlayers));
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
printf("error initializing SDL: %s\n", SDL_GetError()); printf("error initializing SDL: %s\n", SDL_GetError());
} }
@ -250,12 +253,32 @@ int main(int argc, char** argv) {
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; //B *= -1.0;
updateWins(ranks); updateWins(ranks);
if(remainingTurns != 0)parse_all_players(stage, execs); if(ONEATATIME == 1) {
if(remainingTurns > 0) { if(0==winners[playerToMove]) {
remainingTurns -= 1; write_output("output.txt", stage, playerToMove);
if(remainingTurns == 0) { if(WAIT)usleep(1000000/10);
matchDone = true; player_turn(playerToMove, execs[playerToMove]);
//halt = true; }
playerToMove += 1;
while(playerToMove >= nPlayers) {
playerToMove -= nPlayers;
currentTurn += 1;
if(remainingTurns > 0) {
remainingTurns -= 1;
if(remainingTurns == 0) {
matchDone = true;
//halt = true;
}
}
}
} else {
if(remainingTurns != 0)parse_all_players(stage, execs);
if(remainingTurns > 0) {
remainingTurns -= 1;
if(remainingTurns == 0) {
matchDone = true;
//halt = true;
}
} }
} }
elapsed = 0.0; elapsed = 0.0;

View File

@ -118,6 +118,7 @@ bool get_id(int* res) {
} }
void play_sound(char* filename) { void play_sound(char* filename) {
return;
pthread_mutex_lock(&lock); pthread_mutex_lock(&lock);
int id; int id;
if(get_id(&id)) { if(get_id(&id)) {

View File

@ -20,6 +20,7 @@ const int PLAYER_R = 5;
const int MAX_THETA_SPAWN = 80; // degrees const int MAX_THETA_SPAWN = 80; // degrees
const int BARRIERS = 1; const int BARRIERS = 1;
const int ONEATATIME = 1;
const double BARRIER_WIDTH = 0.05; const double BARRIER_WIDTH = 0.05;
const double FRICTION = 0.90; const double FRICTION = 0.90;

View File

@ -103,6 +103,7 @@ extern const double START_EDGE;
extern const double RESTITUTION_WALL; extern const double RESTITUTION_WALL;
extern const double RESTITUTION_PLAYER; extern const double RESTITUTION_PLAYER;
extern const int BARRIERS; extern const int BARRIERS;
extern const int ONEATATIME;
extern const double BARRIER_WIDTH; extern const double BARRIER_WIDTH;
extern const double FRICTION; extern const double FRICTION;

View File

@ -2,10 +2,10 @@ name, elo
./bots/dumb 1347 ./bots/dumb 1347
./bots/dumb2 1404 ./bots/dumb2 1404
./bots/dumb3 1355 ./bots/dumb3 1355
./bots/dumb4 1466 ./bots/dumb4 1345
./bots/dumb5 540 ./bots/dumb5 540
./bots/dumb6 562 ./bots/dumb6 562
./bots/follow1 657 ./bots/follow1 722
./bots/follow2 726 ./bots/follow2 801
./bots/follow3 652 ./bots/follow3 772
./bots/follow4 671 ./bots/follow4 648