Posted by Andrew Wegener on 31st October 2012
Yay! More C++ coding! Well, judging from the pseudocode, this should be relatively easy, right? Wrong! Just kidding. Overall, it was pretty easy. Let me explain:
The first part of the game is the generating of each players’ pieces. This could be fairly simple. However, the first set of rules I declared stated that:
1) Each player would receive ten pieces with randomly generated powers from 1-10.
2) The greater of the numbers will defeat the lesser. The only exception is that 1 can defeat a 10.
These rules are flawed. In theory, a player could receive ten 10s and be guaranteed to win (if the other player doesn’t have any 1s). What I’m saying is that in some cases, it could be impossible for one player to win. Lately, in my ITGM 351 Cognitive Art of Game Design class, Professor Rueda has been making us read about balance in games. As it is, this game is not balanced. It is important that games create the illusion of fairness to its players. My solution to the imbalance was this code that determines the players’ powers:
I decided to set three randomly chosen pieces to certain powers. This code ensures that each player will definitely have at least two 1s and one 10. This virtually eliminates any predetermined victories or losses to either player, obviously extreme, outrageous cases can still occur but the chances are slim to none. Also, the three random pieces are named Slot A, Slot B, and Slot C. I added the “do… while” loops to make sure the same piece was not chosen for two slots.
The actual loop of the main game is less than 100 lines (including a fair amount of white space). The majority of the code, in terms of lines, is from the function that displays the game board. This function is a whopping 800+ lines. All that remains are the random number generator function, the clear screen function, the directions, the title, and SPOILER ALERT!!!!!!….
(Highlight between the dashes to reveal the spoiler)
—A GIANT PIKACHU!!!—
One last thing I would like to mention… This was the first program I’ve written that I did a new (to me, at least) debugging technique. All of the blue text are “comments” – the compiler just skips that line after the //. Something weird was happening with the Slots and their values, so I inserted multiple cout statements telling the compiler to display the values of the slot variables. So, if you want to play this game on “easy” mode, you could just delete the //s then the pieces values will be revealed to you. Fun stuff!
The debugging technique and a better understanding of functions were the biggest experiences I took away from this assignment. I have had many of my friends play this game and it’s hilarious seeing their excitement/frustration/satisfaction while playing. For example, the game ONLY displays the enemy pieces, and ONLY when they are defeated (including in a draw). I enjoyed this project and it went smoothly for me for the most part.
I am not allowed to post the .exe file, unfortunately. Find my contact information and contact me. Maybe you’ll be lucky enough for me to send it to you!