DEV Community

Cover image for BATTLEFIELD: Python Terminal Game
vahanbznuni
vahanbznuni

Posted on

BATTLEFIELD: Python Terminal Game

Welcome to my first computer programming project ever - for Code Academy's Python Terminal Game Portfolio Project.
(https://www.codecademy.com/paths/computer-science/tracks/cspath-cs-101/modules/cspath-final-project/kanban_projects/python-terminal-game)

Project Objectives:

  • Build a terminal program using Python
  • Add at least one interactive feature using input()
  • Use Git version control
  • Use the command line and file navigation
  • Write a technical blog post on the project

Prerequisites:

  • Python
  • Git/GitHub
  • Command Line and File Navigation

The prompt was to create a terminal game using skills learned in the Computer Science Career Path, at the end of the CS101 course. Learned skills range from basic Python syntax, basic data structures and functions, to control flow, object-oriented programming (Python), and basic workflow, including command line and Git version control.

While the project prompt simply asked for a game with at least one user input request, my goal with the project became to use the maximum breadth of my imagination, learned skills, and lookup skills, to make sure the chosen game is playable, the code - readable, and as proficient as possible at this entry level of skill and knowledge. The only prompt given was the one presented above; all brainstorming, choice of overall architecture, algorithmic solution, coding, testing, debugging, integrating, optimizing, refactoring, expanding, and finalizing was done completely independent of CodeAcademy: with some consultation with developer friends.

First phase of development was focused on producing a working program, followed by a second phase of optimizing and developing the AI targeting functionality from "blind and dumb" to a little more advanced and algorithmic - making for actual gameplay, followed by a third stage of refactoring: making the code look more professional, including object-oriented modularity and structure (both visual and logical), as well as addition of detailed - if perhaps a bit pedantic - documentation and commenting.

During the First and Second stage, focus was on minimizing research & lookup, and maximizing creative problem-solving, while the Third stage involved a little bit of consultation, and lookup, with focus on code appearance and structure (since functionality was already programmed).

The Program's docstrings document all structural elements, while the introductory text presents the gameplay. In summary, main.py runs the program. Elements package contains the bulk of the data and functionality - mostly through objects. Battlefield module handles the actual "Battlefield" grid - both for data storage of coordinates, as well as display; the Player module includes all the interactive functionality. Ships get their own module & class, as do string variables and exceptions.

Please note, additional revisions, refactoring, and expansion is possible, which may change the structure and functionality from that described here.

The SourceCode can be found here:
https://github.com/vahanbznuni/Battlefield_Game

Thank You for reading.

(Resolved){P.S. There is a new current issue with running main.py from Windows CMD, as noted in README file. The game can be successfully ran in a text editor.}

Edit 1: the CMD issue has been solved.
Edit 2: GitHub repository- previously set to private - has been reset to “Public.”

Top comments (0)