While I had a working prototype of the game for my last blog post, the base of the code still had a lot of flaws that would make moving forward with the project impossible. In the original game code, the player is forced to be a human and always playing against a computer. The opponent’s reaction code is directly intertwined with the code for the players move. If the player attacks, the block code is automatically resolved, and the prompts the player receives, the action the player makes, and the moves the opponent makes are so tied together that it was impossible to separate them without pretty much rewriting the code.

https://github.com/nickhattwick/PlayingWithCards

The gamep3.py file holds the original game code, while the rest of the folder holds the new game code. Now the rungame.py file simply sets up the characters and kicks off the sequence drawing from other files, instead of simply having everything run from one file. Once players are created and the first player is decided, rungame.py calls prompts.py which sets up the turn and conditions for it to continue or end, before passing priority to the player to make their move by calling for the player‘s turn_prompt function. The three different types of players will each have their own unique function called by this function. A human player will be given text commands, the scripted AI will run a set strategy as before. The third type of player is going to be the one that implements the machine learning aspect by having a different way of choosing from options similar to the player.

There’s a little bit, I still want to fix in the code, but it’s ready to move on to the machine learning function. My mentor and I have started watching the Intro to Machine Learning course on Udacity and so far it doesn’t seem to be a classification problem or an SVM one. The Decision Tree section seems promising and will hopefully end up being a model I can use for this.

Overall, I’m feeling a lot more confident about the code. Since it is much cleaner and separated into parts so that it can be edited easily without messing up other sections. For the next steps, we’re continuing to watch through the Machine Learning course and during our last meeting, Nik showed me how to use decorators and write things into txt files so that the program has a way of keeping a log. Getting that working will definitely be a needed next step.

Other than that, it’s time to make the third turn_prompt section and get moving on the machine learning. I’ve got a ton of learning to do and am a bit nervous, but things should work out. I’m really curious about what the next blog post will be like.

Leave a Reply

Trending

Discover more from NikCreate

Subscribe now to keep reading and get access to the full archive.

Continue reading