{"id":74251,"date":"2019-12-13T10:44:14","date_gmt":"2019-12-13T05:14:14","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=74251"},"modified":"2019-12-13T10:44:14","modified_gmt":"2019-12-13T05:14:14","slug":"python-game-project-tic-tac-toe","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/","title":{"rendered":"Python Tic Tac Toe &#8211; Develop a Game in Python"},"content":{"rendered":"<p>It&#8217;s no doubt, you must have played Tic Tac Toe in your school days and every one of us loves to play the game. You will be surprised to know that the game of Tic Tac Toe is known to exist since ancient Egypt times.<\/p>\n<p>With this Python project by TechVidvan, we are going to build an interactive game of Tic Tac Toe where we\u2019ll learn new things along the way.<\/p>\n<h3>What is Tic Tac Toe?<\/h3>\n<p>Tic Tac Toe is one of the most played games and is the best time killer game that you can play anywhere with just a pen and paper. If you don\u2019t know how to play this game don\u2019t worry let us first understand that.<\/p>\n<p>The game is played by two individuals. First, we draw a board with a 3&#215;3 square grid. The first player chooses \u2018X\u2019 and draws it on any of the square grid, then it\u2019s the chance of the second player to draw \u2018O\u2019 on the available spaces. Like this, the players draw \u2018X\u2019 and \u2018O\u2019 alternatively on the empty spaces until a player succeeds in drawing 3 consecutive marks either in the horizontal, vertical or diagonal way. Then the player wins the game otherwise the game draws when all spots are filled.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/tic-tac-toe-project-in-python.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-74259\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/tic-tac-toe-project-in-python.gif\" alt=\"tic tac toe - project in python\" width=\"370\" height=\"480\" \/><\/a><\/p>\n<h3>Python Tic Tac Toe &#8211; Project Details<\/h3>\n<p>The interesting Python project will be build using the pygame library. We will be explaining all the pygame object methods that are used in this project. Pygame is a great library that will allow us to create the window and draw images and shapes on the window. This way we will capture mouse coordinates and identify the block where we need to mark \u2018X\u2019 or \u2018O\u2019. Then we will check if the user wins the game or not.<\/p>\n<h3>Download Tic Tac Toe Project code<\/h3>\n<p>Please download the full source code of tic tac toe project:\u00a0<strong><a href=\"https:\/\/techvidvan.s3.amazonaws.com\/python-projects\/tic-tac-toe-python-project.zip\">Tic Tac Toe Python Project<\/a><\/strong><\/p>\n<h3>Prerequisites<\/h3>\n<p>To implement this game, we will use the basic concepts of Python and Pygame which is a Python library for building cross-platform games. It contains the modules needed for computer graphics and sound libraries. To install the library, you can use pip installer from the command line:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pip install pygame<\/pre>\n<h2>Steps to Build a Python Tic Tac Toe Game<\/h2>\n<p>First, let&#8217;s check the steps to build Tic Tac Toe program in Python:<\/p>\n<ul>\n<li>Create the display window for our game.<\/li>\n<li>Draw the grid on the canvas where we will play Tic Tac Toe.<\/li>\n<li>Draw the status bar below the canvas to show which player\u2019s turn is it and who wins the game.<\/li>\n<li>When someone wins the game or the game is a draw then we reset the game.<\/li>\n<\/ul>\n<p>We need to run our game inside an infinite loop. It will continuously look for events and when a user presses the mouse button on the grid we will first get the X and Y coordinates of the mouse. Then we will check which square the user has clicked. Then we will draw the appropriate \u2018X\u2019 or \u2018O\u2019 image on the canvas. So that is basically what we will do in this Python project idea.<\/p>\n<h3>1. Initializing game components<\/h3>\n<p>So let\u2019s start by importing the pygame library and the time library because we will use the <strong>time.sleep()<\/strong> method to pause game at certain positions. Then we initialize all the global variables that we will use in our Tic Tac Toe game.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import pygame as pg,sys\nfrom pygame.locals import *\nimport time\n\n\n#initialize global variables\nXO = 'x'\nwinner = None\ndraw = False\nwidth = 400\nheight = 400\nwhite = (255, 255, 255)\nline_color = (10,10,10)\n\n#TicTacToe 3x3 board\nTTT = [[None]*3,[None]*3,[None]*3]<\/pre>\n<p>Here, the TTT is the main 3&#215;3 Tic Tac Toe board and at first, it will have 9 None values. The height and width of the canvas where we will play the game is 400&#215;400.<\/p>\n<h3>2. Initializing Pygame window<\/h3>\n<p>We use the pygame to create a new window where we&#8217;ll play our Tic Tac Toe game. So we initialize the <a href=\"https:\/\/www.pygame.org\/\">pygame<\/a> with <strong>pg.init()<\/strong> method and the window display is set with a width of 400 and a height of 500. We have reserved 100-pixel space for displaying the status of the game.<\/p>\n<p>The <strong>pg.display.set_mode()<\/strong> initializes the display and we reference it with the screen variable. This screen variable will be used whenever we want to draw something on the display.<\/p>\n<p>The pg.display.set_caption method is used to set a name that will appear at the top of the display window.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#initializing pygame window\npg.init()\nfps = 30\nCLOCK = pg.time.Clock()\nscreen = pg.display.set_mode((width, height+100),0,32)\npg.display.set_caption(\"Tic Tac Toe\")\n<\/pre>\n<h3>3. Load and transform images<\/h3>\n<p>The Python project uses many images like the opening image that will display when the game starts or resets. The X and O images that we will draw when the user clicks on the grid. We load all the images and resize them so that they will fit easily in our window.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#loading the images\nopening = pg.image.load('tic tac opening.png')\nx_img = pg.image.load('x.png')\no_img = pg.image.load('o.png')\n\n#resizing images\nx_img = pg.transform.scale(x_img, (80,80))\no_img = pg.transform.scale(o_img, (80,80))\nopening = pg.transform.scale(opening, (width, height+100))<\/pre>\n<h3>4. Define the functions<\/h3>\n<p>Now we create a function that will start the game. We will also use this function when we want to restart the game. In pygame, the <strong>blit()<\/strong> function is used on the surface to draw an image on top of another image.<\/p>\n<p>So we draw the opening image and after drawing, we always need to update the display with <strong>pg.display.update()<\/strong>. When the opening image is drawn, we wait for 1 second using <strong>time.sleep(1)<\/strong> and fill the screen with white colour.<\/p>\n<p>Next, we draw 2 vertical and horizontal lines on the white background to make the 3&#215;3 grid. In the end, we call the <strong>draw_status()<\/strong> function<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def game_opening():\n    screen.blit(opening,(0,0))\n    pg.display.update()\n    time.sleep(1)\n    screen.fill(white)\n\n    # Drawing vertical lines\n    pg.draw.line(screen,line_color,(width\/3,0),(width\/3, height),7)\n    pg.draw.line(screen,line_color,(width\/3*2,0),(width\/3*2, height),7)\n    # Drawing horizontal lines\n    pg.draw.line(screen,line_color,(0,height\/3),(width, height\/3),7)\n    pg.draw.line(screen,line_color,(0,height\/3*2),(width, height\/3*2),7)\n    draw_status()\n<\/pre>\n<p>The <strong>draw_status()<\/strong> function draws a black rectangle where we update the status of the game showing which player\u2019s turn is it and whether the game ends or draws.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def draw_status():\n    global draw\n\n    if winner is None:\n        message = XO.upper() + \"'s Turn\"\n    else:\n        message = winner.upper() + \" won!\"\n    if draw:\n        message = 'Game Draw!'\n\n    font = pg.font.Font(None, 30)\n    text = font.render(message, 1, (255, 255, 255))\n\n    # copy the rendered message onto the board\n    screen.fill ((0, 0, 0), (0, 400, 500, 100))\n    text_rect = text.get_rect(center=(width\/2, 500-50))\n    screen.blit(text, text_rect)\n    pg.display.update()<\/pre>\n<p>The <strong>check_win()<\/strong> function checks the Tic Tac Toe board to see all the marks of \u2018X\u2019 and \u2018O\u2019. It calculates whether a player has won the game or not. They can either win when the player has marked 3 consecutive marks in a row, column or diagonally. This function is called every time when we draw a mark \u2018X\u2019 or \u2018O\u2019 on the board.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def check_win():\n    global TTT, winner,draw\n\n    # check for winning rows\n    for row in range (0,3):\n        if ((TTT [row][0] == TTT[row][1] == TTT[row][2]) and(TTT [row][0] is not None)):\n            # this row won\n            winner = TTT[row][0]\n            pg.draw.line(screen, (250,0,0), (0, (row + 1)*height\/3 -height\/6),\\\n                              (width, (row + 1)*height\/3 - height\/6 ), 4)\n            break\n\n    # check for winning columns\n    for col in range (0, 3):\n        if (TTT[0][col] == TTT[1][col] == TTT[2][col]) and (TTT[0][col] is not None):\n            # this column won\n            winner = TTT[0][col]\n            #draw winning line\n            pg.draw.line (screen, (250,0,0),((col + 1)* width\/3 - width\/6, 0),\\\n                          ((col + 1)* width\/3 - width\/6, height), 4)\n            break\n\n    # check for diagonal winners\n    if (TTT[0][0] == TTT[1][1] == TTT[2][2]) and (TTT[0][0] is not None):\n        # game won diagonally left to right\n        winner = TTT[0][0]\n        pg.draw.line (screen, (250,70,70), (50, 50), (350, 350), 4)\n\n    if (TTT[0][2] == TTT[1][1] == TTT[2][0]) and (TTT[0][2] is not None):\n        # game won diagonally right to left\n        winner = TTT[0][2]\n        pg.draw.line (screen, (250,70,70), (350, 50), (50, 350), 4)\n\n    if(all([all(row) for row in TTT]) and winner is None ):\n        draw = True\n    draw_status()<\/pre>\n<p>The drawXO(row, col) function takes the row and column where the mouse is clicked and then it draws the \u2018X\u2019 or \u2018O\u2019 mark. We calculate the x and y coordinates of the starting point from where we&#8217;ll draw the png image of the mark.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def drawXO(row,col):\n    global TTT,XO\n    if row==1:\n        posx = 30\n    if row==2:\n        posx = width\/3 + 30\n    if row==3:\n        posx = width\/3*2 + 30\n\n    if col==1:\n        posy = 30\n    if col==2:\n        posy = height\/3 + 30\n    if col==3:\n        posy = height\/3*2 + 30\n    TTT[row-1][col-1] = XO\n    if(XO == 'x'):\n        screen.blit(x_img,(posy,posx))\n        XO= 'o'\n    else:\n        screen.blit(o_img,(posy,posx))\n        XO= 'x'\n    pg.display.update()\n    #print(posx,posy)\n    #print(TTT)\n<\/pre>\n<p>The <strong>userClick()<\/strong> function is triggered every time the user presses the mouse button.<\/p>\n<p>When the user clicks the mouse, we first take the x and y coordinates of where the mouse is clicked on the display window and then if that place is not occupied we draw the \u2018XO\u2019 on the canvas. We also check if the player wins or not after drawing \u2018XO\u2019 on the board.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def userClick():\n    #get coordinates of mouse click\n    x,y = pg.mouse.get_pos()\n\n    #get column of mouse click (1-3)\n    if(x&lt;width\/3):\n        col = 1\n    elif (x&lt;width\/3*2):\n        col = 2\n    elif(x&lt;width):\n        col = 3\n    else:\n        col = None\n\n    #get row of mouse click (1-3)\n    if(y&lt;height\/3):\n        row = 1\n    elif (y&lt;height\/3*2):\n        row = 2\n    elif(y&lt;height):\n        row = 3\n    else:\n        row = None\n    #print(row,col)\n\n    if(row and col and TTT[row-1][col-1] is None):\n        global XO\n\n        #draw the x or o on screen\n        drawXO(row,col)\n        check_win()\n<\/pre>\n<p>The last function is the reset_game(). This will restart the game and we also reset all the variables to the beginning of the game.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def reset_game():\n    global TTT, winner,XO, draw\n    time.sleep(3)\n    XO = 'x'\n    draw = False\n    game_opening()\n    winner=None\n    TTT = [[None]*3,[None]*3,[None]*3]<\/pre>\n<p>5. Run the tic tac toe game forever<\/p>\n<p>To start the game, we will call the <strong>game_opening()<\/strong> function. Then, we run an infinite loop and continuously check for any event made by the user. If the user presses mouse button, the MOUSEBUTTONDOWN event will be captured and then we will trigger the <strong>userClick()<\/strong> function. Then if the user wins or the game draws, we reset the game by calling<strong> reset_game()<\/strong> function. We update the display in each iteration and we have set the frames per second to 30.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">game_opening()\n\n# run the game loop forever\nwhile(True):\n    for event in pg.event.get():\n        if event.type == QUIT:\n            pg.quit()\n            sys.exit()\n        elif event.type == MOUSEBUTTONDOWN:\n            # the user clicked; place an X or O\n            userClick()\n            if(winner or draw):\n                reset_game()\n\n    pg.display.update()\n    CLOCK.tick(fps)<\/pre>\n<p>Hooray! The game is complete and ready to play. Save the source code with the <strong>tictactoe.py<\/strong> file name and run the file.<\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/tic-tac-toe-starting-in-python-project-with-source-code.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-74257\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/tic-tac-toe-starting-in-python-project-with-source-code.png\" alt=\"tic tac toe starting in python project with source code\" width=\"406\" height=\"535\" \/><\/a><\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/tic-tac-toe-game-in-python-project-idea.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-74258\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/12\/tic-tac-toe-game-in-python-project-idea.png\" alt=\"tic tac toe game in python project idea\" width=\"406\" height=\"534\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>With this project in Python, we have successfully made the Tic Tac Toe game. We used the popular pygame library for rendering graphics on a display window. We learned how to capture events from the keyboard or mouse and trigger a function when the mouse button is pressed. This way we can calculate mouse position, draw X or O on the display and check if the player wins the game or not. I hope you enjoyed building the game.<\/p>\n<p><em><strong>Now, it&#8217;s time to work on another interesting project &#8211; <a href=\"https:\/\/techvidvan.com\/tutorials\/project-in-python-typing-speed-test\/\">Python Project on Typing Speed Test<\/a><\/strong><\/em><\/p>\n<p>Any difficulty while working on the Python project with source code? Do share in the comment section. Our TechVidvan experts are always there to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s no doubt, you must have played Tic Tac Toe in your school days and every one of us loves to play the game. You will be surprised to know that the game of&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":74275,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[1089,1090,483,1091,1092,1093,1094,1095],"class_list":["post-74251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-advanced-python-project","tag-python-mini-project","tag-python-project","tag-python-project-examples","tag-python-project-with-source-code","tag-python-projects-for-final-year","tag-python-projects-for-practice","tag-tic-tac-toe"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Tic Tac Toe - Develop a Game in Python - TechVidvan<\/title>\n<meta name=\"description\" content=\"Build Python Tic Tac Toe project using Pygame library with easy steps &amp; source code. The Python project covers the Tic Tac Toe concept &amp; process to build the game in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Tic Tac Toe - Develop a Game in Python - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Build Python Tic Tac Toe project using Pygame library with easy steps &amp; source code. The Python project covers the Tic Tac Toe concept &amp; process to build the game in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-13T05:14:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/python-game-project-on-tic-tac-toe.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Tic Tac Toe - Develop a Game in Python - TechVidvan","description":"Build Python Tic Tac Toe project using Pygame library with easy steps & source code. The Python project covers the Tic Tac Toe concept & process to build the game in Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/","og_locale":"en_US","og_type":"article","og_title":"Python Tic Tac Toe - Develop a Game in Python - TechVidvan","og_description":"Build Python Tic Tac Toe project using Pygame library with easy steps & source code. The Python project covers the Tic Tac Toe concept & process to build the game in Python.","og_url":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2019-12-13T05:14:14+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/python-game-project-on-tic-tac-toe.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Python Tic Tac Toe &#8211; Develop a Game in Python","datePublished":"2019-12-13T05:14:14+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/"},"wordCount":1357,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/python-game-project-on-tic-tac-toe.jpg","keywords":["Advanced python project","Python mini project","Python project","python project examples","python project with source code","python projects for final year","Python projects for practice","Tic Tac Toe"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/","url":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/","name":"Python Tic Tac Toe - Develop a Game in Python - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/python-game-project-on-tic-tac-toe.jpg","datePublished":"2019-12-13T05:14:14+00:00","description":"Build Python Tic Tac Toe project using Pygame library with easy steps & source code. The Python project covers the Tic Tac Toe concept & process to build the game in Python.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/python-game-project-on-tic-tac-toe.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2019\/12\/python-game-project-on-tic-tac-toe.jpg","width":802,"height":420,"caption":"python game project on tic tac toe"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/python-game-project-tic-tac-toe\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Python Tic Tac Toe &#8211; Develop a Game in Python"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/74251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=74251"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/74251\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/74275"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=74251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=74251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=74251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}