![]() ![]() First, I tried looking up solutions, leading me to believe that forcing people to download the code then run it on their own terminal windows would be the most effective solution. However, now, I needed to take this project and make it accessible to everyone. I settled on having the CPUs prioritize passing their highest Heart cards and playing the highest card of the suit led, or if they were to start a trick, the highest card of a random suit.Īfter a few minor tweaks and adjustments, the project was complete, and I sent it to my teacher. While choosing the amount of CPUs a game was simple, programming the AI used to choose which cards to pass and then play proved to be difficult. However, I needed to add CPUs and allow the player to choose how many CPUs there would be in order to get a better grade for the project. Although, I did code that should a player obtain all the Heart cards and the Queen of Spades, then everyone else would gain points but not the original player. I tracked the cards each player won through arrays, then just simply checked if their stash contained cards that had Hearts or the Queen of Spades and gave them points for each one. One specifically for that first trick and then a general one that made the winner of the previous round go first.įinally, I needed to count the number of points after all the cards had been played. Since the player who had the Two of Clubs always had to go first at the start of each round, I made two different methods. The next part was the Trick, which was fairly complex. I first tracked the round number, since the direction the players pass in depends on that, before writing the code to not only allow players to choose which card they wanted to swap but also prevent them from selecting cards they don’t have in their deck. With that written, I worked on shuffling the deck of cards then dealing with the cards to players.Īfter that, I focused on how players could swap cards with each other and indicate which ones they wanted to swap with other players. A Card, Deck of Cards, Player, and Hearts class, which would allow me to more efficiently write the program. However, as it seemed difficult to do all of this in one class, I separated the entire program into four distinct classes. To begin the coding process, I wrote the code to shuffle and deal the cards to each player. There were other small parts, such as determining the number of points necessary to end the game or dealing the cards again after all the cards have been used up, but those issues were less complex than the four mentioned above. ![]() Finally, deciding the winner of the trick and counting up the points. The first part was the shuffling and dealing of the cards. I split the game into four major parts that I would tackle in order. Before I began programming, I wrote out the general roadmap of the game. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |