open Types let board_width = ref 0 let board_height = ref 0 let board = ref ([| |] : map) let robots = ref (IntMap.empty : robot_list) let my_id = ref 0 let my_robot () = IntMap.find !my_id !robots let my_loc () = (my_robot ()).robot_loc let my_pack () = (my_robot ()).own let max_weight = ref 0 let money = ref 0 let packs = ref (IntMap.empty : pack_list) let packs_here = ref IntSet.empty let my_weight () = IntSet.fold (fun id acc -> match IntMap.find id !packs with | Some info, _ -> info.weight + acc | None, _ -> assert(1 = 2); acc) (my_pack ()) 0 let homes = ref LocSet.empty let dirty = ref false (* set when a package is picked or dropped *) (* walk related functions *) let invert_dir = function S -> N | N -> S | E -> W | W -> E let dx = function S -> (0, -1) | N -> (0, 1) | E -> (1, 0) | W -> (-1, 0) let move_pos (x, y) = function S -> (x, y - 1) | N -> (x, y + 1) | E -> (x + 1, y) | W -> (x - 1, y)