Snake and ladder: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
(Added Quackery.) |
||
Line 2,192: | Line 2,192: | ||
main()</syntaxhighlight> |
main()</syntaxhighlight> |
||
=={{header|Quackery}}== |
|||
<syntaxhighlight lang="Quackery"> [ this ] is .. ( --> [ ) |
|||
[ table 0 |
|||
.. .. .. 14 .. .. .. .. 31 .. |
|||
.. .. .. .. .. .. -7 .. .. 38 |
|||
.. .. .. .. .. .. .. 84 .. .. |
|||
.. .. .. .. .. .. .. .. .. 59 |
|||
.. .. .. .. .. .. .. .. .. .. |
|||
67 .. .. -34 .. .. .. .. .. .. |
|||
.. -19 81 -60 .. .. .. .. .. .. |
|||
91 .. .. .. .. .. .. .. .. .. |
|||
.. .. .. .. .. .. -24 .. .. .. |
|||
.. .. -73 .. -75 .. .. .. -78 .. ] is board ( n --> x ) |
|||
[ $ "What are the player's names? " |
|||
input nest$ shuffle |
|||
cr say "Order of play: " |
|||
dup witheach [ echo$ sp ] cr cr |
|||
dup size 0 swap of |
|||
false temp put |
|||
[ temp share if |
|||
[ say "Rolling 6 means the player" |
|||
say " receives another go." cr |
|||
-1 split swap join |
|||
dip [ -1 split swap join ] ] |
|||
dip |
|||
[ behead dup echo$ |
|||
nested join ] |
|||
behead |
|||
say " rolls " |
|||
6 random 1+ dup echo |
|||
dup 6 = temp replace |
|||
2dup + 100 > iff |
|||
[ say " which is too many " |
|||
say "so they don't move." cr |
|||
drop join ] |
|||
again |
|||
say " and moves to " |
|||
+ dup echo |
|||
dup 100 = iff |
|||
[ say " and wins." cr |
|||
drop ] |
|||
done |
|||
dup board |
|||
dup .. = iff |
|||
[ drop join |
|||
say "." cr ] |
|||
again |
|||
dup 0 < iff |
|||
[ say " which is a snake" |
|||
say " so they drop to " |
|||
abs dup echo say "." cr |
|||
nip join ] |
|||
again |
|||
say " which is a ladder" |
|||
say " so they rise to " |
|||
dup echo say "." cr |
|||
nip join |
|||
again ] |
|||
2drop |
|||
temp release ] is play ( --> [ ) |
|||
play</syntaxhighlight> |
|||
{{out}} |
|||
<div style="height: 320px;overflow:scroll"> |
|||
<pre>What are the player's names? Hector Zsazsa Kiki |
|||
Order of play: Kiki Zsazsa Hector |
|||
Kiki rolls 6 and moves to 6. |
|||
Rolling 6 means the player receives another go. |
|||
Kiki rolls 4 and moves to 10. |
|||
Zsazsa rolls 5 and moves to 5. |
|||
Hector rolls 1 and moves to 1. |
|||
Kiki rolls 2 and moves to 12. |
|||
Zsazsa rolls 2 and moves to 7. |
|||
Hector rolls 3 and moves to 4 which is a ladder so they rise to 14. |
|||
Kiki rolls 3 and moves to 15. |
|||
Zsazsa rolls 4 and moves to 11. |
|||
Hector rolls 1 and moves to 15. |
|||
Kiki rolls 4 and moves to 19. |
|||
Zsazsa rolls 5 and moves to 16. |
|||
Hector rolls 1 and moves to 16. |
|||
Kiki rolls 4 and moves to 23. |
|||
Zsazsa rolls 4 and moves to 20 which is a ladder so they rise to 38. |
|||
Hector rolls 2 and moves to 18. |
|||
Kiki rolls 5 and moves to 28 which is a ladder so they rise to 84. |
|||
Zsazsa rolls 3 and moves to 41. |
|||
Hector rolls 6 and moves to 24. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 2 and moves to 26. |
|||
Kiki rolls 3 and moves to 87 which is a snake so they drop to 24. |
|||
Zsazsa rolls 6 and moves to 47. |
|||
Rolling 6 means the player receives another go. |
|||
Zsazsa rolls 5 and moves to 52. |
|||
Hector rolls 6 and moves to 32. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 6 and moves to 38. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 3 and moves to 41. |
|||
Kiki rolls 5 and moves to 29. |
|||
Zsazsa rolls 5 and moves to 57. |
|||
Hector rolls 3 and moves to 44. |
|||
Kiki rolls 2 and moves to 31. |
|||
Zsazsa rolls 1 and moves to 58. |
|||
Hector rolls 4 and moves to 48. |
|||
Kiki rolls 4 and moves to 35. |
|||
Zsazsa rolls 3 and moves to 61. |
|||
Hector rolls 4 and moves to 52. |
|||
Kiki rolls 1 and moves to 36. |
|||
Zsazsa rolls 3 and moves to 64 which is a snake so they drop to 60. |
|||
Hector rolls 6 and moves to 58. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 4 and moves to 62 which is a snake so they drop to 19. |
|||
Kiki rolls 4 and moves to 40 which is a ladder so they rise to 59. |
|||
Zsazsa rolls 6 and moves to 66. |
|||
Rolling 6 means the player receives another go. |
|||
Zsazsa rolls 6 and moves to 72. |
|||
Rolling 6 means the player receives another go. |
|||
Zsazsa rolls 4 and moves to 76. |
|||
Hector rolls 4 and moves to 23. |
|||
Kiki rolls 3 and moves to 62 which is a snake so they drop to 19. |
|||
Zsazsa rolls 3 and moves to 79. |
|||
Hector rolls 3 and moves to 26. |
|||
Kiki rolls 6 and moves to 25. |
|||
Rolling 6 means the player receives another go. |
|||
Kiki rolls 2 and moves to 27. |
|||
Zsazsa rolls 4 and moves to 83. |
|||
Hector rolls 6 and moves to 32. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 6 and moves to 38. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 6 and moves to 44. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 1 and moves to 45. |
|||
Kiki rolls 2 and moves to 29. |
|||
Zsazsa rolls 2 and moves to 85. |
|||
Hector rolls 6 and moves to 51 which is a ladder so they rise to 67. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 1 and moves to 68. |
|||
Kiki rolls 2 and moves to 31. |
|||
Zsazsa rolls 3 and moves to 88. |
|||
Hector rolls 6 and moves to 74. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 4 and moves to 78. |
|||
Kiki rolls 6 and moves to 37. |
|||
Rolling 6 means the player receives another go. |
|||
Kiki rolls 1 and moves to 38. |
|||
Zsazsa rolls 3 and moves to 91. |
|||
Hector rolls 5 and moves to 83. |
|||
Kiki rolls 3 and moves to 41. |
|||
Zsazsa rolls 4 and moves to 95 which is a snake so they drop to 75. |
|||
Hector rolls 6 and moves to 89. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 5 and moves to 94. |
|||
Kiki rolls 4 and moves to 45. |
|||
Zsazsa rolls 6 and moves to 81. |
|||
Rolling 6 means the player receives another go. |
|||
Zsazsa rolls 3 and moves to 84. |
|||
Hector rolls 3 and moves to 97. |
|||
Kiki rolls 1 and moves to 46. |
|||
Zsazsa rolls 6 and moves to 90. |
|||
Rolling 6 means the player receives another go. |
|||
Zsazsa rolls 6 and moves to 96. |
|||
Rolling 6 means the player receives another go. |
|||
Zsazsa rolls 1 and moves to 97. |
|||
Hector rolls 6 which is too many so they don't move. |
|||
Rolling 6 means the player receives another go. |
|||
Hector rolls 2 and moves to 99 which is a snake so they drop to 78. |
|||
Kiki rolls 4 and moves to 50. |
|||
Zsazsa rolls 5 which is too many so they don't move. |
|||
Hector rolls 1 and moves to 79. |
|||
Kiki rolls 2 and moves to 52. |
|||
Zsazsa rolls 3 and moves to 100 and wins. |
|||
</pre> |
|||
</div> |
|||
=={{header|Racket}}== |
=={{header|Racket}}== |