slight improvement to graphing

This commit is contained in:
Alexandre 2025-01-05 11:10:47 +01:00
parent f3f26c5284
commit 8ae37b145e
13 changed files with 42 additions and 38 deletions

BIN
again

Binary file not shown.

BIN
again.cmi

Binary file not shown.

BIN
again.cmx

Binary file not shown.

View File

@ -1105,7 +1105,7 @@ let seek_player (gd : game_data) (dgs : danger_map) =
if logg then Printf.fprintf stderr "(%d, %d) --[%d]--> (%d, %d)\n" !cxi !cyi directn destx desty ;
if destx = !cxi && desty = !cyi then begin
if logg then Printf.fprintf stderr " Trapping\n" ;
print_ret "again.sav" (direction_after_trap gd dgs !cxi !cyi) 3 print_escape ;
print_ret "again_dash.sav" (direction_after_trap gd dgs !cxi !cyi) 3 print_escape ;
cxi := !cxi + fst order.(directn) ;
cyi := !cyi + snd order.(directn) ;
has_trapped := true ;
@ -1113,7 +1113,7 @@ let seek_player (gd : game_data) (dgs : danger_map) =
end
else if !remaining_dash = 0. then begin
if logg then Printf.fprintf stderr " Dashing\n" ;
print_ret "again.sav" directn 2 print_escape ;
print_ret "again_dash.sav" directn 2 print_escape ;
remaining_dash := 3. ;
cxi := !cxi + fst order.(directn) ;
cyi := !cyi + snd order.(directn) ;
@ -1121,14 +1121,14 @@ let seek_player (gd : game_data) (dgs : danger_map) =
end
else if abs (destx - !cxi) + abs (desty - !cyi) <= gd.players.(pid).bomb_radius && gd.players.(pid).bomb_to_place > 0 then begin
if logg then Printf.fprintf stderr " Bombing\n" ;
print_ret "again.sav" directn 1 print_escape ;
print_ret "again_dash.sav" directn 1 print_escape ;
cxi := !cxi + fst order.(directn) ;
cyi := !cyi + snd order.(directn) ;
break := true ;
end
else begin
if logg then Printf.fprintf stderr " Moving\n" ;
print_ret "again.sav" directn 0 print_escape ;
print_ret "again_dash.sav" directn 0 print_escape ;
cxi := !cxi + fst order.(directn) ;
cyi := !cyi + snd order.(directn) ;
break := true ;
@ -1401,7 +1401,7 @@ print_dangers danger_data ;;*)
(*Printf.fprintf stderr "\n" ;;
print_dangers danger_data ;;*)
if read_queue "again.sav" then begin
if read_queue "again_dash.sav" then begin
remaining_dash := !remaining_dash +. 1. ;
if logg then Printf.fprintf stderr "[%d] reading...\n" game_map.player_id ;
end
@ -1422,7 +1422,7 @@ else begin
if logg then Printf.fprintf stderr "[player %d] %d %d (at time %f - with %d dash potential)\n" game_map.player_id !direction !action game_map.dt (int_of_float !remaining_dash);
end
else begin
ignore (read_queue "again.sav")
ignore (read_queue "again_dash.sav")
end
end;;
(*Printf.printf "\n4 0" ;;*)

BIN
again.o

Binary file not shown.

1
again_rem.sav Normal file
View File

@ -0,0 +1 @@
0

0
again_traps.sav Normal file
View File

View File

