Up.
This commit is contained in:
parent
79945ad572
commit
3a4782b32e
3 changed files with 48 additions and 0 deletions
1
coders-strike-back/Makefile
Symbolic link
1
coders-strike-back/Makefile
Symbolic link
|
@ -0,0 +1 @@
|
|||
../Makefile
|
46
coders-strike-back/code1.ml
Normal file
46
coders-strike-back/code1.ml
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
let open Printf in
|
||||
let debug = fprintf stderr in
|
||||
|
||||
(* game loop *)
|
||||
while true do
|
||||
(* nextcheckpointx: x position of the next check point *)
|
||||
(* nextcheckpointy: y position of the next check point *)
|
||||
(* nextcheckpointdist: distance to the next checkpoint *)
|
||||
(* nextcheckpointangle: angle between your pod orientation and the direction of the next checkpoint *)
|
||||
|
||||
(* parse my data *)
|
||||
let line = input_line stdin in
|
||||
let x, y, nextcheckpointx, nextcheckpointy, nextcheckpointdist, nextcheckpointangle =
|
||||
Scanf.sscanf line "%d %d %d %d %d %d" (fun x y nextcheckpointx nextcheckpointy nextcheckpointdist nextcheckpointangle -> (x, y, nextcheckpointx, nextcheckpointy, nextcheckpointdist, nextcheckpointangle))
|
||||
in
|
||||
|
||||
(* parse opponent data *)
|
||||
let line = input_line stdin in
|
||||
let opponentx, opponenty = Scanf.sscanf line "%d %d" (fun opponentx opponenty -> (opponentx, opponenty)) in
|
||||
|
||||
let is_far = nextcheckpointdist > 4000 in
|
||||
let is_near = nextcheckpointdist < 500 in
|
||||
let is_aligned = nextcheckpointangle > -15 && nextcheckpointangle < 15 in
|
||||
let is_aside = nextcheckpointangle > 90 || nextcheckpointangle < -90 in
|
||||
let use_boost = is_aligned && is_far in
|
||||
|
||||
debug "angle = %d\n%!" nextcheckpointangle ;
|
||||
|
||||
let thrust =
|
||||
if is_aside then 10
|
||||
else if is_aligned && is_near then 30
|
||||
else 100
|
||||
in
|
||||
|
||||
let power_str = match use_boost with
|
||||
| false -> string_of_int thrust
|
||||
| true -> "BOOST"
|
||||
in
|
||||
|
||||
(* output the target position + the power (0 <= thrust <= 100) *)
|
||||
(* i.e.: "x y thrust" *)
|
||||
printf "%d %d %s\n%!" nextcheckpointx nextcheckpointy power_str ;
|
||||
();
|
||||
done;
|
||||
|
1
coders-strike-back/code1.native
Symbolic link
1
coders-strike-back/code1.native
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/grolland/src/Glenux/codingame/coders-strike-back/_build/code1.native
|
Loading…
Reference in a new issue