procgen  threat.ml at [93b72b5a88]

File threat.ml artifact dc6a67ba01 part of check-in 93b72b5a88


let range min max = min+(Random.int (max-min))
let pick ar = ar.(range 0 (Array.length ar))
let rule (items : string list Lazy.t array) = let syntax = Lazy.force(pick items) in
    List.fold_left (^) "" syntax 
let choice ar = Lazy.force(pick ar)
type person = {
    nom : string;
    gen : string;
    acc : string;
}

let victims = [|
    {nom="you";gen="your";acc="you"};
|]
let insults = [|
    "bitch"; "cunt"; "freak"; "douchebag";
    "bastard";
|]
let action victim = rule [|
    lazy ["port "; victim.acc; " to lisp"];
    lazy ["rain on "; victim.gen; " parade"];
|]
let intros () =
    let vocative () = match range 0 3 in
        | 0 -> "you"
        | 1 -> pick insults
        | 2 -> "you, " ^ (pick insults) in
    rule [|
        lazy ["listen up, "; vocative (); "!
|]
let threat () = (intros()) ^ " " ^ (action (pick victims)) 
let () =
    Random.self_init();
    print_string (threat ())