You are browsing as a guest. Sign up (or log in) to start making projects!

Tic Tac Toe

  • 5 Devlogs
  • 8 Total hours

Tic Tac Toe

Ship #1 Changes requested

I made a basic Tic-Tac-Toe game.

The most challenging part was the Minimax algorithm and designing the interface with ncurse library.

I am so proud of myself that i was able to pull it off.

Please keep in mind before juding that i am a completely beginner who is new into the space and it's my first project.

  • 5 devlogs
  • 8h
Try project → See source code →
Open comments for this post

1h 16m 37s logged

Hey Everyone,
I made some serious improvement in my project.
I used ncurses library to improve the UI and i fixed the repetitive board which before kept coming to a single board to look more asthetic and a premium finished product.

what bugs i faced:

bracket hell : i stuck because of a unwanted random bracket it has to be solved because it was ruining the rest of the code.

fogot to declare:

i forget to declare the prototype and update the rest of the code where i was using printBoard(board) to printBoard(board,cursor_row,cursor_col) to use the arrow keys to look more refine.

Hey Everyone,
I made some serious improvement in my project.
I used ncurses library to improve the UI and i fixed the repetitive board which before kept coming to a single board to look more asthetic and a premium finished product.

what bugs i faced:

bracket hell : i stuck because of a unwanted random bracket it has to be solved because it was ruining the rest of the code.

fogot to declare:

i forget to declare the prototype and update the rest of the code where i was using printBoard(board) to printBoard(board,cursor_row,cursor_col) to use the arrow keys to look more refine.

Replying to @pizza

1
Open comments for this post

1h 0m 44s logged

Added Difficulty bar:

Hey Everyone , After struggling to beat AI in my Tic-Tac-toe project i threw some restrictions to beat AI using Difficulty levels.

Bugs i encountered:
The Bracket: I somehow endup mixing all of the backets here and there and it took me a while to fix the trap and because of the bracket trap everytime user was playing PvP AI was playing instead of player 2 for which everytime player 2 was winnin but at the end somehow i managed to fix it.
SETTING up Difficulty Bar: when i was trying to set up the difficulty bar to easy it was taking random guesses but it was looking realistic because the grid has only 9 blocks to move but it was still better although i dropped the idea previously saying it was too dumb but yeah sometimes it makes sense and in Medium difficulty it uses 50% of it brain and the rest random guesses but the game changes at Hard i also call it Unbeatable level here you can rarely beat AI even if you try so hard you will meet draw everytime.

i am slowly trying to express myself,
Happy Coding hour
PIZZA:)

Added Difficulty bar:

Hey Everyone , After struggling to beat AI in my Tic-Tac-toe project i threw some restrictions to beat AI using Difficulty levels.

Bugs i encountered:
The Bracket: I somehow endup mixing all of the backets here and there and it took me a while to fix the trap and because of the bracket trap everytime user was playing PvP AI was playing instead of player 2 for which everytime player 2 was winnin but at the end somehow i managed to fix it.
SETTING up Difficulty Bar: when i was trying to set up the difficulty bar to easy it was taking random guesses but it was looking realistic because the grid has only 9 blocks to move but it was still better although i dropped the idea previously saying it was too dumb but yeah sometimes it makes sense and in Medium difficulty it uses 50% of it brain and the rest random guesses but the game changes at Hard i also call it Unbeatable level here you can rarely beat AI even if you try so hard you will meet draw everytime.

i am slowly trying to express myself,
Happy Coding hour
PIZZA:)

Replying to @pizza

0
Open comments for this post

2h 32m 3s logged

Implementation of Minimax:

Hey everyone, As you know i was trying to build computer vs player,

i tried to build the algorithm minimax but failed miserably last time so prepared myself and built the computer vs player so lets talk about what problems i faced during the build.

What Bugs i Faced ?

  • The Rage-Quitting AI: Once the AI stopped cheating, it started giving up entirely. I had a bug where I forgot to tell the Minimax algorithm what a “Draw” was. Because it didn’t know how to return a 0 for a tie, it assumed a full board was the worst possible outcome in the universe. If I trapped the AI in a fork where it knew it couldn’t win, it would literally skip its turn and refuse to play! I had to build a fallback block to force it to accept its fate.
  • Over writing issue: there was a time where i made a system where a player couldn’t overwrite ai but AI could and when i saw that it broke me and even after fixing the bug the same error kept coming cause it was stupit of me who didn’t save the new edition.
  • The Silent Fails: At one point, I tried to implement Player vs. Player mode, but when it was Player 2’s turn, the game would just print the board twice and loop back to Player 1. I had completely forgotten to write the scanf input logic for the second player! The code was just reaching that block.
  • Over powered AI: Now one mistake i made and don’t want anyone to repeat is to put a controller over AI so that you can realistically beat AI or u will be lost everytime and even if u try hard it will be draw at max.

What to fix

  • THE Controller for AI: as i said before i want to implement a difficulty system to reduce the power of AI.
  • Improving the interface: i want to improve the interface to make it more fun.
    Thanks for Reading,
    Happy coding :)

Implementation of Minimax:

Hey everyone, As you know i was trying to build computer vs player,

i tried to build the algorithm minimax but failed miserably last time so prepared myself and built the computer vs player so lets talk about what problems i faced during the build.

What Bugs i Faced ?

  • The Rage-Quitting AI: Once the AI stopped cheating, it started giving up entirely. I had a bug where I forgot to tell the Minimax algorithm what a “Draw” was. Because it didn’t know how to return a 0 for a tie, it assumed a full board was the worst possible outcome in the universe. If I trapped the AI in a fork where it knew it couldn’t win, it would literally skip its turn and refuse to play! I had to build a fallback block to force it to accept its fate.
  • Over writing issue: there was a time where i made a system where a player couldn’t overwrite ai but AI could and when i saw that it broke me and even after fixing the bug the same error kept coming cause it was stupit of me who didn’t save the new edition.
  • The Silent Fails: At one point, I tried to implement Player vs. Player mode, but when it was Player 2’s turn, the game would just print the board twice and loop back to Player 1. I had completely forgotten to write the scanf input logic for the second player! The code was just reaching that block.
  • Over powered AI: Now one mistake i made and don’t want anyone to repeat is to put a controller over AI so that you can realistically beat AI or u will be lost everytime and even if u try hard it will be draw at max.

What to fix

  • THE Controller for AI: as i said before i want to implement a difficulty system to reduce the power of AI.
  • Improving the interface: i want to improve the interface to make it more fun.
    Thanks for Reading,
    Happy coding :)

Replying to @pizza

0
Open comments for this post

30m logged

was trying to improve my project by allowing player to play with the computer but i just couldn’t finish it well so will come back with better solution and the random computer felt so dumb to me i don’t want anyone to experience that ! Yeah that’s it if any want want to share idea am Open to consider any ideas :)

was trying to improve my project by allowing player to play with the computer but i just couldn’t finish it well so will come back with better solution and the random computer felt so dumb to me i don’t want anyone to experience that ! Yeah that’s it if any want want to share idea am Open to consider any ideas :)

Replying to @pizza

0
Open comments for this post

2h 24m 32s logged

after joining cs50 a month ago am finally able to build a tic tac toe .Now its a basic but i will try to improve it and those semicolon became my greatest obstacle but still somehow i cracked it and will try to make it more interactive with automation and all

after joining cs50 a month ago am finally able to build a tic tac toe .Now its a basic but i will try to improve it and those semicolon became my greatest obstacle but still somehow i cracked it and will try to make it more interactive with automation and all

Replying to @pizza

1

Followers

Loading…