@ -1,27 +1,26 @@
122.20000000000016
150.1250000000006
1
13 21
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 3 3 3 3 3 0 2 2 2 2 0 5 5 5 5 5 5 5 5 1
1 3 1 3 1 2 1 2 1 2 1 2 1 0 1 5 1 4 1 5 1
1 3 3 3 3 3 0 2 2 2 2 2 0 4 4 4 4 4 5 5 1
1 3 1 3 1 2 1 2 1 2 1 2 1 0 1 5 1 4 1 4 1
1 3 3 3 3 0 2 2 2 2 2 2 2 2 2 0 0 4 4 4 1
1 3 1 3 1 0 1 2 1 2 1 2 1 2 1 4 1 4 1 4 1
1 3 3 3 6 6 0 2 2 2 2 2 2 0 4 4 4 4 4 4 1
1 6 1 0 1 0 1 2 1 2 1 2 1 2 1 4 1 4 1 4 1
1 6 6 6 6 0 2 2 2 2 2 2 0 4 4 4 4 4 4 4 1
1 6 1 6 1 0 1 2 1 2 1 2 1 0 1 4 1 4 1 4 1
1 6 6 6 6 6 0 2 2 2 0 4 4 4 4 4 4 4 4 4 1
1 3 3 3 3 3 3 3 3 0 2 2 2 0 5 5 5 5 5 5 1
1 3 1 3 1 3 1 0 1 2 1 2 1 2 1 5 1 5 1 5 1
1 3 3 3 3 3 3 3 3 0 2 2 2 2 2 5 5 5 5 4 1
1 3 1 6 1 3 1 4 1 2 1 2 1 2 1 2 1 5 1 4 1
1 3 3 6 6 4 4 4 4 4 2 2 2 2 2 4 2 0 0 4 1
1 0 1 6 1 3 1 4 1 2 1 2 1 2 1 4 1 5 1 4 1
1 3 6 6 6 6 6 4 2 2 2 2 2 0 0 4 4 4 4 4 1
1 6 1 6 1 3 1 0 1 2 1 0 1 4 1 4 1 5 1 5 1
1 6 6 6 6 6 6 6 6 6 0 6 4 4 4 4 4 4 5 5 1
1 6 1 6 1 6 1 0 1 0 1 6 1 4 1 4 1 5 1 5 1
1 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 4 5 4 4 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
5 16 4 122.30000000000013
1
7 14 1 1 3 4 0 0
6
6 5 4
1 6 3
9 12 4
10 13 2
7 13 0
2 13 4
3
1 8 2 151.25100000000052
9 13 4 151.90400000000037
7 14 4 154.82000000000042
2
4 7 1 3 3 2 1 0
8 15 3 3 0 4 0 0
2
3 9 4
8 11 2

View File

@ -8,13 +8,13 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
int width = 800 ;
int height = 500 ;
int width = 900 ;
int height = 600 ;
int offset = 25 ;
int wside = 15 ;
int map_size = 64 ;
int map_size = 80 ;
int min(int x, int y) {
if(x < y) {
@ -345,13 +345,17 @@ void update_graph(SDL_Renderer* renderer, int** board, int current_time) {
int y_size = 1+(top_y - bot_y)/(1+max_val) ;
for(int t0 = 0; t0 < borned; t0++) {
int t = (t0 + max(0, current_time - map_size +1))%map_size ;
int xc = convex_pt(left_x, right_x, ((float)(t0))/((float)(borned))) ;
if(t%20==0) {
placeRectToRenderer(renderer, xc, offset+wside, x_size, height - 2*(offset+wside), 128, 128, 128, 128);
}
for(int pl = 0; pl < 4; pl++) {
int t = (t0 + max(0, current_time - map_size +1))%map_size ;
//int t = t0 ;
int xc = convex_pt(left_x, right_x, ((float)(t0))/((float)(borned))) ;
int yc = convex_pt(bot_y, top_y, 1.0f - ((float)(max(0, board[t][pl])))/((float)(max_val+1))) ;
//drawCircleToRenderer(renderer, xc, yc, 10) ;
placeRectToRenderer(renderer, xc, yc-y_size+offset+wside, x_size, y_size, 255*(pl==0)+192*(pl==3), 255*(pl==2)+192*(pl==3), 255*(pl==1), 96) ;
}
}
int tmax = (borned-1 + max(0, current_time - map_size +1))%map_size ;
@ -391,7 +395,7 @@ int main(int argc, char** argv) {
SDL_SetRenderDrawBlendMode(rend, SDL_BLENDMODE_BLEND);
int** board = malloc(sizeof(int*)*map_size) ;
for(int k = 0; k < 128; k++) {
for(int k = 0; k < map_size; k++) {
board[k] = malloc(sizeof(int)*4);
for(int l = 0; l < 4; l++) {
board[k][l] = (-1) ;
@ -420,7 +424,7 @@ int main(int argc, char** argv) {
fprintf(stderr, "|||||||||||||||| QUIT ||||||||||||||||\n") ;
for(int k = 0; k < 128; k++) {
for(int k = 0; k < map_size; k++) {
free(board[k]);
}
free(board);

BIN
graphs

Binary file not shown.

View File

@ -1 +1 @@
1
0

View File

@ -1 +1 @@
3 0
0 0