Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created October 6, 2019 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/e91e19fcbb304cff24bbdef6040ea223 to your computer and use it in GitHub Desktop.
Save IntegerMan/e91e19fcbb304cff24bbdef6040ea223 to your computer and use it in GitHub Desktop.
[<EntryPoint>]
let main argv =
printfn "F# Console Application Tutorial by Matt Eland"
let getRandomNumber =
let r = Random()
fun max -> (r.Next max) + 1
let world = makeWorld 13 13 getRandomNumber
let mutable state = { World = world; Player = world.Squirrel }
let mutable simulating: bool = true
while simulating do
let player = state.World.Squirrel
let userCommand = getUserInput(state.World) |> tryParseInput
match userCommand with
| None -> printfn "Invalid input"
| Some command ->
match command with
| Exit -> simulating <- false
| Action gameCommand -> state <- playTurn state player getRandomNumber gameCommand
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment