@MasterEverything We are talking about beginning of the tutorial.
@penlavits33055 жыл бұрын
Was about to say the same.
@anonymoususer76633 жыл бұрын
@MasterEverything don't ask stupid questions quit being an idiot.
@whistlingwhistler95839 жыл бұрын
the music is a bit to loud at the start and couldn't hear the first part of the tutorial.
@Impulse_Photography6 жыл бұрын
I couldn't even hear a word he was saying - - he should just kill that music altogether - its about the program not the cool "LOUD" music effects.
@rbb79775 жыл бұрын
yOUR FACE IS LOUD!
@bdnoob37688 жыл бұрын
The moment after 3:48 made me laugh to tears for about 5min. I wasn't laughing at you, but the comedy of the whole situation: "When we run the program, it will display..." BIP BIP BIP ... *gibberish* ... BIP BIP ... trumpet. Classic.
@rijadheco5 жыл бұрын
That is a real world example of C++ and why it is a better programming language to learn and I mean "learn " ,It doesn't forgive, wrong code logic but syntax fine ? Fine let me bring you all the mess I can and you will learn after this mistake.Trust me you learn then :D
@GamerTheTurtle4 жыл бұрын
@@rijadheco careful, you'll get gatekeepers that keep trying to one up eachother before one tells you to learn binary first
@bern12234 жыл бұрын
I did this as an assignment like two years ago and have been beating around the bush coming back to it. I'm pleasantly surprised to now know it wasn't as bad as I remember! Thanks NVitanovic!
@Ryudan137 жыл бұрын
Fantastic Tutorial Sir! You made a very engaging lesson that employs coding, matrices, overwriting objects, and he he... debugging :)
@smettyboo6 жыл бұрын
Maybe some suggestions: This is a shorter way for the input function. With division and modulo, you can get the row and the column: void Input() { int a=0; int row,col; cout > a; row = (a-1) / 3; col = (a-1) % 3; matrix[row][col] = player; } And for the Win function, you can check the 3 row/column win in a loop: char Win() { char Winner = 'N'; for(int i = 0;i < 3;i++) // check if rows/columns are equal { if (matrix[i][0] == matrix[i][1] && matrix[i][0] == matrix[i][2]) Winner = matrix[i][0]; if (matrix[0][i] == matrix[1][i] && matrix[0][i] == matrix[2][i]) Winner = matrix[0][i]; } // check the two diagonal win possibilities if (matrix[0][0] == matrix[1][1] && matrix[0][0] == matrix[2][2]) Winner = matrix[0][0]; if (matrix[0][2] == matrix[1][1] && matrix[2][0] == matrix[1][1]) Winner = matrix[0][2]; return Winner; }
@ivan07994 жыл бұрын
I have been trying to do something similar for the win function, thanks
@MarysJanuszPazdzioch5 жыл бұрын
Another way you can check matrix.There is no need for checking 'X' and 'O' because after input we know who is playing now -then we check if won ( if won gameover = true so next loop wont happen) -then return player so we can print out in main who won. Thanks for your tutorial. You really use basic tools so I can understand what you are doing:-) if((matrix[0][0] == matrix[0][1]) && (matrix[0][1] == matrix[0][2])) gameover = true; else if(matrix[1][0] == matrix[1][1] && matrix[1][1] == matrix[1][2]) gameover = 1; else if(matrix[2][0] == matrix[2][1] && matrix[2][1] == matrix[2][2]) gameover = 1; else if(matrix[0][0] == matrix[1][1] && matrix[1][1] == matrix[2][2]) gameover = 1; else if(matrix[2][0] == matrix[1][1] && matrix[1][1] == matrix[0][2]) gameover = 1; else if(matrix[0][0] == matrix[1][0] && matrix[1][0] == matrix[2][0]) gameover = 1; else if(matrix[0][1] == matrix[1][1] && matrix[1][1] == matrix[2][1]) gameover = 1; else if(matrix[0][2] == matrix[1][2] && matrix[1][2] == matrix[2][0]) gameover = 1; return player;
@bryliang9 жыл бұрын
For the win function, would it be easier to use 'switch' statement rather than using a bunch of if's?
@Philogy9 жыл бұрын
13:51 you could just do if..... == player and put that before the toggleplayer() because only the current player will have inputed something
@radekmojzis98299 жыл бұрын
Instead of writting that chain of 10 else if you could do easily this a--; matrix[a/3][a%3] = player; just saying... you can use nice 2 lines of code instead of 10 else if... or this situation would be a good example for a switch use. but no offence, you are doing a great job.
@nol22228 жыл бұрын
Is that even more efficient, than using switch statements? Sry for the dumb question...
@smithcodes12438 жыл бұрын
Awesome dude !
@TehJMc8 жыл бұрын
How would you prevent overlaps using this instead, i'm finding it rather troublesome in figuring out?
It was an amazing video though I have a doubt. What if it's a draw? How are we going to terminate the loop?
@ahmadzubair36918 жыл бұрын
Oh man amazing ....this is very easy way to make a tic tac toe game ....i am second semester right now and i have to make a game without graphics ...and i tried alot but their is error every time ...but this video gave me a huge hint to make a game tic tac toe easily ... Thanks man ....😊
@austangbadboi21872 жыл бұрын
Awesome tutorial!! However is there a way to make it so that if a square has already been taken, the opposition can't take it anyways?
@elias198 жыл бұрын
First, i want to thank you for your amazing job making this beautifull videos. PLEASE, INCLUDE YOUR VIDEOS IN A PLAYLIST TO MAKE YOUR CHANNEL MORE ORGANIZED
@NVitanovic8 жыл бұрын
Thanks for the support, I've created a few playlists. Just check the channel directly.
@quanix19829 жыл бұрын
Why not just check if the 3 positions of the line in the matrix have the same values and then return that value as a winner? For example: if (matrix[0][0] == matrix[0][1] && matrix[0][0] == matrix[0][2]) return matrix[0][0]; Makes the code a lot shorter.
@InfernalJoy9 жыл бұрын
Erwin Bakkum it will show some error....i was doing this thing in my program and it was showing some errors... thats y i watch this video :)
@TheAtomicMango7 жыл бұрын
Quanix Studio might be because it's comparing locations as opposed to what's in them
@karlhoehenstain493910 жыл бұрын
Thank you very much. Excellent tutorial on C ++. The best of its kind on the web It would be interesting if you could add two tutorials, with the following topics: 1. Having a simple C ++ program that calculates, for example, c = a + b - Produce the corresponding DLL file, suitable to be exported to a file Exel (64 bits). - Declare the DLL (with its path) in VB _ Excel in a way that can be used in the book Excel (64 bits). - In two cells in a worksheet in the workbook Excel (64 bits) define the value of "a" and "b". - From another cell, call the DLL function to obtain c = a + b. 2. Same as above, but for Excel 32bit. Using a DLL in Excel and 32/64 bit issue is quite unclear to many people, among which I include myself Regards Carlos
@MarysJanuszPazdzioch5 жыл бұрын
Thanks for this tutorial mate. I've got strange problem.When I run that code on Visual Studio it doesn't show me matrix in while loop.I need to force to shut console but running that on Code::Blocks I haven't noticed any issues.Hmm?
@keenskee7 жыл бұрын
update your input with (no need of multiple if): i = (a-1) % 3; j = (a-1-i) / 3; matrix[j][i] = player;
@crystalkirana51096 жыл бұрын
Can you tech me how to get that recipe? I mean how to practice our habit to use math beside using multiple function?
@AndruRomin3 жыл бұрын
Just a friendly suggestion. Lower the volume of the music in the beginning. Cut the time in half from 40 seconds to no more then 12. Fade out the music and start your dialogue after...
@Sk-hm9qj2 жыл бұрын
Thank you so much Sir It's video help me to slove my confusion
@TheIronHeadRat10 жыл бұрын
Thank you for this tutorial.
@ratonpramanik8 жыл бұрын
I saw your every tutorial. And its better tutorial ever i see. Thanks for channel and videos. I requested you to plz upload some videos on car race. This is highly requested :)
@nilslorand9 жыл бұрын
If I type anything with system("cls");, it says that system was not declared in this scope (Codeblocks)
@shreyasrajapurkar38169 жыл бұрын
+Nils Lorand you need to include windows.h for that and it should work just fine. just #include :)
@nilslorand9 жыл бұрын
oh... ok :D
@djouze009 жыл бұрын
+Nils Lorand Why include windows.h ? It's just include the stdlib.h !
@valizeth40736 жыл бұрын
the system commands are in the windows "api" so you'll have to include
@parthmadan72122 жыл бұрын
My program works well except it doesn’t ‘break’ after the user wins. It declares who wins after all the rows and columns are filled. I tried everything to fix it :( Please help me!!!
@gillolface34354 жыл бұрын
Is there a way that all the lines of if else can be reduced. Im thinking of something like a for loop. But Im not experienced enough with using loops to know if it'll work.
@martinezdecap5 ай бұрын
Such a good video. Thank you
@azadpreetkaur9162 жыл бұрын
Thanks you soo much!! It helped me a LOT! :))
@oguzhanyilmaz6 жыл бұрын
Your channel is sooo helpful, thankyou
@nymeriablack52443 жыл бұрын
really helpful stuff out here
@tamasfreiberger11849 жыл бұрын
At checking if a player has won, would it work like this? char Win() { if(matrix[0][0] == matrix[1][0] == matrix[2][0]) return matrix[0][0]; ... } ?
@A1exGx8 жыл бұрын
No, c++ doesn't allow writing comparisons as you'd do in math, say for comparing more than 2 elements. That's why you have to compare each of them individually, like 1 with 2 and 2 with 3.
@infinteuniverse5 жыл бұрын
I haven't watched the video. I recently made a tic tac toe game on the console app. Could I use some of the same functions if I tried to make the same program in Visual Studio?
@infinteuniverse5 жыл бұрын
Interesting. The hardest part is making a function to check the win conditions. I wanted to see if I could use my code to make a graphical display for the game. My code is just a console app as well haha.
@yeshjadhav80827 жыл бұрын
Is this compare with vector programming .
@pavankumarb25824 жыл бұрын
Which app Ur using bro to do coading
@adityagawade75936 жыл бұрын
very very very awesome tutorial .....excellent explanation sir....i found it very helpful
@MrAnt60006 жыл бұрын
Thank you lot after seeing this tutorial i made the sudoku game pls make more games tutorial
@muhammadbinattique71672 жыл бұрын
whatever number i press, the program only prints X at the field and O is not being printed. Its just X everywhere.
@17osefalfanfadhil305 жыл бұрын
Great Tutorial !!!! Loved it, Subscribed
@DCG_429 жыл бұрын
I have question on how the char does it know when the char is x or when the char is O I am little bit confuse
@jpkprogrammingtutor72569 жыл бұрын
+sharingandc I do not understand your question. Also "char" does not know anything... did you mean variable? On which line or at which time in the video this happens?
@rickyfatty3632 жыл бұрын
I know this is 7 years late. There is a global variable char player = 'x'; so player who uses x always goes first the while loop in main is in the oreder while (1) { input(); Draw(); TogglePlayer(); } so what ever player x types first is where x goes then the program shows the result then TogglePlayer(); executes void TogglePlayer() { if (player == 'x') player = 'O'; else player = 'x'; } since you stated with char player = 'x'; it will swithc player to O on your next run through the function togglePlayer will execute and swith char back to x.
@prateeksingh572810 жыл бұрын
i need tu kno which software are u using in this video......
@FBHKHAN10 жыл бұрын
He is using Microsoft Visual Studio
@megamantis66069 жыл бұрын
Hello exactly what project type are you using? Im using visual studio 2013 by the way. Is it console application you are using?
@MrAlper7789 жыл бұрын
he is using the same program
@azadpreetkaur9162 жыл бұрын
i'm from germany and i needed this for my IT homework. What do you mean wit toggle player? It is just a name or has it a meaning? but thank you very much, you explained it very well and in detail. I understood it. Thank youu
@rasith_reacts_RR5 жыл бұрын
could you please explain the Void toggleplayer function I couldn't understand that
@furqanalibutt62414 жыл бұрын
how about if we have to play game against computer any help?
@jasonbolton20678 жыл бұрын
If 'X' or 'O' decide to go where the other has already gone, how might one prevent that.
@juice37024 жыл бұрын
You can make a global bool matrix so every value is false initially and then as you put the Xs ans Os the values switch to true. When choosing your number (though i went by typing the coordinates, i find numbering the matrix silly) the code has to verify if the value at the same coordinates in the bool matrix is 0, if it's false then you're good to go as the position is empty, but if it's true there's already something there and you have to choose another position. This solves both the probles of putting Xs over Os and Os over Xs, as well as putting Xs over Xs and Os over Os.
@rorshankcon27088 жыл бұрын
Why not use a break to do the check on the matrix points?
@LorenHelgeson8 жыл бұрын
Thanks for the excellent tutorial. Subscribed!
@geoffl6 жыл бұрын
I tried using a for loop in char Win(). It did not work well. Why did you skip that?
@ReNe8510009 жыл бұрын
Hello NVitanovic, I already checked my code several times and I still can't figure out why my player 'O' cannot win. Also, the system does not close so it keeps showing the name of the game and the instructions every time I enter a number. Can you please guide me on fixing this. I am using code blocks, Thanks!
@AmitSingh-ck3rp3 жыл бұрын
Thank you for this.
@zzz70117 жыл бұрын
how u make text bigger in the game because it so small.
@dobby13134 жыл бұрын
Dumb question but I thought you had to declare a function then define it. I thought the declaration told the computer how to call it in main. Could someone please explain how that works
@ahsam95807 жыл бұрын
Can you write this program again with the input of name from the user?
@COdExPerT7777 жыл бұрын
I'm getting an error when checking the win. In the if statements I'm getting an error C2106 and it says that value most be modifiable. It doesn't like the matrix part apparently. Can someone help me out?
@iTzNickGaming8 жыл бұрын
Hey, I need help and this for my computer science class. My teacher wants me to make a single player mode for tic tac toe meaning it will be the player the vs the computer. Any ideas to help me out??
@Abdullah_Haruna4 жыл бұрын
sorry i'm late but you would need to add an a.i. that is not too easy and not too hard.
@haiderhassan65347 жыл бұрын
Dear brother I have a problem when I put '"1" and any other number by the player1 it is converted into " X" but if I put the same number for player2 then the X converted into "O" what i can do for this problem plz help me ........
@aaroncruz26104 жыл бұрын
how do i make it if there is a tie
@sffsfssfsffs89366 жыл бұрын
how can i do this with struct?please help me
@nandanidalsaniya32514 жыл бұрын
Tysm for this idea n tutorial
@harryvaneyk709610 жыл бұрын
i dont think you made it so a player cant take a spot that is taken
@muskets57186 жыл бұрын
Harry van Eyk just do if a == 1 && (matrix[0][0] != ‘X’ && matrix[0][0] != ‘O’)
@juice37024 жыл бұрын
A global bool matrix with false for empty positions and true for occupied positions should solve the problem
@abhinandankaranth85972 жыл бұрын
my first game thank for the tutorial
@anonymoususer76633 жыл бұрын
You don't need else if. You can just use a bunch of if statements.
@mushtaqafridi67565 жыл бұрын
Why you not use switch instead of if else condition
@kleandojaupaj78199 жыл бұрын
it says TogglePlayer was not declared in this scope can u help plz??
@owaisishtiaq57798 жыл бұрын
What's the use of a Draw( ) function ? can u please tell me.
@jasonbolton20678 жыл бұрын
Draw first writes the name of the game for the player, then iterates through and displays both dimensions of the array using the for loops
@owaisishtiaq57798 жыл бұрын
Thank you
@owaisishtiaq57798 жыл бұрын
How can we make the game without uaing functions
@owaisishtiaq57798 жыл бұрын
I mean how can we make the without Using* functions. Did u hav any tutorial of it😃
@dantecorso71099 жыл бұрын
they sei ther was a problem on system("cls"); the error message say error stray"\240'in program ??????????
@ianzhang49149 жыл бұрын
don't be sorry I learned a lot form you. you should be proud
@mikeknight429 жыл бұрын
OMG TY SO MUCH .. i have been sick recently and i missed the class on arrays .. ty youtube you saved my butt again (dat j variable though... kinda confusing but i am noobish) *EDIT* actually ur variable choice is just utter bad practice .... probably just cause you arent solving an irl problem though
@godussopsama1443 жыл бұрын
Nice 😀❤️
@KralOnur9 жыл бұрын
hey, can you write tictactoe with different commandss
@archievethinking46926 жыл бұрын
thank you sir it should be very benificial for me
@yaswanthynsv94258 жыл бұрын
can i use #include ?
@Unusedmaterial8 жыл бұрын
yaswanth ynsv its only used in turboc. Do not use it.
@yaswanthynsv94258 жыл бұрын
Unusedmaterial thanks good to know ....hey can you suggest a good tutorial book for me? i want to learn C++ easily.
@nilslorand9 жыл бұрын
Can you somehow change the color of the text?
@MrAlper7789 жыл бұрын
+Nils Lorand Yes you can
@yoshiman841568 жыл бұрын
+Nils Lorand yes you can! #include then when you want to change the color do something like this system("color 0D"); its hex if you want to know the colors go to cmd and type in help color
@nilslorand8 жыл бұрын
Funny How I'm no Longer into Programming ^^ But still Thanks!
@yoshiman841568 жыл бұрын
I love programming I know python vary well and C++. I'm making a game in java now
@nilslorand8 жыл бұрын
Good Luck!
@gfaso50977 жыл бұрын
Nice video!
@destinliburd54557 жыл бұрын
i dont understand why there would be 8 if statements for placing X, if there are 9 possible positions where X could be placed..
@valizeth40736 жыл бұрын
why are u using global varibles?
@karlstelzer16466 жыл бұрын
thank you for the tutorial!
@safisafwan85986 жыл бұрын
nice one but how to make it short using 2d or 3d arrays
@zaidnaseer44764 жыл бұрын
Could someone please write the intro which was obscured by the music
@dantealighieri5368 жыл бұрын
matrix[0][a-1] = player; Is easier and more efficient than writing if statements for each integer. I'm only at 7:46 so I hope you notice this or explain why you didn't do that
@dantealighieri5368 жыл бұрын
Also coming from years of only scripting experience, your tutorials are helping me to pick this new horizon of "programming" up ridiculously fast to the point where I'm already catching your mistakes and finding ways to make code more efficient. Thank you so much.
@johnwayne27008 жыл бұрын
Superb one-liner, but to be able to get it this way, you have to know the elements of the array are allocated on the stack contiguously. So matrix[0][4] is the same as matrix[1][0].
@summanbutt2957 жыл бұрын
What to do if we want to draw the game like no player can win in this game?
@strodeum64609 жыл бұрын
What ide do you use?
@player1coding9588 жыл бұрын
+Strodeum He is using Visual Studios
@Noah-di3iu9 жыл бұрын
You should teach us to write a program that lets us play with the computer
@InfernalJoy9 жыл бұрын
Cool guy 14 YEAH THIS IS A BETTER IDEA :)
@jpkprogrammingtutor72569 жыл бұрын
+Noah8368 AI (artifial intelligence) tic tac toe?
@InfernoTNT8 жыл бұрын
how do u make the entire enviromment black?
@AaronTheYoonicorn8 жыл бұрын
+InfernoTNT tools > options > general > color theme
@Philogy9 жыл бұрын
and the paste bin isnt working
@bhoopendrasharma94746 жыл бұрын
Thank you for the video, I was expecting some kind of algorithm implementation like 'MinMax' or 'alpha Beta'...
@DavePoo5 жыл бұрын
You don't need MinMax or any other fancy algorithm to play tic-tac-toe as a perfect game can be played without any look ahead. You consider all your available moves and pick the best one, there is no need to look at possible counter moves.
@RandomBeefAR6 жыл бұрын
thnx for ur hard work for us srs dude thnx
@sieghart19313 жыл бұрын
very nice
@ahmedsohail98557 жыл бұрын
If u can make with 1d arraay
@adrikagupta55734 жыл бұрын
I have modified the code in some parts. But I am stuck due to a bug that I am not able to fix. The problem is that I want to convert 1 to '1'. But when I am using code like int a = 1; char p =char(1); The p is the character whose ASCII value is 1 and not '1' which is what I want. Anybody has an idea?
@inx18194 жыл бұрын
is it always a one digit number? if yes you could probably do something like this: char digits[] = {'0', '1, '2', '3', '4', '5', '6', '7', '8', '9'}; char x = digits[a];
@alen76486 жыл бұрын
How can I contact you ?
@nashrulnazrin90517 жыл бұрын
how to do if want to have 5games? please reply
@yazanqwaider89777 жыл бұрын
very very good
@benhardsim86296 жыл бұрын
anyone can explain me what is return 'x' for ??
@davidilunga23845 жыл бұрын
Big Hint!, lifesaver you are
@amirkaric63138 жыл бұрын
hy bro, could i get the code?
@aashikyadav28608 жыл бұрын
whenever i use the same number for X and O.. it gets overwritten.. so need to solve the problem