Skip to content

Commit b953725

Browse files
ShalokShalomalfonsogarciacaro
authored andcommitted
Update to current standards
The "Problems" section of the REPL reported 10 issues. I corrected all of them and still cant get the game running.
1 parent dc67256 commit b953725

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

public/samples/games/ants.fs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,19 +592,19 @@ let formatRemaining remaining =
592592

593593
let maxCycles = 1000
594594
let 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
596596
let cycles = ref 0
597597

598598
let blackAI = new HardishAI.TestAntBehavior() :> IAntBehavior
599599
let redAI = new AntsEverywhereExmampleAI.TestAntBehavior() :> IAntBehavior
600600

601601
let 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

Comments
 (0)