I am currently going through the Computer Science Career Path with Codecademy.com. The first section of the program is called CS101: Introduction to Programming and uses the Python programming language to teach basic computer programming concepts and skills. I had previously studied computer science in highschool and university on my way to my engineering degree, but that was so long ago I've wanted a refresher in the basics.
At the end of this section of the career path, there is a portfolio project where it is required to create a basic interactive game using Python that can be played in the terminal. For this I had decided that I was going to create a version of Battleship. My plan was to start out with a 1 player game and once I had the basic functionality in place, add the 2 player functionality.
I know some of my code could be made simpler with using additional modules, as Python has an almost unlimited list of modules that can be called upon to perform a task, but I wanted to practice with base Python as much as possible and limit external module usage.
After getting a basic 1 player version working, I tackled a 2 player version. Initially I had planned to use 2 different classes, one for ships and a second for the boards but quickly realized the code got easier if I added a third class for the player. Once the 2 player version was working I had to go back and re-write the 1 player logic to work with the modifications that were required to get 2 player to work.
All in all I am happy with the functionality of the game and am proud of how it turned out. In the future I may come back to this project to improve the input validation from the user as was as refactor the code to use external modules were it would improve efficiency.
You can find this project on my github page here. I look forward to continuing my coding journey.
Top comments (0)