A python snake and ladder game for machine coding.
- Free software: MIT license
- Documentation: https://vaibhavvikas.ml/snake-ladder/.
Create a snake and ladder application. The application should take as input (from the command line or a file):
- Number of snakes (s) followed by s lines each containing 2 numbers denoting the head and tail positions of the snake.
- Number of ladders (l) followed by l lines each containing 2 numbers denoting the start and end positions of the ladder.
- Number of players (p) followed by p lines each containing a name.
After taking these inputs, you should print all the moves in the form of the current player name followed by a random number between 1 to 6 denoting the die roll and the initial and final position based on the move. Format: <player_name> rolled a <dice_value> and moved from <initial_position> to <final_position>
When someone wins the game, print that the player won the game. Format: <player_name> wins the game
- The board will have 100 cells numbered from 1 to 100.
- The game will have a six sided dice numbered from 1 to 6 and will always give a random number on rolling it.
- Each player has a piece which is initially kept outside the board (i.e., at position 0).
- Each player rolls the dice when their turn comes.
- Based on the dice value, the player moves their piece forward that number of cells. Ex: If the dice value is 5 and the piece is at position 21, the player will put their piece at position 26 now (21+5).
- A player wins if it exactly reaches the position 100 and the game ends there.
- After the dice roll, if a piece is supposed to move outside position 100, it does not move.
- The board also contains some snakes and ladders.
- Each snake will have its head at some number and its tail at a smaller number.
- Whenever a piece ends up at a position with the head of the snake, the piece should go down to the position of the tail of that snake.
- Each ladder will have its start position at some number and end position at a larger number.
- Whenever a piece ends up at a position with the start of the ladder, the piece should go up to the position of the end of that ladder.
- There could be another snake/ladder at the tail of the snake or the end position of the ladder and the piece should go up/down accordingly.
- Assumptions you can take apart from those already mentioned in rules
- There won’t be a snake at 100.
- There won’t be multiple snakes/ladders at the same start/head point.
- It is possible to reach 100, i.e., it is possible to win the game.
- Snakes and Ladders do not form an infinite loop.
- Make sure that you have a working and demonstrable code
- Make sure that the code is functionally correct
- Code should be modular and readable
- Separation of concern should be addressed
- Please do not write everything in a single file
- Code should easily accommodate new requirements and minimal changes
- There should be a main method from where the code could be easily testable
- [Optional] Write unit tests, if possible
- No need to create a GUI
Please do these only if you’ve time left. You can write your code such that these could be accommodated without changing your code much.
- The game is played with a dice with the dice value could be between 1 to any input in a single move.
- The board size can be customizable and can be taken as input before other input (snakes, ladders, players).
- In case of more than 2 players, the game continues until only one player is left.
- On getting max value, you get another turn and on getting 3 consecutive max values, all the three of those get cancelled.
100
2
vaibh dwan
12
4
87 23
43 11
98 56
76 36
4
12 45
40 60
73 91
62 81
vaibh rolled a 6 and moved from 0 to 6
dwan rolled a 10 and moved from 0 to 10
vaibh rolled a 10 and moved from 6 to 16
dwan rolled a 27 and moved from 10 to 37
vaibh rolled a 4 and moved from 16 to 20
dwan rolled a 2 and moved from 37 to 39
vaibh rolled a 1 and moved from 20 to 21
dwan rolled a 2 and moved from 39 to 41
vaibh rolled a 11 and moved from 21 to 32
dwan rolled a 4 and moved from 41 to 45
vaibh rolled a 5 and moved from 32 to 37
dwan rolled a 6 and moved from 45 to 51
vaibh rolled a 2 and moved from 37 to 39
dwan rolled a 7 and moved from 51 to 58
vaibh rolled a 1 and moved from 39 to 40
dwan rolled a 6 and moved from 58 to 64
vaibh rolled a 2 and moved from 40 to 42
dwan rolled a 4 and moved from 64 to 68
vaibh rolled a 2 and moved from 42 to 44
dwan rolled a 6 and moved from 68 to 74
vaibh rolled a 11 and moved from 44 to 55
dwan rolled a 6 and moved from 74 to 80
vaibh rolled a 3 and moved from 55 to 58
dwan rolled a 1 and moved from 80 to 81
vaibh rolled a 9 and moved from 58 to 67
dwan rolled a 2 and moved from 81 to 83
vaibh rolled a 3 and moved from 67 to 70
dwan rolled a 5 and moved from 83 to 88
vaibh rolled a 6 and moved from 70 to 76
dwan rolled a 4 and moved from 88 to 92
vaibh rolled a 2 and moved from 76 to 78
dwan rolled a 2 and moved from 92 to 94
vaibh rolled a 10 and moved from 78 to 88
dwan rolled a 9 and but can't move from 94
vaibh rolled a 11 and moved from 88 to 99
dwan rolled a 3 and moved from 94 to 97
vaibh rolled a 5 and but can't move from 99
dwan rolled a 1 and moved from 97 to 98
vaibh rolled a 4 and but can't move from 99
dwan rolled a 1 and moved from 98 to 99
vaibh rolled a 15 and but can't move from 99
dwan rolled a 7 and but can't move from 99
vaibh rolled a 3 and but can't move from 99
dwan rolled a 2 and but can't move from 99
vaibh rolled a 10 and but can't move from 99
dwan rolled a 11 and but can't move from 99
vaibh rolled a 5 and but can't move from 99
dwan rolled a 6 and but can't move from 99
vaibh rolled a 2 and but can't move from 99
dwan rolled a 11 and but can't move from 99
vaibh rolled a 10 and but can't move from 99
dwan rolled a 10 and but can't move from 99
vaibh rolled a 11 and but can't move from 99
dwan rolled a 8 and but can't move from 99
vaibh rolled a 5 and but can't move from 99
dwan rolled a 11 and but can't move from 99
vaibh rolled a 19 and but can't move from 99
dwan rolled a 10 and but can't move from 99
vaibh rolled a 15 and but can't move from 99
dwan rolled a 4 and but can't move from 99
vaibh rolled a 6 and but can't move from 99
dwan rolled a 1 and moved from 99 to 100
Game Over
This package was created with Cookiecutter_ and the vaibhavvikas/cookiecutter-pypackage
_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _vaibhavvikas/cookiecutter-pypackage
: https://github.com/vaibhavvikas/cookiecutter-pypackage