{"id":22349407,"url":"https://github.com/vtickner/codecademy-python-terminal-game","last_synced_at":"2025-03-26T11:21:35.538Z","repository":{"id":233860542,"uuid":"786921122","full_name":"VTickner/codecademy-python-terminal-game","owner":"VTickner","description":"This portfolio project was created as part of Codecademy's Computer Science Career Path course. The Python terminal game I have created is a Tic-Tac-Toe game.","archived":false,"fork":false,"pushed_at":"2024-04-22T15:21:02.000Z","size":416,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T12:34:50.180Z","etag":null,"topics":["classes-in-python","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VTickner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-15T14:54:54.000Z","updated_at":"2024-08-23T14:42:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"5eaf316c-71e6-48eb-bba0-3aa9160a2406","html_url":"https://github.com/VTickner/codecademy-python-terminal-game","commit_stats":null,"previous_names":["vtickner/codecademy-python-terminal-game"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VTickner%2Fcodecademy-python-terminal-game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VTickner%2Fcodecademy-python-terminal-game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VTickner%2Fcodecademy-python-terminal-game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VTickner%2Fcodecademy-python-terminal-game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VTickner","download_url":"https://codeload.github.com/VTickner/codecademy-python-terminal-game/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245641470,"owners_count":20648652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classes-in-python","python"],"created_at":"2024-12-04T11:08:12.838Z","updated_at":"2025-03-26T11:21:35.532Z","avatar_url":"https://github.com/VTickner.png","language":"Python","readme":"# Computer Science Projects - Portfolio Project: Python Terminal Game\n\nThis portfolio project was created as part of [Codecademy's](https://www.codecademy.com) Computer Science Career Path course.\n\n## Table of contents\n\n- [Project Overview](#project-overview)\n  - [Project objectives](#project-objectives)\n- [Python Terminal Game: Tic-Tac-Toe](#python-terminal-game-tic-tac-toe)\n  - [Screenshots](#screenshots)\n- [Process](#process)\n  - [Coding decisions](#coding-decisions)\n  - [What I learned](#what-i-learned)\n  - [Potential improvements to program](#potential-improvements-to-program)\n  - [Useful resources](#useful-resources)\n- [Author](#author)\n\n## Project Overview\n\n\"Welcome to the portfolio project in CS 101: Introduction to Programming! In this portfolio project, you will research, brainstorm, and build a basic terminal program of your choice for your friends and family to play with. After you finish building the program, you will create a blog post to share the program on a publication of your choice!\" - [Codecademy](https://www.codecademy.com)\n\n### Project objectives\n\n- Build a terminal program using Python.\n- Add at least one interactive feature using `input()`.\n- Use Git version control.\n- Use the command line and file navigation.\n- Write a technical blog post on the project.\n\n## Python Terminal Game: Tic-Tac-Toe\n\nFor this particular project I decided to create a Tic-Tac-Toe game.\n\n- Solution URL: [Tic-Tac-Toe Game](./tic_tac_toe.py)\n\n### Screenshots\n\n#### Game instructions:\n\n![Game instructions for Tic-Tac-Toe Python terminal game](./screenshot1.jpg)\n\n#### Players taking turns:\n\n![Players taking turns in Tic-Tac-Toe Python terminal game](./screenshot2.jpg)\n\n#### Overall scores:\n\n![Overall player scores and play again message in Tic-Tac-Toe Python terminal game](./screenshot3.jpg)\n\n## Process\n\n- Think of an idea for the python terminal game: Tic-Tac-Toe game.\n- Project brainstorming on how the game will work:\n  - Game to be turn based for 2 players to play within a terminal.\n  - Print out initial board game with instructions on how to play the game.\n  - Get names of players and assign which player is using O (marker) and which player is using X (marker).\n  - Play starts with each player taking turns stating location of where to place their marker.\n  - After each turn, reprint board game to show where the placed markers are.\n  - Check for when 3 matching markers are either in a row, column, or along a diagonal.\n    - If yes, print winner information.\n    - If all locations on board are full, print draw information.\n    - If neither the above are true then continue the game with the next player taking their turn.\n  - At the end of the game, get the answer as to whether players wish to play another round of the game.\n    - If yes, reset game with same player information.\n    - Otherwise end game.\n  - Keep total score of overall wins for each player.\n- Set up a GitHub repository.\n- Set up Git version control.\n- Write Tic-Tac-Toe game program.\n- Refactor program.\n- Create blog post about project. (This README file is my post about the project I have created.)\n\n### Coding decisions\n\nThere are a number of decisions I made as to how to approach and code this game. So below is an explanation as to the what and why I wrote the code in the way that I did.\n\n- As there are 2 players in the game I created a `class Player` to handle the player's `name`, `marker` (X or O) and `score`.\n- Initialising the game overall is split into two parts - `init_player()` and `init_game()`. This is so that the game can be reset with `init_game()` with using the same players, if the players select that they wish to play another game.\n- The grid board is drawn by using Unicode box drawing (line-drawing) characters. This created a nicer boxed image for the board.\n- The use of a `counter` was used in several places in the program for the following reasons:\n  - To determine whether `player1` (odd counter number) or `player2` (even counter number) is currently entering information.\n  - `check_won()` is only called if `counter \u003e=5` as that's the minimum amount of moves used between `player1` and `player2` before the first player can obtain 3 markers in a line.\n  - `board_full = True` when `counter \u003e 9` as that's the maximum amount of moves playable in a Tic-Tac-Toe game.\n- Error checking is done for:\n  - Input of player's name: `name` is not empty or only whitespace.\n  - Input of player's marker: `marker` is only X or O (upper or lower case are both accepted).\n  - Input of marker position `player_turn`:\n    - Position number from 1 to 9 only\n    - Position also has to be empty (i.e. with no marker already).\n\n### What I learned\n\n- There are Unicode codes for drawing lines that are useful for creating grid drawings in a terminal.\n- How to return multiple variables.\n- \\ enables a line to be split into multiple lines without causing syntax errors (for easier readability)\n- How to catch a value error with using:\n\n  ```python\n  try:\n    ...\n  except ValueError:\n    ...\n  ```\n\n### Potential improvements to program\n\n- Highlight the three markers that created the winning line.\n  - This would make it more visually obvious which markers made the winning line.\n  - Possible way of doing this, could be by changing the colour of the three winning markers when printed to the terminal screen.\n\n### Useful resources\n\n- [Wikipedia Article About Tic-Tac-Toe](https://en.wikipedia.org/wiki/Tic-tac-toe)\n- [Wikipedia Article About Box Drawing Characters](https://en.wikipedia.org/wiki/Box-drawing_characters)\n\n## Author\n\n- V. Tickner\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtickner%2Fcodecademy-python-terminal-game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvtickner%2Fcodecademy-python-terminal-game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtickner%2Fcodecademy-python-terminal-game/lists"}