type loc = int * int type pack_info = { weight : int; dest : int * int } type pack_loc = No | Yes of loc | Maybe of loc (* | Likely of loc | Unlikely of loc *) module IntMap = Map.Make (struct type t = int let compare = compare end) let intmap_to_list m = IntMap.fold (fun id v acc -> (id, v) :: acc) m [] module IntSet = Set.Make (struct type t = int let compare = compare end) module LocSet = Set.Make (struct type t = int * int let compare = compare end) let intset_to_list m = IntSet.fold (fun e acc -> e :: acc) m [] let locset_to_list m = LocSet.elements m type pack_list = (pack_info option * pack_loc) IntMap.t type pack_id = int type robot_info = { mutable robot_loc : int * int; mutable own : IntSet.t } type robot_list = robot_info IntMap.t type map_elem = Plain | Water | Wall | Home of int (* num of packs taken *) type map = map_elem array array type move = N | E | S | W type action = Move of move | Pick of int list | Drop of int list (* scalar loc and linear two-dim array *) type fast_loc = int type 'a fast_locarray = 'a array let fastloc_y_shiftbits = 10 let fastloc_y_mult = 1024 let fastloc_get_x p = p land 1023 let fastloc_get_y p = p lsr 10 let fastloc_encode x y = (y lsl 10) lor x let loc_of_fastloc p = fastloc_get_x p, fastloc_get_y p let fastloc_of_loc (x, y) = fastloc_encode x y let make_fastlocarray x y init = Array.create (y * fastloc_y_mult) init