here - Bilal`s Journey

MATLAB PROJECT: “Snakes and Ladders”
SUBMITTED BY: Bilal Shahid
ROLL NO: 2013-10-0148
SUMMARY:
The program is a multiplayer game in which a player has to traverse each single position
on a (10X10) board by ‘rolling a dice’. The player who reaches the position 100 before
any other player(s) wins. The computer asks for the number of players and their names at
the start when the project begins. The program displays a numbered square board with
snakes and ladders. Ladders facilitate a player to win by moving them ahead and snakes
push them down on the board. Players also compete for a position on the board; no two
players can be on the same position and the computer throws a player out of the board
and that player will be allowed to enter the board only if he roll a ‘6’, as the normal rule
of entry into the board. Alongside the board are: the option to roll a dice; a speed roll bar;
a position board and a display for the player who is out of the board.
USAGE:
Start the program by running the M-FILE: ‘runme.m’. The screen would display the
name of the project and its designer. Click on the ‘Begin’ button and a new screen
appears that displays the classical SNAKES & LADDERS game board.
 OPTIONS:
There are several options that one may consider while running the project. These include:
1. As soon as the user clicks ‘BEGIN’, a menu screen appears that asks for
the number of players. Then click ‘START GAME’.
2. A dialogue box appears that asks for the names of players. You make
enter a name, or just press ‘OK’ and the computer will generate a default
name ‘PLAYER 1’, etc.
3. At any moment when the players want to abandon the game, they can
simply click the close option on the title bar. However, this feature will
NOT work while a ‘PLAYER’ is moving along the board or while stepping
a ladder or falling off after a snake ‘bite’.
4. Another option is for the user to restart the game in case the game ends or
closes unexpectedly. This comes when the close option is chosen and a
dialogue box appears that asks if the player wants to restart. You may click
‘yes’ if wish to continue with another game.
 FEATURES:
There are a number of features exclusive to this project that have been carefully thought
of to make the project simple like the classic SNAKES & LADDERS game yet keep the
user involved in rolling the dice like in the real board game.
1. After you start game, each player may roll dice on their turn. This is
done by clicking on the ROLL DICE option and by carefully looking at
the ‘DICE ROLL POWER red bar. Its maximum length increases the
probability of getting a ‘6’ on the dice face.
2. There are no dock tools and the title of the screen window has been
renamed. The screen size is also fixed to a standard size.
3. The movement of pieces that represent PLAYERS would be shown to
vary with the number on the dice and this would be shown on an
animated ‘POSITION’ board that displays each player’s position and
even show whose turn it is.
4. PLAYERS climb ladders and fall with snakes in path of snake’s body,
as they move along the board.
5. The ‘wavsounds’ are played as the die rolls, the pieces move along a
ladder or snake or when a player wins.
6. The game is complete when a player reaches position 100.
THEORY & PRGOGRAMMING:

Theory: The game simply employs probability and plain mathematical
ideas while making the dice roll, recording the position of the PLAYERS
and showing it on the board. When, for example, the red bar has its full
length, there is a high probability of getting a ‘6’. When making the
pieces move on the board, the position is recorded. To make the pieces
move along the path of snake body or the ladder, its coordinates were
found and the position of the piece changed accordingly.

Structure:
1. The main program is run by the file ‘runme.m’. There are other key script
files: setupboard; setupgraphics; startgame; make move; load sounds;
chooseNoOfplayers; animateScoreBoard and cleanup.
2. The function [button (btnCap, btnPos, btnSize)] creates a button according to
the screen number of the simulation, with caption, position and its size.
3. The function [getColor(colorNo)] chooses appropriate color number set by its
rgb value for various uses in different script files.
4. The function [makeDie (number)] selects an appropriate case as to what the
number of the dice should be and displays this number on the patch of the
dice.
5. The function [makePiece(pNo)]selects the PLAYER piece that is under
consideration and sets its movement and other properties etc.
6. The function [rolldice(faces, maxAngle)] changes the number on the dice and
its rotation.