JumpingFactorial.borg

JumpingFactorial.borg


{
` machines should contain a list of machines where to jump to
` if a machine doesn't exist the agent is lost
machines:
    [
    agent(router_placename()+"/Bob"),
    agent(router_placename()+"/Christine"),
    agent(router_placename()+"/Dirk"),
    agent(router_placename()+"/Erica")
    ];

fac(i)::
    {
    display("factorial " + text(i));
    machine:machines[(abs(random())\\size(machines))+1];
    display(" moving to "+ text(machine)+eoln);
    agentmove(machine);
    if (i > 1, fac(i - 1)*i, 1)
    };

display("Make sure to start an additional 4 borg evaluators.",
        eoln,"fac(12)",eoln)
}