C++ Tutorial 15 - Making simple Tic Tac Toe game (Part 2)

  Рет қаралды 86,858

NVitanovic

NVitanovic

Күн бұрын

Пікірлер: 82
@simplyincorrigible7708
@simplyincorrigible7708 5 жыл бұрын
a nicer way to do ties is declare int tie = 9 in the main(); uses while(tie) instead of while(1) put tie -= 1; in the while loop. add if(tie
@thewiedzmin6062
@thewiedzmin6062 5 жыл бұрын
Nice follow up to the last one! I know its a little bloated but it will be an easy program to explain to the newbies and new learners! Thank you! 🙏
@keiseruskatherine
@keiseruskatherine 9 жыл бұрын
Love this channel but this music is killing me.
@Nick-jb4xi
@Nick-jb4xi 6 жыл бұрын
I like the music, but it should fade out before you are talking.
@emcjava9380
@emcjava9380 6 жыл бұрын
I think the matrix[0][0] can change to matrix[a\3][a%3]
@burninglegend8455
@burninglegend8455 3 жыл бұрын
how would I add a play again function for this?
@salehahmed2845
@salehahmed2845 4 жыл бұрын
how can i make a loop that rematch the game or display a new board to count the wins?
@karlhoehenstain4939
@karlhoehenstain4939 10 жыл бұрын
Excellent tutorials. This could be supplemented with some lines to reject the case of errors in the letter. This case appears as draw. Other. In a previous comment, I suggested a tutorial for using a DLL ( C++) from a Excel spreadsheet and consider the cases of 32 and 64 bits. regards
@shakin2009
@shakin2009 10 жыл бұрын
holy intro, a few seconds intro is all you need, i cant hear what your saying. otherwise good tut.
@odilesutsakhan2539
@odilesutsakhan2539 9 жыл бұрын
what's the equivalent of system() but for mac OS X users?
@roshanthapamagar1318
@roshanthapamagar1318 7 жыл бұрын
The function system(); is same for mac user user but the commands are different. Like in windows system("cls") clears the screen. You can replace the command inside the function which clears the screen or pauses the window. System("mac OS X terminal command here ");
@windowsphone8.1gamesandapp91
@windowsphone8.1gamesandapp91 10 жыл бұрын
Great tutorial, where are you from?
@ABugWithTheBigDreams
@ABugWithTheBigDreams 8 жыл бұрын
if i want to ask for replay the game then ? I tried to implement it by using goto statement but previous inputs are showing how to reset the game after one play ? Nice tutorial and Thank you
@vx3666
@vx3666 8 жыл бұрын
Boy, use a do-while statement. Something like: char ans; int main() { char ans; // Other statements do { // The game code here cout ans; cout
@arkasza2007
@arkasza2007 6 жыл бұрын
I've done that, and it's asking me with every move if I want to play again haha, how can I fix it?
@GHhost-m4j
@GHhost-m4j 6 жыл бұрын
you can put the contents of int main() into a function - game().Make another function that should replace the present elements of the matrix('x','o') with the initial elements of the matrix('1','2','3'...) or just make a new vector(Matrix[3][3]) and in the beginning of the game() function you should write matrix[3][3]=Matrix[3][3].Matrix [3][3] should have '1','2','3' ... as elements. In the end of the game() function you should put this code: if(n==9){ couta; if(a==1)game(); else return 0; } and the main function: int main(){ game(); }
@SaadAli-hw5oq
@SaadAli-hw5oq 8 жыл бұрын
I want to play with PC so what will I have to do??
@dawiddworak538
@dawiddworak538 8 жыл бұрын
Make function that will choose number of field.
@isbahprincess4871
@isbahprincess4871 8 жыл бұрын
i want to make it in runn ing form so what should i do?
@beri4138
@beri4138 7 жыл бұрын
Saad Ali void computermove(char matrix[3][3]) {again: int num1 = rand()%3; int num2 = rand()%3; if (matrix[num1][num2] != 'X' && matrix[num1][num2] != 'O') {matrix[num1][num2] = 'O'; return;} else goto again; { The idea is that we generate 2 random numbers that are between 0 and 2. We use those numbers as coordinates in the matrix. We check if the coordinates are already taken by a X or a O. If they arent taken, we put a O in that spot. If they are taken, we generate new coordinates.
@zielak0701
@zielak0701 5 жыл бұрын
Did you make a player versus a computer?
@girishsaravate242
@girishsaravate242 4 жыл бұрын
Hey i want X in red and O in green ,how to make it?
@biqbicle4982
@biqbicle4982 2 жыл бұрын
idk
@lightwaters
@lightwaters 6 жыл бұрын
its been just 30 days since i started c++..I made this whole game where user can enter name, check who wins or looses then press a key to restart...only thing is I took 1200 lines of code....lol.... using just loops and arrays no functions since thats where I am at ...but interesting to see the power of functions .thank you the source code file is no longer there can anyone paste it here if they have it ?..thx
@arism.accola7301
@arism.accola7301 6 жыл бұрын
When I input 10 the player changes and do not ask again for an input. How can i fix this problem?
@chuy6339
@chuy6339 8 жыл бұрын
i used your code on visual studio 2013 and the screen closes rapidly... need help
@akoskovacs7794
@akoskovacs7794 8 жыл бұрын
try to write system("pause"); at the end of your main()
@zrabatah
@zrabatah 8 жыл бұрын
What is the song?
@chuy6339
@chuy6339 8 жыл бұрын
how could i add a code so that the user can input their names?
@herooyyy
@herooyyy 8 жыл бұрын
+Jesus Rosales First of all u need to create a two string for both players and a void class where it asks for your names. Then just change the 'X' and 'Y' to the name of the strings
@antoniagrosan9504
@antoniagrosan9504 8 жыл бұрын
Hi! I have a problem: i tried to make the board, but when i compile it, it doesn't show anything, but a "?" in a square. I also wanted to konw what should i do to make system ("pause") and (cls) work, because it says "system was not declared in this scope". Thank youu
@9553954961
@9553954961 8 жыл бұрын
you have to add "include" . because system() exists in this library.
@antoniagrosan9504
@antoniagrosan9504 8 жыл бұрын
thank you!!
@pradyumnkejriwal3007
@pradyumnkejriwal3007 8 жыл бұрын
nope you have to include "cstdlib"
@sarvjeetrawat7719
@sarvjeetrawat7719 6 жыл бұрын
thanks its work
@Xitrii
@Xitrii 3 жыл бұрын
How to add a function where I can restart the game.
@biqbicle4982
@biqbicle4982 2 жыл бұрын
idk
@iTzNickGaming
@iTzNickGaming 8 жыл бұрын
Anyone can help me out this is for a school project, how can I make it so there is a mode for single player
@magicape1258
@magicape1258 4 жыл бұрын
3 years too late sorry but, you would have to make a randomizer for the bot
@ChidoriVRasengan97
@ChidoriVRasengan97 7 жыл бұрын
C++ Noob here, are there any algorithms and/or data structures used in this code, if so could you point those out please? Thanks.
@boranollana3336
@boranollana3336 6 жыл бұрын
Man what is there to ask about?
@boranollana3336
@boranollana3336 6 жыл бұрын
I saw this video before i knew shit in c++ and i did not understand shit. After half semester of studying i understood everything. Do not go and watch tutorials like this if you do not know anything at all.
@nilslorand
@nilslorand 9 жыл бұрын
One bug: If you press 1 (its X), then 1 Again (It says its occupied), then 2 (it turns into X not O. So the field then looks like that X X 3 4 5 6 7 8 9
@mavelrecord9676
@mavelrecord9676 6 жыл бұрын
That is not a bug its actually correct, the player changes(toggle ) after ever play which means losing one turn to wrong input gives an opportunity to the other player
@dustin4138
@dustin4138 6 жыл бұрын
mavel record lol this is known as correcting error "by canging the question not the error" lol
@codewithhb6989
@codewithhb6989 4 жыл бұрын
you are champion man
@yasir2481
@yasir2481 9 жыл бұрын
That's cool dude. thnx a lot.
@zhaoweilim9416
@zhaoweilim9416 7 жыл бұрын
Thanks for sharing this video !!! help me a lot !!!^_^
@alaaamr3869
@alaaamr3869 7 жыл бұрын
can u do another one 5*5 plzz
@alaakhaled188
@alaakhaled188 8 жыл бұрын
Thank You
@isbahprincess4871
@isbahprincess4871 8 жыл бұрын
which algorithm of artificial intelligence you are using?
@massimogiardina9138
@massimogiardina9138 8 жыл бұрын
none lol..
@komendantlopp9116
@komendantlopp9116 7 жыл бұрын
I do this in notelad++ and I don't know how to open this!
@yojojo351
@yojojo351 7 жыл бұрын
thanks
@karangupta7778
@karangupta7778 4 жыл бұрын
please help it gives me error on char player = 'X';
@vectordhruv8908
@vectordhruv8908 3 жыл бұрын
Sir why are you not uploading videos since 3 years
@amirkaric6313
@amirkaric6313 8 жыл бұрын
hy bro, could you send me a code?
@nilslorand
@nilslorand 9 жыл бұрын
I use codeblocks and system ("cls") does not work
@momogames3764
@momogames3764 9 жыл бұрын
+Nils Lorand #include
@momogames3764
@momogames3764 9 жыл бұрын
+Nils Lorand #include
@ABugWithTheBigDreams
@ABugWithTheBigDreams 8 жыл бұрын
+Nils Lorand i also use code blocks try this system("cls"); i added stdlib & it works for me add new libraries and try again :)
@johnwbyrd
@johnwbyrd 8 жыл бұрын
That's because the author of this tutorial does not understand cross-platform development.
@javirubaine8607
@javirubaine8607 8 жыл бұрын
What does ("cls") mean ?
@chuy6339
@chuy6339 8 жыл бұрын
and when i type one it turns into X but when i press 2 it turns into X again
@jamesa.646
@jamesa.646 3 жыл бұрын
Yea I am having the same problem rn
@MorgothResurrection
@MorgothResurrection 9 жыл бұрын
Well, this kind of coding and examples can show the importance of for or while loops.... It is a mess! It's got like 100+ lines for things that were not necessary and nobody would try to read through that XD
@cpthermes3703
@cpthermes3703 5 жыл бұрын
void TogglePlayer() { if (player == 'X') player = '0'; else player = 'X'; } this is the only part i do not understand, please explain! :(
@xor_255
@xor_255 5 жыл бұрын
if value of player='X' then change it to 'O' coz after x it's o's turn and when its value is anything other than x(like o) change it to X
@cpthermes3703
@cpthermes3703 5 жыл бұрын
@@xor_255 thank you, by the time u wrote the comment i have already gotten the idea. But thank you for your time and effort explaining :)
@TheLlamaCannon
@TheLlamaCannon 8 жыл бұрын
you didnt update the version of the game! lol nice tutorial bro
@peterkulik5943
@peterkulik5943 7 жыл бұрын
Ohh, copy-paste master course? :D
@renzpulvira3214
@renzpulvira3214 9 жыл бұрын
u talk like dendi.
@isbahprincess4871
@isbahprincess4871 8 жыл бұрын
plz help
@robsentadesse5250
@robsentadesse5250 6 жыл бұрын
I want play with computer
@A1exGx
@A1exGx 8 жыл бұрын
Oh god, the Win function is an example of terrible programming, using tens of ifs instead of repetitives such as for or while... the Input as well, it took him 200 lines of code when it could've been done efficiently in less than 100.
@yoshiman84156
@yoshiman84156 8 жыл бұрын
this is 100 lines and does every thing his program does
@ChidoriVRasengan97
@ChidoriVRasengan97 7 жыл бұрын
C++ Noob here, are there any algorithms and/or data structures used in this code, if so could you point those out please? Thanks.
C++ Tutorial 15 - Making simple Tic Tac Toe game (Part 1)
23:46
NVitanovic
Рет қаралды 289 М.
C++ Tutorial 18 - Simple Snake Game (Part 1)
11:16
NVitanovic
Рет қаралды 2,2 МЛН
C++ Tutorial 18 - Simple Snake Game (Part 3)
16:19
NVitanovic
Рет қаралды 588 М.
C++ Tutorial 18 - Simple Snake Game (Part 2)
12:24
NVitanovic
Рет қаралды 752 М.
C++ Tutorial 21 - Simple Pong Game (Part 1)
15:27
NVitanovic
Рет қаралды 198 М.
C++ Tutorial 21 - Simple Pong Game (Part 2)
14:40
NVitanovic
Рет қаралды 83 М.
C++ Tutorial 22 - Simple Hangman Game (Part 1)
16:29
NVitanovic
Рет қаралды 76 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 1,1 МЛН
C++ Tutorial 10 - Making a simple ship battle (sinking) game
18:56
C++ Tutorial 21 - Simple Pong Game (Part 3)
26:15
NVitanovic
Рет қаралды 102 М.