This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* game loop *) | |
while true do | |
// previous code | |
// ignore input for available molecules for wood 2 | |
let _ = readInput() | |
// more to come |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* game loop *) | |
while true do | |
let me = Robot.Create (tokenizeInput()) Player.Me | |
let enemy = Robot.Create (tokenizeInput()) Player.Enemy | |
// more to come |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let projectCount = readInt() | |
for i in 0 .. projectCount - 1 do | |
let _ = readInput() | |
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// previous GetMove code above | |
match mySamples.Length, samplesReady.Length, cloudSamples.Length, me.Location with | |
// previous match expressions here | |
| _, _, _, Module.Molecules -> | |
gather (getRequiredMolecule me mySamples.Head) | |
| _, _, _, _ -> | |
goto Module.Molecules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// previous GetMove code above | |
match mySamples.Length, samplesReady.Length, cloudSamples.Length, me.Location with | |
// previous match expressions here | |
| ms, _, cs, Module.Diagnosis when ms = 0 && cs > 0 -> | |
collect cloudSamples.Head | |
| ms, _, cs, _ when ms = 0 && cs > 0 -> | |
goto Module.Diagnosis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// previous getMove code above | |
match mySamples.Length, samplesReady.Length, cloudSamples.Length, me.Location with | |
| _, sr, _, Module.Laboratory when sr > 0 -> | |
produce samplesReady.Head | |
| _, sr, _, _ when sr > 0 -> | |
goto Module.Laboratory | |
// more to come |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GameState -> String | |
let getMove (gs : GameState) = | |
let me = gs.Robots |> List.find (fun r -> r.Player = Player.Me) | |
let mySamples = gs.Samples |> List.filter (fun s -> s.CarriedBy = Player.Me) | |
let samplesReady = mySamples |> List.filter (canMakeSample me) | |
let cloudSamples = | |
gs.Samples | |
|> List.filter (fun s -> s.CarriedBy = Player.Cloud) | |
|> List.sortByDescending (fun s -> s.HealthPoints) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let getMove (gs : GameState) = | |
let me = gs.Robots |> List.find (fun r -> r.Player = Player.Me) | |
let mySamples = gs.Samples |> List.filter (fun s -> s.CarriedBy = Player.Me) | |
let samplesReady = mySamples |> List.filter (canMakeSample me) | |
let cloudSamples = | |
gs.Samples | |
|> List.filter (fun s -> s.CarriedBy = Player.Cloud) | |
|> List.sortByDescending (fun s -> s.HealthPoints) | |
match mySamples.Length, samplesReady.Length, cloudSamples.Length, me.Location with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Robot -> SampleData -> MoleculeType | |
let getRequiredMolecule (robot : Robot) (sample : SampleData) = | |
let ms = | |
sample.Molecules.Counts | |
|> Map.filter (fun mt count -> robot.Molecules.Counts.[mt] < count) | |
|> Seq.head | |
ms.Key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Robot -> SampleData -> bool | |
let canMakeSample (robot : Robot) (sample : SampleData) = | |
sample.Molecules.Counts | |
|> Map.forall (fun mt count -> robot.Molecules.Counts.[mt] >= count) |