In this game, rolling a 0 on the dice is a conceivable outcome, adding an element of unpredictability to each turn. Players encounter chance cards reminiscent of those found in Monopoly, introducing unexpected twists and turns to the gameplay. Moreover, navigating the moving ghost mirrors the mechanics of the classic Snake Game, posing a risk of restarting the game should players come into contact with it, enhancing the strategic depth and excitement of the overall experience.
Gameboard in Bitmap Display:
Core Functions in the MIPs code:
C Program:
Before the classic board game "Snakes and Ladders" was implemented in MIPS, it was programmed using the C programming language. In C, the program starts by printing out the rules of the game and a grid representing the game board. Players are initialized at the starting position (square 1) while the ghost position is initialized to 0. From there the game loop begins to run. The main loop continues until one of the players reaches or exceeds position 80. Within each iteration of the loop, the current player rolls a dice to determine the number of steps they will take. Based on the dice roll, the player's position is updated, taking into account any snakes or ladders encountered. Additionally, the ghost position is updated, potentially moving it to a new location on the board. After the game loop ends, the program announces the winner based on which player reached the end first. The program utilizes rand() for generating random numbers. Overall, the program provides a basic simulation of the Snakes and Ladders game, allowing two players to take turns rolling the dice and moving on the board until one of them reaches or exceeds position 80.
I encountered several bugs in my code, prompting me to adopt a systematic approach to debugging. I decided to break down the program into smaller, more manageable chunks, isolating each function to facilitate error identification. For instance, I isolated the ghost function in its own file to thoroughly test its functionality, which helped uncover existing bugs. Additionally, I segregated the move and diceRoll functions into a single file for experimentation purposes. Through this process, I realized the critical importance of the function order in MIPS, especially when not using the return address in functions. Initially, I placed the branches of the move function directly below it, leading to numerous issues. To address this, I meticulously reviewed the code line by line after assembly, ultimately resolving the problem by repositioning the branches above the move function.