Week 6 – Continued Progress
Welcome to my sixth Senior Project blog! I’ll go over some progress I made this week, including fixing a (very big) problem from last week, as well as making some more progress towards being able to automatically adjust the difficulty of the game.
Fixing The Win-Loss Counter
Last week, I implemented a way to track the total wins and losses, which would later be used to determine if a player was winning more than they lost, or losing more than they won. I added this into my getWinner() method, which would update the wins and losses whenever it was called. The issue with this, however, was that the method was called every time in my update() method, leading to the winner of a single game being given approximately 60 wins per second that the game ended before the new one started, rather than just one win or loss per game. After spending some time trying to figure out how to call the getWinner() method only once, I decided to just instead update wins and losses in the newGame() method, which gets called when the player clicks the screen after a game ends. I needed to pass the winner of the game as a parameter in this method, but could then update the wins and losses only once. There is minor thing about this that I don’t like, as the wins and losses won’t actually get updated until a new game starts. Therefore, if the game is closed before starting a new game, the result of that game won’t be tracked. For now, though, I’m leaving it like this since it does technically work, and so that I can also move on to other parts of my project.
Improved Board Score
My current board score is determined by the difference in the number of pieces for each color. For my “improved” method, I wanted to also include the number of kings in this score by giving them a value higher than a normal piece. In chess, each piece on the board has a value, and while not everyone agrees on the exact value of each piece, they are approximately 1, 3, 3, 5, and 9 for pawns, bishops, knights, rooks, and queens. However, I couldn’t find any generally agreed on values for the regular and king pieces in checkers, so for now, I decided to have each king piece be worth two regular pieces when calculating the board’s score, though I may update this later.
Displaying The Win-Loss Record
The last thing I did this week was fairly simple. I used some of the extra space I gave myself in order to display the win-loss record of the player. I added this to the draw() method in play.py, in which I called the board’s play() method, as well as drew the valid moves available. In addition to this, it now displays the player’s total record. Next week, I will work on storing this information in a text file, as well as storing the specific results of the last 5 to 10 games in order to save the player’s progress rather than resetting it if the game closes.