Peg Solitaire (MIPS R2000 Assembly)

Spring 2011 | Project Length: 4 weeks (Elective coursework)

A Peg Solitaire game written from scratch in MIPS R2000 Assembly Language as a solo project. Done as a final project for my Computer Organization class. Validates user input, prints appropriate error messages, and detects when the game has ended.

The class itself was taken as a free elective. The full source code is available upon request. I previously had it available for download, but the professor asked me to take it down so that he could re-use the assignment.

Example Session

   ************************
   **     Peg Puzzle     **
   ************************

    0  1  2  3  4  5  6
        +---------+
0       | X  X  X |
1 +-----+ X  X  X +-----+
2 | X  X  X  X  X  X  X |
3 | X  X  X     X  X  X |
4 | X  X  X  X  X  X  X |
5 +-----+ X  X  X +-----+
6       | X  X  X |
        +---------+

Enter the location of the peg to move (RC, -1 to quit): 00

Illegal location.

Enter the location of the peg to move (RC, -1 to quit): 33

Illegal move, no peg at source location.

Enter the location of the peg to move (RC, -1 to quit): 03
Enter the location where the peg is moving to (RC, -1 to quit): 23

Illegal move, destination location is occupied.

Enter the location where the peg is moving to (RC, -1 to quit): 33

Illegal move, can only jump over one peg, re-enter move.

Enter the location of the peg to move (RC, -1 to quit): 22
Enter the location where the peg is moving to (RC, -1 to quit): 33

Illegal move, can only jump over one peg, re-enter move.

Enter the location of the peg to move (RC, -1 to quit): 13
Enter the location where the peg is moving to (RC, -1 to quit): 33

    0  1  2  3  4  5  6
        +---------+
0       | X  X  X |
1 +-----+ X     X +-----+
2 | X  X  X     X  X  X |
3 | X  X  X  X  X  X  X |
4 | X  X  X  X  X  X  X |
5 +-----+ X  X  X +-----+
6       | X  X  X |
        +---------+

Enter the location of the peg to move (RC, -1 to quit): 33
Enter the location where the peg is moving to (RC, -1 to quit): 13

Illegal move, no peg being jumped over, re-enter move.

Enter the location of the peg to move (RC, -1 to quit): 43
Enter the location where the peg is moving to (RC, -1 to quit): 23

    0  1  2  3  4  5  6
        +---------+
0       | X  X  X |
1 +-----+ X     X +-----+
2 | X  X  X  X  X  X  X |
3 | X  X  X     X  X  X |
4 | X  X  X     X  X  X |
5 +-----+ X  X  X +-----+
6       | X  X  X |
        +---------+

Enter the location of the peg to move (RC, -1 to quit): 31
Enter the location where the peg is moving to (RC, -1 to quit): 33

    0  1  2  3  4  5  6
        +---------+
0       | X  X  X |
1 +-----+ X     X +-----+
2 | X  X  X  X  X  X  X |
3 | X        X  X  X  X |
4 | X  X  X     X  X  X |
5 +-----+ X  X  X +-----+
6       | X  X  X |
        +---------+

Enter the location of the peg to move (RC, -1 to quit): 34
Enter the location where the peg is moving to (RC, -1 to quit): 32

    0  1  2  3  4  5  6
        +---------+
0       | X  X  X |
1 +-----+ X     X +-----+
2 | X  X  X  X  X  X  X |
3 | X     X        X  X |
4 | X  X  X     X  X  X |
5 +-----+ X  X  X +-----+
6       | X  X  X |
        +---------+

Enter the location of the peg to move (RC, -1 to quit): 36
Enter the location where the peg is moving to (RC, -1 to quit): 34

    0  1  2  3  4  5  6
        +---------+
0       | X  X  X |
1 +-----+ X     X +-----+
2 | X  X  X  X  X  X  X |
3 | X     X     X       |
4 | X  X  X     X  X  X |
5 +-----+ X  X  X +-----+
6       | X  X  X |
        +---------+

Enter the location of the peg to move (RC, -1 to quit): 63
Enter the location where the peg is moving to (RC, -1 to quit): 43

    0  1  2  3  4  5  6
        +---------+
0       | X  X  X |
1 +-----+ X     X +-----+
2 | X  X  X  X  X  X  X |
3 | X     X     X       |
4 | X  X  X  X  X  X  X |
5 +-----+ X     X +-----+
6       | X     X |
        +---------+

There are no more legal moves.
You left 26 pegs on the board.

Downloads

peg_puzzle.asm (33.5 KB) – Available upon request!
(Sorry, it’s not available publicly; this way future students doing this assignment can’t just download the solution)