Anonymous user
Snake and ladder: Difference between revisions
m
→{{header|REXX}}: changed whitespace and some comments.
No edit summary |
m (→{{header|REXX}}: changed whitespace and some comments.) |
||
Line 1,389:
{{trans|D}}
<!-- for Regina REXX, use a seed of 8 to produce the game shown below. !-->
<lang rexx>/*REXX program
parse arg np seed . /*obtain optional arguments from the CL*/
if np=='' | np=="," then np=
if datatype(seed, 'W') then call random ,,seed /*maybe use a seed
pad= left('',7) /*variable value used for indenting SAY*/
do k=1 for 100; @.k=
end /*k*/ /* [↑] number when landing on a square*/
/* [↓] define ladder destinations. */
Line 1,401:
/* [↑] define snake destinations. */
player.= 1 /*start all players on the 1st square. */
do games=1 until $==100; say center(' turn ' games" ", 75, "─")
do j=1 for np until $==100; $= turn(j, player.j); player.j= $
end /*j*/ /*process each of the number of players*/
Line 1,410:
turn: parse arg P, square; ?= random(1, 6) /*simulate a roll of a six─sided die. */
@does= pad 'Player ' P " on square " right(square, 2) ' rolls a ' ?
if square+?>100 then do; say @does " but can't move. Next player's turn."
return square
end
else do; square= square + ? /*move a player.*/
say @does " and moves to square" right(square, 3)
end
|