Skip to content

Instantly share code, notes, and snippets.

@videlais
Created May 28, 2019 04:52
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 videlais/4dfb650c82972e5eef18e33c1c01cd8e to your computer and use it in GitHub Desktop.
Save videlais/4dfb650c82972e5eef18e33c1c01cd8e to your computer and use it in GitHub Desktop.
VAR x = 20
VAR y = 20
VAR water = 20
The desert was vast. My steps were erased soon after I placed them, but I had to continue. I knew that with every movement on the map, I would drink water -- and I was quickly running out.
-> Choices
=== Choices ===
{ water < 1: -> Out_Of_Water }
+ Move north?
{ setY(y - 1) }
{ drinkWater() }
-> Choices
+ Move south?
{ setY(y + 1) }
{ drinkWater() }
-> Choices
+ Move west?
{ setX(x - 1) }
{ drinkWater() }
-> Choices
+ Move east?
{ setX(x + 1) }
{ drinkWater() }
-> Choices
=== Out_Of_Water ===
I shook my canteen, but could tell it was empty. This... this was the last step in my journey.
-> DONE
=== function setX(newX) ===
{
- newX > 100:
~ x = 100
- newX < 0:
~ x = 0
- else:
~ x = newX
}
=== function setY(newY) ===
{
- newY > 100:
~ y = 100
- newY < 0:
~ y = 0
- else:
~ y = newY
}
=== function currentPosition() ===
(Currently at {x} and {y}.)
=== function drinkWater() ===
~ water = water - 1
=== function currentWater() ===
(Remaining water {water})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment