diff --git a/bin/main b/bin/main index ca9926e..4387b05 100755 Binary files a/bin/main and b/bin/main differ diff --git a/input_test.txt b/input_test.txt index 20bb71f..1dd06c7 100644 --- a/input_test.txt +++ b/input_test.txt @@ -13,7 +13,7 @@ 4 4 2 4.3 8 6 3 5.5 5 -3 0 0 0 2 4 5 3 +2 6 0 0 2 4 5 3 2 0 1 4 3 2 2 2 10 5 2 0 2 3 2 3 5 5 3 5 1 10 2 3 diff --git a/main.cmi b/main.cmi index 15e807a..bab3cd8 100644 Binary files a/main.cmi and b/main.cmi differ diff --git a/main.cmo b/main.cmo index 6e4f181..ae6037c 100644 Binary files a/main.cmo and b/main.cmo differ diff --git a/main.ml b/main.ml index a633b7d..a3c775f 100644 --- a/main.ml +++ b/main.ml @@ -3,7 +3,7 @@ let debug_all = true ;; let fatal_time = 1.0 ;; -let explosion_time = 0.5 ;; +let explosion_time = 1.0 ;; (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------------------------------------------------------------------------------- *) @@ -160,8 +160,8 @@ let print_danger_levels (map : danger array array) = match map.(l).(c) with | Blocked -> Printf.printf "@ " | Safe -> Printf.printf ". " - | Danger _ -> Printf.printf "! " - | Fatal _ -> Printf.printf "X " + | Danger x -> Printf.printf "! " + | Fatal x -> Printf.printf "X " done; Printf.printf "\n" done ;; @@ -348,7 +348,7 @@ let cell_values (gd : game_data) = for ln = 0 to lines -1 do for cl = 0 to cols -1 do - if gd.laby.(ln).(cl) >= 3 && gd.laby.(ln).(cl) <> 3 + gd.player_id then begin + if (gd.laby.(ln).(cl) >= 3 && gd.laby.(ln).(cl) <> 3 + gd.player_id) || gd.laby.(ln).(cl) = 0 then begin (* use a similar method than danger for bombs *) let halt = ref false in @@ -481,19 +481,19 @@ let move_explore (gd: game_data) (dgs : danger array array) = Hashtbl.add visited (cx0, cy0) 1 ; if is_valid (cx0+1) (cy0) lines cols && not ((simt +. interval) > (level_of_danger dgs.(cx0+1).(cy0)) && (simt +. interval) < (level_of_danger dgs.(cx0+1).(cy0)) +. explosion_time) then begin (* South *) - if debug_all then Printf.printf "[escape] +South\n" ; + if debug_all then Printf.printf "[crates] +South\n" ; Queue.add (cx0+1, cy0, simt +. interval, 2) q ; end; if is_valid (cx0-1) (cy0) lines cols && not ((simt +. interval) > (level_of_danger dgs.(cx0-1).(cy0)) && (simt +. interval) < (level_of_danger dgs.(cx0-1).(cy0)) +. explosion_time) then begin (* North *) - if debug_all then Printf.printf "[escape] +North\n" ; + if debug_all then Printf.printf "[crates] +North\n" ; Queue.add (cx0-1, cy0, simt +. interval, 0) q ; end; if is_valid (cx0) (cy0+1) lines cols && not ((simt +. interval) > (level_of_danger dgs.(cx0).(cy0+1)) && (simt +. interval) < (level_of_danger dgs.(cx0).(cy0+1)) +. explosion_time) then begin (* East *) - if debug_all then Printf.printf "[escape] +East\n" ; + if debug_all then Printf.printf "[crates] +East\n" ; Queue.add (cx0, cy0+1, simt +. interval, 1) q ; end; if is_valid (cx0) (cy0-1) lines cols && not ((simt +. interval) > (level_of_danger dgs.(cx0).(cy0-1)) && (simt +. interval) < (level_of_danger dgs.(cx0).(cy0-1)) +. explosion_time) then begin (* West *) - if debug_all then Printf.printf "[escape] +West\n" ; + if debug_all then Printf.printf "[crates] +West\n" ; Queue.add (cx0, cy0-1, simt +. interval, 3) q ; end; @@ -508,7 +508,7 @@ let move_explore (gd: game_data) (dgs : danger array array) = raise (ReturnInt direct) else if dgs.(cx).(cy) = Blocked then () - else begin (* either danger or fatal *) + else begin (* we need to go deeper *) let dang_time = level_of_danger dgs.(cx).(cy) in for dir = 0 to 3 do let newx = cx + fst order.(dir) @@ -560,7 +560,7 @@ let move_explore (gd: game_data) (dgs : danger array array) = result in - (* check if there's a crate next to the player, and if upon placing a bomb it won't block the player *) + (* check if there's a crate next to the player, and if upon placing a bomb it won't softlock the player *) if is_valid (cxi+1) (cyi) lines cols && gd.laby.(cxi+1).(cyi) = 2 && (safe_path_with_bomb cxi cyi gd.players.(pid).bomb_radius <> 4) then begin (* Crate at South *) current_status := EscapeDeath ; action := 1;