<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sam</title>
    <description>The latest articles on DEV Community by Sam (@siderthecoder).</description>
    <link>https://dev.to/siderthecoder</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2296395%2Faa3de490-785c-4b88-9e75-014cd5160d90.jpg</url>
      <title>DEV Community: Sam</title>
      <link>https://dev.to/siderthecoder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siderthecoder"/>
    <language>en</language>
    <item>
      <title>A Simple Tic Tac Toe Terminal Game</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Mon, 28 Oct 2024 20:43:32 +0000</pubDate>
      <link>https://dev.to/siderthecoder/a-simple-tic-tac-toe-terminal-game-3mdj</link>
      <guid>https://dev.to/siderthecoder/a-simple-tic-tac-toe-terminal-game-3mdj</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/SidertheCoder/Python-Git-Repository/blob/main/TTT.py" rel="noopener noreferrer"&gt;https://github.com/SidertheCoder/Python-Git-Repository/blob/main/TTT.py&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am currently taking a computer science course on Codecademy.com and needed to make a terminal game for my portfolio project so I decided to make a game of Tic Tac Toe.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkehyx8mzcp2mwt8ktwpr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkehyx8mzcp2mwt8ktwpr.png" alt="Image description" width="230" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my code I first created a dictionary to hold what would go in each box of the Tic Tac Toe board making use of the fact that the [ ] in a list looks like a box when printed in a terminal. I then use that dictionary in the function create_grid to present the board as it currently is. Next I made a class named Player that gets the 2 player names and also checks who is going first based on a roll randomized between 1 and 6, whoever is first also gets to pick if they want X or O. After that is a win_check function that checks if any of the 8 winning combinations appear on the grid. Finally a definition to initialize game and all previous functions plays and repeats players picking where their X or O goes until the board is full or a winning combination is found and prints out an announcement of the winner.&lt;/p&gt;

&lt;p&gt;I am still quite new to Python so I'm aware I should've used comments more, remembered to commit more often and I could've made it look cleaner but I plan to continue to work so I can do those things better. Any tips or advice is always appreciated and thank you for reading.&lt;/p&gt;

</description>
      <category>python</category>
      <category>terminal</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
