Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created October 6, 2019 03:21
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/089840ced96c77a7d97c859b55ff4727 to your computer and use it in GitHub Desktop.
Save IntegerMan/089840ced96c77a7d97c859b55ff4727 to your computer and use it in GitHub Desktop.
type GameCommand =
| MoveLeft | MoveRight
| MoveUp | MoveDown
| MoveUpLeft | MoveUpRight
| MoveDownLeft | MoveDownRight
| Wait
| Restart
let playTurn state player getRandomNumber command =
let world = state.World
match command with
| MoveLeft -> { state with World = moveActor world player -1 0 }
| MoveRight -> { state with World = moveActor world player 1 0 }
| MoveUp -> { state with World = moveActor world player 0 -1 }
| MoveDown -> { state with World = moveActor world player 0 1 }
| MoveUpLeft -> { state with World = moveActor world player -1 -1 }
| MoveUpRight -> { state with World = moveActor world player 1 -1 }
| MoveDownLeft -> { state with World = moveActor world player -1 1 }
| MoveDownRight -> { state with World = moveActor world player 1 1 }
| Wait ->
printfn "Time Passes..."
state
| Restart ->
let world = makeWorld 13 13 getRandomNumber
{ World = world; Player = world.Squirrel }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment