challenge-codinggame/code-busters/code.ml

53 lines
1.7 KiB
OCaml
Raw Permalink Normal View History

2016-07-26 23:48:11 +00:00
module BusterCtx :
sig
type t
end =
struct
type ctx = {
name : string ;
mutable x : int ;
mutable y : int
}
type t = ctx
end
;;
(* Send your busters out into the fog to trap ghosts and bring them home! *)
let bustersperplayer = int_of_string (input_line stdin) in (* the amount of busters you control *)
let ghostcount = int_of_string (input_line stdin) in (* the amount of ghosts on the map *)
let myteamid = int_of_string (input_line stdin) in (* if this is 0, your base is on the top left of the map, if it is one, on the bottom right *)
(* initialize buster ctx array *)
(* game loop *)
while true do
let entities = int_of_string (input_line stdin) in (* the number of busters and ghosts visible to you *)
for i = 0 to entities - 1 do
(* entityid: buster id or ghost id *)
(* y: position of this buster / ghost *)
(* entitytype: the team id if it is a buster, -1 if it is a ghost. *)
(* state: For busters: 0=idle, 1=carrying a ghost. *)
(* value: For busters: Ghost id being carried. For ghosts: number of busters attempting to trap this ghost. *)
let line = input_line stdin in
let entityid, x, y, entitytype, state, value = Scanf.sscanf line "%d %d %d %d %d %d" (fun entityid x y entitytype state value -> (entityid, x, y, entitytype, state, value)) in
();
done;
for i = 0 to bustersperplayer - 1 do
(* Write an action using print_endline *)
(* To debug: prerr_endline "Debug message"; *)
Printf.printf "MOVE 8000 4500" ; (* MOVE x y | BUST id | RELEASE *)
print_endline "";
();
done;
();
done;