Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created October 22, 2019 03:40
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/c1d3e75abb8368a0e32a177d0fad7eb4 to your computer and use it in GitHub Desktop.
Save IntegerMan/c1d3e75abb8368a0e32a177d0fad7eb4 to your computer and use it in GitHub Desktop.
let handleSquirrelMove otherActor hasAcorn =
if not hasAcorn && otherActor.ActorKind = Acorn && otherActor.IsActive then
// Moving to the acorn for the first time should give the squirrel the acorn
{state with World =
{
world with
Squirrel = {ActorKind = Squirrel true; Pos = pos; IsActive = true}
Acorn = {world.Acorn with IsActive = false}
}
}
else if hasAcorn && otherActor.ActorKind = Tree then
// Moving to the tree with the acorn - this should win the game
{
state with SimState = Won; World = {
world with Squirrel = {ActorKind = Squirrel true; Pos = pos; IsActive = true}
}
}
else
performMove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment