%export "../MonteCarlo/MonteCarlo"
        random_walk
        show_ending_statistics
%include "transition_nets"
%include "../MonteCarlo/MonteCarlo"


random_walk :: net -> node -> process [node]
  random_walk n here s
    = here : random_walk n (select n here (hd s)) (tl s)

select :: net -> node -> real -> node
  select n here rnd = n here!(#n here*rnd)








show_ending_statistics :: statistics node -> [char]
  show_ending_statistics (table,total)
    = "RUNS SO FAR: " ++ shownum total
      ++ "\n\nDISTRIBUTION OF ENDINGS SO FAR:\n\n"
      ++ "NODE\tCOUNT\tPERCENTAGE\n----\t-----\t----------\n"
      ++ concat (map (shownodecount total) table)
      ++ "\n\n\n\n"

shownodecount :: count -> (node,count) -> [char]
  shownodecount total (here,c) = shownum here++"\t"++shownum c
                                 ++"\t"++shownum (100*c/total)++"%\n"
