Trying to get a Software Engineer Job.
Tags: gamedev, python, computerscience, codenewbie
Published: 2021-07-01 15:21:25

I am a disabled vet after an 11-year long career in the army who decided to change my career into computer science. Now a new senior, I envisioned myself with an internship already. That is not the case, unfortunately. During my time at Kennesaw State University, I participated in the SAIS 2020 conference and won Best Paper in my category. I was invited to publish the follow-up in their journal. Yet, I was not able to secure an interview.
With the limited information that I had, I concluded that my GitHub portfolio was too weak. I joined Codeacademy.com and started their computer science pro program. Based on their site, to complete their course, I must complete several Final projects that are portfolio-worthy. 
The first final project is a Hangman Game. I took the time to design an Automata diagram to simplify the coding process and reduce confusion.
![Automata Diagram 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36dngjme1iq7uyh6h0lt.png)
The first diagram covers the main states of the program. The second covers the logic inside of states 1P and 2P. 1P and 2P stand for one-player and two-player play through respectively.
![Automata Diagram 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ll1yvlgmy2g9ucqlkr6r.png)
The planning done, I coded the main.py first following the logic I laid out in the previous diagrams. I wanted to keep the main.py to only function calls. I devised an interface and back-end function scheme.
![main.py](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0oiiaq9xc66opej6bgb.png)
Next, I focused on the Interface.py functions. I limited them to the interactions with the player or players. Within these interface functions, I added all the objects and backend function calls needed.
![interface.py](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zg0gelmoj37mooxyvf3.png)
Then I coded the state management functions. All of them handle the returning of transition codes and the logic behind them.  The next set of codes were the game and player objects. 
![Game object structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpnfzwpgm17en3pbw8o3.png)
![Player object structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vajejfp00hqvx69d6acv.png)
I wanted to have logic for a basic AI within the Player object to give the single players a challenge. I used an if statement to split the instantiation of players to accommodate the AI. Lastly, I coded the AI. I used an elementary logic string: analyze the mask, reduce the number of possible words, pick a random word from the reduced list, pick a random letter from that word corresponding to an empty slot on the mask.
![Some of AI logic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6v30184omyr0z3oup2pi.png)
In essence, the code reduces the number of possible words every time the mask is updated and pics a letter from that list in an empty position on the mask. To increase competitiveness and strategy, the winner is the first player to input the last letter and the loser is the first player to error 6 times. With that in mind, you can intentionally answer worn in order to pick the last letter. Also, you cannot let the AI guess most of the missing letters and input the final letter. 
![Gameplay screenshots](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trnjbynvvq6n0btfg04s.png)
I played it a couple of times and I had my friends and family play it also. We all agree that the strategic element and the AI make for a challenging game. I want to extend a thank you to www.codeacademy.com for inspiring this project. It was challenging and fun to work on. In the end, I made animated ASCII art for the lost and win screen. If you want to check it out, go to my https://github.com/ernst-fanfan/Hangman-V1.0. This blog has no sponsors and no one is paying me to write it.