C++ TIC TAC TOE game for beginners ⭕

  Рет қаралды 24,567

Bro Code

Bro Code

Күн бұрын

Пікірлер: 53
@BroCodez
@BroCodez 2 жыл бұрын
#include #include void drawBoard(char *spaces); void playerMove(char *spaces, char player); void computerMove(char *spaces, char computer); bool checkWinner(char *spaces, char player, char computer); bool checkTie(char *spaces); int main() { char spaces[9] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}; char player = 'X'; char computer = 'O'; bool running = true; drawBoard(spaces); while(running){ playerMove(spaces, player); drawBoard(spaces); if(checkWinner(spaces, player, computer)){ running = false; break; } else if(checkTie(spaces)){ running = false; break; } computerMove(spaces, computer); drawBoard(spaces); if(checkWinner(spaces, player, computer)){ running = false; break; } else if(checkTie(spaces)){ running = false; break; } } std::cout
@k7nai
@k7nai 2 жыл бұрын
Hey 😳
@CầnbiếtKo-k5i
@CầnbiếtKo-k5i Жыл бұрын
bạn cần thêm dòng thư viện này nữa:#include
@ayushrai1705
@ayushrai1705 Жыл бұрын
what happens if the random function in computer moves picks a already filled space?
@shinayang-um7mk
@shinayang-um7mk 6 ай бұрын
1:51
@SalKulti
@SalKulti 3 ай бұрын
Why was !number used instead of just the norma, number 0?
@andarling9742
@andarling9742 Жыл бұрын
u could check winner by creating an an array of playermoves and check if there are 3 numbers that when num1 - num2 = num2 - num3 && num1-num2
@narayanswamyghanta315
@narayanswamyghanta315 Жыл бұрын
Looking at this game code, I understood that i lack in algorthimic thinking.
@guillermofrancella08
@guillermofrancella08 5 ай бұрын
Bro is back with the Code. Love you man.
@DawoodRizwan-k7f
@DawoodRizwan-k7f 2 ай бұрын
so good bro...
@ra2dsla7
@ra2dsla7 2 жыл бұрын
could u please explain the condition in details (!number > 0 || !number < 8)?
@shintiao1732
@shintiao1732 2 жыл бұрын
@koji is not the same, you try input the same number in player and you will know that.
@ali_gd_0161
@ali_gd_0161 Жыл бұрын
Think of it as ( !(number >0) || !(number < 8) The ! Operator changes the boolean value of the condition in front of it. E.g if it's true it becomes false
@nicko4140
@nicko4140 Жыл бұрын
@@ali_gd_0161 im confused how it loops after you select a non empty space. is the !number>0 || !number
@hupmitom5509
@hupmitom5509 Жыл бұрын
number = 1 the logic is the same. I think it is easier to understand.
@BroDevsRBLX
@BroDevsRBLX 11 ай бұрын
It just means as long as the number is 8 the loop will execute@@Kak-koi
@firestickman4605
@firestickman4605 Ай бұрын
thank you so much!
@RaviYadav-wm7tp
@RaviYadav-wm7tp Ай бұрын
30 mins in half way there, yet to create the winning criteria this was really helpful
@havocblast8737
@havocblast8737 4 ай бұрын
I ended up taking this idea an started working on a terminal submarine hunting game where you are trying to sink a submarine that is hiding/moving around under the water. I do need to figure out how to make drawing the board faster since I am using colors to print a grid of blue spaces in the terminal for the water. Board is currently 40 by 80. Thanks for bringing me down that rabbit hole lol
@HunaBopa
@HunaBopa Жыл бұрын
Bro, I have a question for you. Look, we did implement the minimax algorithm in Python and create an AI Tic Tac Toe player that is invincible. However, in C++ it's a daunting task for me. Can you help me implement the minimax algorithm in C++?
@baconheadhair6938
@baconheadhair6938 25 күн бұрын
i am the one who is invincible
@FrederikWollert
@FrederikWollert 6 ай бұрын
Good Video Bro.
@shintiao1732
@shintiao1732 2 жыл бұрын
if we never use the "char computer" in cheakWinner function ,why need to import this parameter?
@anvrag
@anvrag Жыл бұрын
for fun..
@kshitijsrivastava8312
@kshitijsrivastava8312 Жыл бұрын
For me its showing an exception report after performing the code, telling its a bug.
@CodeZ3253
@CodeZ3253 3 ай бұрын
you said originally you would have used switch statements but I thought they could only be used with ints
@baconheadhair6938
@baconheadhair6938 25 күн бұрын
They can be used with singlr digit things like ints and chars but not for things like strings
@jessechen2132
@jessechen2132 Жыл бұрын
When a user enters a letter rather than a number, the program crashes. Do you know how to solve it?
@anvrag
@anvrag Жыл бұрын
std::cin.clear(); fflush(stdin); use this two lines of powerful code which will help u to prevent crashes (use it below the input)
@FlorrioEggGaming
@FlorrioEggGaming Жыл бұрын
@@anvrag truly powerful code
@Toothless_Rides
@Toothless_Rides 8 ай бұрын
@@anvrag how? when I coded this in, it became an infinite loop...
@NovaStargazer23
@NovaStargazer23 28 күн бұрын
​@@Toothless_Rides Fflush(stdin) not work for linux Use while(cin.get() != ' ') { continue; }
@baconheadhair6938
@baconheadhair6938 25 күн бұрын
@@Toothless_Ridesyou could also make it accept a char value insteas and then just use isdigit() to make sure its a number and stoi() to convert it to an int
@gamsterilyass2952
@gamsterilyass2952 4 ай бұрын
Assembly ?
@triculex2854
@triculex2854 2 ай бұрын
while(!num>0 || !num
@diosinvicto
@diosinvicto Ай бұрын
I hate a double negation😂😂.... But this one's better while(number < 0 || number > 8)
@baconheadhair6938
@baconheadhair6938 25 күн бұрын
@@diosinvictoThat isnt a double negation, its just two negations. A double negation is negating a negation. Your code also isn’t „better“. It quite literally does the exact same thing
@charlo-d2
@charlo-d2 29 күн бұрын
Cannot be done in CodeBlocks?
@lalkad8561
@lalkad8561 Жыл бұрын
#include #include void drawBoard(char *spaces); void playerMove(char *spaces, char player); void computerMove(char *spaces, char computer); bool checkWinner(char *spaces, char player, char computer); bool checkTie(char *spaces); int main(){ char spaces[9] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}; char player = 'X'; char computer = 'O'; bool running = true; drawBoard(spaces); while(running){ playerMove(spaces, player); drawBoard(spaces); if(checkWinner(spaces, player, computer)){ running = false; break; } else if(checkTie(spaces)){ running = false; break; } computerMove(spaces, computer); drawBoard(spaces); if(checkWinner(spaces, player, computer)){ running = false; break; } else if(checkTie(spaces)){ running = false; break; } } std::cout
@Toothless_Rides
@Toothless_Rides 8 ай бұрын
why??? This was pointless😂
C++ dynamic memory explained for beginners 🧠
5:49
Bro Code
Рет қаралды 10 М.
Tic Tac Toe Game in C++
20:20
Kenny Yip Coding
Рет қаралды 11 М.
Yay, My Dad Is a Vending Machine! 🛍️😆 #funny #prank #comedy
00:17
兔子姐姐最终逃走了吗?#小丑#兔子警官#家庭
00:58
小蚂蚁和小宇宙
Рет қаралды 13 МЛН
UFC 308 : Уиттакер VS Чимаев
01:54
Setanta Sports UFC
Рет қаралды 710 М.
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 3,1 МЛН
Let's code a TIC TAC TOE game in python! ⭕
21:30
Bro Code
Рет қаралды 145 М.
C Tic Tac Toe game ⭕
20:08
Bro Code
Рет қаралды 166 М.
What is INHERITANCE in C++? 👨‍👧‍👧
11:05
Bro Code
Рет қаралды 14 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 269 М.
ASMR Programming - Spinning Cube - No Talking
20:45
Servet Gulnaroglu
Рет қаралды 4,1 МЛН
Make a C++ game FULL COURSE!
37:05
Low Level Game Dev
Рет қаралды 173 М.
C++ ROCK PAPER SCISSORS game for beginners 👊
13:07
Bro Code
Рет қаралды 12 М.
I made the same game in Assembly, C and C++
4:20
Nathan Baggs
Рет қаралды 773 М.
Python TIC TAC TOE Tutorial | Beginner Friendly Tutorial
25:15
Code Coach
Рет қаралды 202 М.
Yay, My Dad Is a Vending Machine! 🛍️😆 #funny #prank #comedy
00:17