This file contains hidden or 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
| // Remains unchanged | |
| // Module ->string | |
| let goto : Goto = fun m -> sprintf "GOTO %s" <| m.ToString() | |
| // Replaced by next two (new) moves | |
| // SampleData -> string | |
| //let collect:Collect = fun s -> sprintf "CONNECT %i" <| s.Id | |
| // New move | |
| // Rank -> String |
This file contains hidden or 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
| // <--- 2nd parameter was (sample : SampleData) | |
| let canMakeSample (robot : Robot) (sample : DiagnosedSampleData) = | |
| sample.Molecules.Counts | |
| |> Map.forall (fun mt count -> robot.Molecules.Counts.[mt] >= count) | |
| // <--- 2nd parameter was (sample : SampleData) | |
| let getRequiredMolecule (robot : Robot) (sample : DiagnosedSampleData) = | |
| let ms = | |
| sample.Molecules.Counts | |
| |> Map.filter (fun mt count -> robot.Molecules.Counts.[mt] < count) |
This file contains hidden or 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
| type Goto = Module -> string // <--- Remains unchanged | |
| // type Collect = SampleData -> string // <--- Replaced by next two | |
| type CollectNewSample = Rank -> string | |
| type CollectCloudSample = DiagnosedSampleData -> string | |
| type Analyze = UndiagnosedSampleData -> string // <--- New type of move | |
| type Gather = MoleculeType -> string // <--- Remains unchanged | |
| type Produce = DiagnosedSampleData -> string // <--- Change SampleData to DiagnosedSampleData |
This file contains hidden or 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
| type SampleData = | |
| | Diagnosed of DiagnosedSampleData | |
| | Undiagnosed of UndiagnosedSampleData | |
| static member Create (token : Token) = | |
| if token.[4] |> int = -1 then | |
| SampleData.Undiagnosed <| UndiagnosedSampleData.Create token | |
| else | |
| SampleData.Diagnosed <| DiagnosedSampleData.Create token |
This file contains hidden or 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
| type UndiagnosedSampleData = | |
| { Id : Id | |
| CarriedBy : Player | |
| Rank : Rank } | |
| static member Create (token : Token) = | |
| { Id = (int <| token.[0]) | |
| CarriedBy = Player.Create (int <| token.[1]) | |
| Rank = (int <| token.[2]) | |
| } |
This file contains hidden or 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
| type Rank = int // <------------------- new type alias | |
| type DiagnosedSampleData = | |
| { Id : Id | |
| CarriedBy : Player | |
| Rank : Rank // <------------------- New field | |
| HealthPoints : HealthPoints | |
| Molecules : MoleculeStorage } | |
| static member Create (token : Token) = | |
| { Id = (int <| token.[0]) |
This file contains hidden or 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
| type Module = | |
| | StartPos | |
| | Samples // <------------------- New Union Case | |
| | Diagnosis | |
| | Molecules | |
| | Laboratory | |
| static member Create moduleName = | |
| match moduleName with | |
| | "START_POS" -> Module.StartPos | |
| | "SAMPLES" -> Module.Samples // <------------------- New Union Case |
This file contains hidden or 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 | |
| // ignore input for available molecules for wood 2 | |
| let _ = readInput() | |
| let samples = | |
| readInt() |
This file contains hidden or 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 | |
| let gameState = | |
| { Robots = [me; enemy] | |
| Samples = samples } | |
This file contains hidden or 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 | |
| let samples = | |
| readInt() | |
| |> readNLines | |
| |> Array.map (tokenize >> SampleData.Create) | |
| |> Array.toList |
NewerOlder