@@ -592,19 +592,19 @@ let formatRemaining remaining =
592592
593593let maxCycles = 1000
594594let world = ref ( buildWorldInitialWorld())
595- let foodToWin = int <| double ( Map.fold ( fun s k v -> s + v.Food) 0 ! world) * percentFoodToWin
595+ let foodToWin = int <| double ( Map.fold ( fun s k v -> s + v.Food) 0 world.Value ) * percentFoodToWin
596596let cycles = ref 0
597597
598598let blackAI = new HardishAI.TestAntBehavior() :> IAntBehavior
599599let redAI = new AntsEverywhereExmampleAI.TestAntBehavior() :> IAntBehavior
600600
601601let render ( w , h ) =
602- cycles := ! cycles + 1
602+ cycles.Value <- cycles.Value + 1
603603
604- let bScore = BlackAntNest.CountFood ! world
605- let rScore = RedAntNest.CountFood ! world
604+ let bScore = BlackAntNest.CountFood world.Value
605+ let rScore = RedAntNest.CountFood world.Value
606606
607- let remainig = maxCycles - ! cycles
607+ let remainig = maxCycles - cycles.Value
608608
609609 let scoreString = formatScoreCard blackAI.Name bScore redAI.Name rScore
610610 updateInput " score" scoreString |> ignore
@@ -614,10 +614,10 @@ let render (w,h) =
614614
615615
616616 ( 0. , 0. , w, h) |> filled ( rgb 200 200 200 )
617- drawUpdates ( w, h) ! world
618- world := worldCycle blackAI redAI ! world
617+ drawUpdates ( w, h) world.Value
618+ world.Value <- worldCycle blackAI redAI world.Value
619619
620- if bScore > foodToWin || rScore > foodToWin || ! cycles > maxCycles then
620+ if bScore > foodToWin || rScore > foodToWin || cycles.Value > maxCycles then
621621 if bScore > rScore then Some blackAI.Name
622622 elif rScore > bScore then Some redAI.Name
623623 else None
@@ -633,4 +633,4 @@ let rec update () =
633633 | Some winner ->
634634 updateInput " secondline" ( sprintf " The winner is: %s " winner) |> ignore
635635
636- update ()
636+ update ()
0 commit comments