Snake and ladder: Difference between revisions
Content added Content deleted
(Snake and Ladder en BASIC256) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 18: | Line 18: | ||
Happy coding. |
Happy coding. |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python}} |
|||
<lang 11l>V snl = [4 = 14, |
|||
9 = 31, |
|||
17 = 7, |
|||
20 = 38, |
|||
28 = 84, |
|||
40 = 59, |
|||
51 = 67, |
|||
54 = 34, |
|||
62 = 19, |
|||
63 = 81, |
|||
64 = 60, |
|||
71 = 91, |
|||
87 = 24, |
|||
93 = 73, |
|||
95 = 75, |
|||
99 = 78] |
|||
V sixesRollAgain = 1B |
|||
F turn(player, =square) |
|||
L |
|||
V roll = random:(1 .. 6) |
|||
print(‘Player #. on square #., rolls a #.’.format(player, square, roll), end' ‘’) |
|||
I square + roll > 100 |
|||
print(‘ but cannot move.’) |
|||
E |
|||
square += roll |
|||
print(‘ and moves to square #.’.format(square)) |
|||
I square == 100 |
|||
R 100 |
|||
V next = :snl.get(square, square) |
|||
I square < next |
|||
print(‘Yay! landed on a ladder. Climb up to #..’.format(next)) |
|||
I square == 100 |
|||
R 100 |
|||
square = next |
|||
E I square > next |
|||
print(‘Oops! Landed on a snake. Slither down to #..’.format(next)) |
|||
square = next |
|||
I roll < 6 | !:sixesRollAgain |
|||
R square |
|||
print(‘Rolled a 6 so roll again.’) |
|||
F main() |
|||
V players = [1, 1, 1] |
|||
L |
|||
L(i) 0..2 |
|||
V ns = turn(i + 1, players[i]) |
|||
I ns == 100 |
|||
print(‘Player #. wins!’.format(i + 1)) |
|||
R |
|||
players[i] = ns |
|||
print() |
|||
main()</lang> |
|||
{{out}} |
|||
The same as in Python. |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |