slight improvement to graphing
This commit is contained in:
parent
f3f26c5284
commit
8ae37b145e
12
again.ml
12
again.ml
|
@ -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 logg then Printf.fprintf stderr "(%d, %d) --[%d]--> (%d, %d)\n" !cxi !cyi directn destx desty ;
|
||||||
if destx = !cxi && desty = !cyi then begin
|
if destx = !cxi && desty = !cyi then begin
|
||||||
if logg then Printf.fprintf stderr " Trapping\n" ;
|
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) ;
|
cxi := !cxi + fst order.(directn) ;
|
||||||
cyi := !cyi + snd order.(directn) ;
|
cyi := !cyi + snd order.(directn) ;
|
||||||
has_trapped := true ;
|
has_trapped := true ;
|
||||||
|
@ -1113,7 +1113,7 @@ let seek_player (gd : game_data) (dgs : danger_map) =
|
||||||
end
|
end
|
||||||
else if !remaining_dash = 0. then begin
|
else if !remaining_dash = 0. then begin
|
||||||
if logg then Printf.fprintf stderr " Dashing\n" ;
|
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. ;
|
remaining_dash := 3. ;
|
||||||
cxi := !cxi + fst order.(directn) ;
|
cxi := !cxi + fst order.(directn) ;
|
||||||
cyi := !cyi + snd order.(directn) ;
|
cyi := !cyi + snd order.(directn) ;
|
||||||
|
@ -1121,14 +1121,14 @@ let seek_player (gd : game_data) (dgs : danger_map) =
|
||||||
end
|
end
|
||||||
else if abs (destx - !cxi) + abs (desty - !cyi) <= gd.players.(pid).bomb_radius && gd.players.(pid).bomb_to_place > 0 then begin
|
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" ;
|
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) ;
|
cxi := !cxi + fst order.(directn) ;
|
||||||
cyi := !cyi + snd order.(directn) ;
|
cyi := !cyi + snd order.(directn) ;
|
||||||
break := true ;
|
break := true ;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
if logg then Printf.fprintf stderr " Moving\n" ;
|
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) ;
|
cxi := !cxi + fst order.(directn) ;
|
||||||
cyi := !cyi + snd order.(directn) ;
|
cyi := !cyi + snd order.(directn) ;
|
||||||
break := true ;
|
break := true ;
|
||||||
|
@ -1401,7 +1401,7 @@ print_dangers danger_data ;;*)
|
||||||
(*Printf.fprintf stderr "\n" ;;
|
(*Printf.fprintf stderr "\n" ;;
|
||||||
print_dangers danger_data ;;*)
|
print_dangers danger_data ;;*)
|
||||||
|
|
||||||
if read_queue "again.sav" then begin
|
if read_queue "again_dash.sav" then begin
|
||||||
remaining_dash := !remaining_dash +. 1. ;
|
remaining_dash := !remaining_dash +. 1. ;
|
||||||
if logg then Printf.fprintf stderr "[%d] reading...\n" game_map.player_id ;
|
if logg then Printf.fprintf stderr "[%d] reading...\n" game_map.player_id ;
|
||||||
end
|
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);
|
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
|
end
|
||||||
else begin
|
else begin
|
||||||
ignore (read_queue "again.sav")
|
ignore (read_queue "again_dash.sav")
|
||||||
end
|
end
|
||||||
end;;
|
end;;
|
||||||
(*Printf.printf "\n4 0" ;;*)
|
(*Printf.printf "\n4 0" ;;*)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
45
entrees.txt
45
entrees.txt
|
@ -1,27 +1,26 @@
|
||||||
122.20000000000016
|
150.1250000000006
|
||||||
1
|
1
|
||||||
13 21
|
13 21
|
||||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
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 3 3 3 3 3 3 3 0 2 2 2 0 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 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 0 2 2 2 2 2 0 4 4 4 4 4 5 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 3 1 2 1 2 1 2 1 2 1 0 1 5 1 4 1 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 3 3 0 2 2 2 2 2 2 2 2 2 0 0 4 4 4 1
|
1 3 3 6 6 4 4 4 4 4 2 2 2 2 2 4 2 0 0 4 1
|
||||||
1 3 1 3 1 0 1 2 1 2 1 2 1 2 1 4 1 4 1 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 3 3 6 6 0 2 2 2 2 2 2 0 4 4 4 4 4 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 0 1 0 1 2 1 2 1 2 1 2 1 4 1 4 1 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 0 2 2 2 2 2 2 0 4 4 4 4 4 4 4 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 0 1 2 1 2 1 2 1 0 1 4 1 4 1 4 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 0 2 2 2 0 4 4 4 4 4 4 4 4 4 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||||
1
|
3
|
||||||
5 16 4 122.30000000000013
|
1 8 2 151.25100000000052
|
||||||
1
|
9 13 4 151.90400000000037
|
||||||
7 14 1 1 3 4 0 0
|
7 14 4 154.82000000000042
|
||||||
6
|
2
|
||||||
6 5 4
|
4 7 1 3 3 2 1 0
|
||||||
1 6 3
|
8 15 3 3 0 4 0 0
|
||||||
9 12 4
|
2
|
||||||
10 13 2
|
3 9 4
|
||||||
7 13 0
|
8 11 2
|
||||||
2 13 4
|
|
||||||
|
|
18
graphing.c
18
graphing.c
|
@ -8,13 +8,13 @@
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
|
|
||||||
int width = 800 ;
|
int width = 900 ;
|
||||||
int height = 500 ;
|
int height = 600 ;
|
||||||
|
|
||||||
int offset = 25 ;
|
int offset = 25 ;
|
||||||
int wside = 15 ;
|
int wside = 15 ;
|
||||||
|
|
||||||
int map_size = 64 ;
|
int map_size = 80 ;
|
||||||
|
|
||||||
int min(int x, int y) {
|
int min(int x, int y) {
|
||||||
if(x < 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) ;
|
int y_size = 1+(top_y - bot_y)/(1+max_val) ;
|
||||||
|
|
||||||
for(int t0 = 0; t0 < borned; t0++) {
|
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++) {
|
for(int pl = 0; pl < 4; pl++) {
|
||||||
int t = (t0 + max(0, current_time - map_size +1))%map_size ;
|
|
||||||
//int t = t0 ;
|
//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))) ;
|
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) ;
|
//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) ;
|
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 ;
|
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);
|
SDL_SetRenderDrawBlendMode(rend, SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
int** board = malloc(sizeof(int*)*map_size) ;
|
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);
|
board[k] = malloc(sizeof(int)*4);
|
||||||
for(int l = 0; l < 4; l++) {
|
for(int l = 0; l < 4; l++) {
|
||||||
board[k][l] = (-1) ;
|
board[k][l] = (-1) ;
|
||||||
|
@ -420,7 +424,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
fprintf(stderr, "|||||||||||||||| QUIT ||||||||||||||||\n") ;
|
fprintf(stderr, "|||||||||||||||| QUIT ||||||||||||||||\n") ;
|
||||||
|
|
||||||
for(int k = 0; k < 128; k++) {
|
for(int k = 0; k < map_size; k++) {
|
||||||
free(board[k]);
|
free(board[k]);
|
||||||
}
|
}
|
||||||
free(board);
|
free(board);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1
|
0
|
|
@ -1 +1 @@
|
||||||
3 0
|
0 0
|
Loading…
Reference in New Issue