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 | |
// ignore input for available molecules for wood 2 | |
let _ = readInput() | |
let samples = | |
readInt() |
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
// 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
// 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 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 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 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 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 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]) | |
} |
NewerOlder