(Part 4) Visual Studio Winform Tic Tac Toe Tutorial with AI (Artificial Intelligence)

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 พ.ย. 2024

ความคิดเห็น • 100

  • @Joseph5860
    @Joseph5860 7 ปีที่แล้ว +1

    Chris, as a fellow programmer, thanks for all the time and effort you put into this project. I learned a lot from your videos about Windows application development. Keep up the great work!

  • @GreekFireWarrior
    @GreekFireWarrior 4 ปีที่แล้ว

    Great tutorial to follow as a complete beginner.
    Had watched quite a few videos of C# for beginners, so thought i'd move onto a game.
    This was greatly structured and easy to follow and learn along

  • @derekmerida9007
    @derekmerida9007 4 ปีที่แล้ว +3

    oh man, this video is fantastic, it's 2020 and it helped me a lot, thank you very much and you have a new sub

  • @fist0009
    @fist0009 9 ปีที่แล้ว +7

    Chris,
    Your patience is beyond me. Not only do you show how to build this Tic Tac Toe program you take the time to cater to your commenters (i.e.3a and 4). I'm a really old guy (50+) and just decided to go get my BS in IT to keep my mind engaged. Your tutoring methods are so easy to follow and you explain stuff as well. Thanks for making these videos. I do have a question for you though. Once you create this game how do you get it out of Visual Studio and onto any PC? Like a packaged program I guess.

    • @chrismerritt7291
      @chrismerritt7291  9 ปีที่แล้ว +3

      D Henson , Thanks for the kind words. With these really simple projects (like most of mine are), you can just go into the bin/debug folder of your project (after you have run it - i.e., the play button), and you'll see an executable (exe file). You can just double click to run the application. If you were looking to actually distribute what you build in a more professional way, you could add Install Shield's limited edition to Visual Studio, but it's a lot more involved. Not necessarily difficult, but takes some effort and a decent amount of trial and error to get it right. :)

  • @ivybridge0110
    @ivybridge0110 10 ปีที่แล้ว +12

    Thanks Chris.
    Can you make Tutorial TicTacToe with client server?

  • @mailee0610
    @mailee0610 11 หลายเดือนก่อน

    I need to add a socket using the TCP/IP protocol, how can I accomplish this?

  • @sarfrazjahan8615
    @sarfrazjahan8615 3 ปีที่แล้ว

    Chris.
    I think You should make another video in which Describe this please..either player 1's turn or player 2's turn

  • @azizfredyanto3700
    @azizfredyanto3700 5 ปีที่แล้ว +3

    Why when the user wins, the computer also wins?

  • @skyz3ra
    @skyz3ra 9 ปีที่แล้ว

    amazing videos, i kinda understood how windows forms works waaay better thanks to you.

  • @zakyzulkarnain6477
    @zakyzulkarnain6477 6 ปีที่แล้ว +2

    Chris, i will say Thank you so much, because your tutorials help me to make my assignment :))
    ill wait your new tutorial how to make another simple game with AI

  • @dr.floopybazzi2835
    @dr.floopybazzi2835 4 ปีที่แล้ว +1

    is there a way to make it where the player gets to pick 2 player or vs computer

  • @aroosasiddiqui2165
    @aroosasiddiqui2165 7 ปีที่แล้ว +1

    would u please provide us the complete project?

  • @Kacprate
    @Kacprate 6 ปีที่แล้ว

    Great tutorials that help to get into Winforms, good job!

  • @polinayatsina2242
    @polinayatsina2242 9 ปีที่แล้ว +2

    Hi,Chris, I have some questions. Your videos about Tic Tac Toe really helps me, but I got an error in the computer_make_move method where I was getting an unhandled null reference exception, method disableButtons doesn't working. When i finish the game, empty buttons stay active and I can click on them. How can I solve this problem? Please,help me(

    • @scy216
      @scy216 4 ปีที่แล้ว +2

      I know this comment is 4 years old, but maybe someone else is wondering about the disableButtons method not working. You need to move the try catch in the disableButtons method inside the foreach, just like Chris did with the "New Game" menu item click event in part 2.

    • @corbinwilson3781
      @corbinwilson3781 2 ปีที่แล้ว

      @@scy216 there’s another way to do it. Again I know this comment is 2 years old, but I was making a program and I got stuck on that same part. For about 4 hours, until I finally found another solution
      foreach ( Control c in this.Controls )
      {
      TextBox tb = c as TextBox;
      if ( null != tb )
      {
      }
      }
      I then switched text box to button and it worked.

  • @usama57926
    @usama57926 6 ปีที่แล้ว +1

    sir please make another video in which make the game advance i mean use pictures and high graphics.

  • @davidalves236
    @davidalves236 3 ปีที่แล้ว

    Great tutorial. But going for the corner square when you are player 2 is suicide, the only way player 1 doesn't win is if player 2 plays middle square on turn 2. You should only go for the corners if you are player 1. Assuming both players are playing the optimal way of course.

  • @studypartner2280
    @studypartner2280 5 ปีที่แล้ว

    Thanks Chris for sharing this type of excellent work !

  • @ghsegal
    @ghsegal 6 ปีที่แล้ว

    Would you be able to show how one might be able to display the game board or past games once called upon? for example, file, load game history, ( and in this new page you could click on game 1, game 2 etc.. and it would show the outcome of each game selected?

  • @nikolaoskosmatos8098
    @nikolaoskosmatos8098 8 ปีที่แล้ว

    Great job Chris! Thanks for that example!

  • @christianjunetubera665
    @christianjunetubera665 9 ปีที่แล้ว

    Hi thanks for your tutorial ...has a bug that the computer moves twice ? ...

  • @RCPMione
    @RCPMione 10 ปีที่แล้ว +2

    I've got a little problem with the against_the_computer and There_Is_a_winner system. When player against the computer if player wins the computer make a move and is also declared a winner. Is there a way to lock out the computer when the winner is announce? Tried a couple of idea just made it crash.

    • @ber2I
      @ber2I 7 ปีที่แล้ว

      hi there. this is my prblem too, anyway do you already know how to fix it? thanks.

  • @1000минус7-л
    @1000минус7-л 7 ปีที่แล้ว +3

    move.PerformClick(); What id it?

  • @adventuretube5588
    @adventuretube5588 7 ปีที่แล้ว

    hi Chris thank you for providing this videos its helping me so much but I have a question how can I convert it to an app by Android and iOS and if I want to let two forms the one where you write your name, press play how can I make it play with computer I have seen this video but I don't want to remove the second form. thank you for the knowledge you provided I hope you upload more about website such as streaming online videos and apps how its done again thank you I hope you answer my question

  • @AssurtiveTurtle
    @AssurtiveTurtle 10 ปีที่แล้ว

    Thanks for this :) I have one more request. I am making a virtual OS (Basic logon screen, media player, browser etc)and Im stuck on how to call a class and run it from an icon. So when I click on my Tic-Tac-Toe icon (I have this entire program in a seperate class) I dont know how to open the program in a window?

  • @Savo963
    @Savo963 8 ปีที่แล้ว

    Hi Chris,
    Can you add writing win results in some database(postgresql or some other) and make some list of best players?

  • @benoittheminerandgamer
    @benoittheminerandgamer 7 ปีที่แล้ว

    I am trying to make the game tic-tac-toe (human against computer) and I do not know how to progress progressBar when it is the pc that plays. When it is me who plays and I click on one of the 9 buttons the progressebar goes all well. Can you help me

  • @ber2I
    @ber2I 7 ปีที่แล้ว

    hi Chris. please help me how can i dissable buttons if theres a winner when im playing with ai because ai can make a move after i win. I try my best but still i cant figure out how to dissable buttons. please help me with this matter. thanks

  • @pentalfakos
    @pentalfakos 9 ปีที่แล้ว

    Thanks for the tutorial. What do I do if I want to make a button, that says vs Computer?

  • @سعیدهعارفی-ذ9ص
    @سعیدهعارفی-ذ9ص 8 ปีที่แล้ว

    I used it in my own Tic Tac Toe but in vb.net.
    Thank you

  • @kikiparab9308
    @kikiparab9308 10 ปีที่แล้ว +1

    hiii chris your videos are really rocking & made easy to understand but please show us how to put our app in windows store and earn money(app monetization) or publish our app into our website.!!!! your help would be appreciated

  • @ngocinh497
    @ngocinh497 7 ปีที่แล้ว

    You can help me how to create an AI engine for the tic tac toe game with Hill-Climbing search???

  • @willoxstudigm5379
    @willoxstudigm5379 10 ปีที่แล้ว +2

    thanks chris

  • @Chornelioez
    @Chornelioez 7 ปีที่แล้ว

    Sir, can I know which Algorithm you are using? Negamax or Minimax Algorithm?

  • @nadzrinpuad1283
    @nadzrinpuad1283 7 ปีที่แล้ว

    chris can you make Ai move in minimax algorithm to be more understand

  • @patmull1
    @patmull1 10 ปีที่แล้ว

    You did awesome job! Thank you and keep on making tutorial videos

  • @maciqos8136
    @maciqos8136 6 ปีที่แล้ว

    Hello, i know its a bit late but.. I have problem that application is working but when i start it and its against computer.. Its same as against player can somebody help me?

  • @hylkenicola9180
    @hylkenicola9180 6 ปีที่แล้ว

    The app stopt working after adding all this cant even press any button to fill a box anymore

  • @jp-wi8xr
    @jp-wi8xr 9 ปีที่แล้ว

    Hey Chris,
    I just wanted to modify the program a bit and wanted the computer to be 'X'. So for the first turn, if i use the "computer_make_move" method the AI always clicks the "A1" button as expected. So I decided to use the "look_for_open_space" method but this time the AI always clicks the "C3" button. So i was wondering as to why does this happen and is there a way by which we can select a button at random?
    Thanks.

    • @chrismerritt7291
      @chrismerritt7291  9 ปีที่แล้ว

      Piyush Jaiswal, always clicking C3, is due to the order of the controls in the list [foreach (Control c in Controls)]. You could randomize this. I modified my look_for_open_space method and added a shuffleArray method. See pastebin for the code: pastebin.com/GpLSDc1N.

    • @jp-wi8xr
      @jp-wi8xr 9 ปีที่แล้ว

      Chris Merritt, thanks a ton again for all your help and videos.

  • @JohnMarcVincentTolin
    @JohnMarcVincentTolin 8 ปีที่แล้ว

    how to put an exception by asking the player if he wants to play again?? can someone teach me how to do this??

  • @notsumo
    @notsumo 8 ปีที่แล้ว +2

    if the game ends in a draw, it throws an unhandled exception! Could someone please tell me how to over come this? the specific error is below. Thanks in advance (o_o)
    "An unhandled exception of type 'System.NullReferenceException' occurred in WindowsFormsApplication1.exe" is what the error says.

    • @BnBProductionzzz
      @BnBProductionzzz 8 ปีที่แล้ว +9

      This is due to the code move.PerformClick(); because when a draw occurs there are no more spaces for the computer to click so therefore it doesn't have an "object" to click. To overcome this issue create an if statement containing the following >> if (turn_count != 9)
      move.PerformClick();
      Using this if statement makes the computer only perform a click during the first 8 turns and when you have your final turn in order to create a draw (which is the 9th turn count) the computer will not perform another click due to the code "!=9:". This should hopefully fix your error, please let me know if you have any problems implementing the code!

    • @flavioschuricht7404
      @flavioschuricht7404 8 ปีที่แล้ว

      Thank you soooo much, i spent 2 hours to finde the error

    • @barnabas_666
      @barnabas_666 7 ปีที่แล้ว +1

      End of button_click event could looks like:
      if ((!turn) && (against_computer) && (turn_count < 9))
      computer_make_move();

    • @hylkenicola9180
      @hylkenicola9180 6 ปีที่แล้ว

      When you play B2, C3, B1 and finally A3 the program encounters an error:
      System.NullReferenceException: "The object reference is not set on an instance of an object." so that does fix the draw but not the move it doesn't know to make when the game is practically a draw but fields are yet to be filled. The move counter will not solve this issue

    • @zakyzulkarnain6477
      @zakyzulkarnain6477 6 ปีที่แล้ว

      @@BnBProductionzzz thankyou so much, cause your information can help each other :))

  • @22sbm
    @22sbm 7 ปีที่แล้ว

    chriss can u make computer vs human tictac toe game

  • @musacanuysal9976
    @musacanuysal9976 9 ปีที่แล้ว

    Hi Chris,
    We are students from Turkey and we have project about tic-toc-toe also we made codes to part 3 but computer ai doesn't work.Part 4 codes not working. Can you send us the full codes thanks for answer

  • @shmindersinghchatha6412
    @shmindersinghchatha6412 10 ปีที่แล้ว +1

    ""Amazing video really helpful to all ""but i think there is a little problm in code
    i just add new method in b/w yours named "look_for_center" and under that B2 button is assigned b'coz there is only one center named B2.but when i play vs A.I
    and after pressing following buttons A1,C3,C2, i give the opportunity to AI to win , but he didnt make tic take toe , instead make a foolish move ,...kindly plz help

  • @tikarobinson9335
    @tikarobinson9335 9 ปีที่แล้ว

    hey, i have a program using java where I have to make a tic tac toe game using the human user against the computer user could you please help me.. I'm so lost

  • @DevilEgg_1
    @DevilEgg_1 4 ปีที่แล้ว

    Hi there ive got a problem, when i win against the computer it awards the computer a point too how do i fix this

    • @SkinnyRat
      @SkinnyRat 4 ปีที่แล้ว

      You probably swapped round the conditions for X to win and O to win. He covered this in part 1. It's the inverse of what you think. If there is a winner and it's you're turn, the computer wins. When it's not you're turn, you win. It sounds confusing.

  • @kitioyi
    @kitioyi 6 ปีที่แล้ว

    your code are use minimax algorithm?

  • @teodornikolov6520
    @teodornikolov6520 10 ปีที่แล้ว

    Ohh i get stuck in some bad error. When all buttons are click i got error Unhadled ....something like that :S

  • @พัชชราภรณ์ทองรอง

    How do look_for_open_space methods of work?

  • @bw2247
    @bw2247 7 ปีที่แล้ว

    great tutorial!

  • @zulnajibmukhlis1247
    @zulnajibmukhlis1247 6 ปีที่แล้ว

    hello sir, what is the algorithm you use for this AI ???

  • @phamluc2661
    @phamluc2661 9 ปีที่แล้ว

    Thanks Chris very much!

  • @mirza_irtiza
    @mirza_irtiza 6 ปีที่แล้ว

    is it minmax algorithm ?

  • @cirohernandez6538
    @cirohernandez6538 3 ปีที่แล้ว

    alguna persona que pueda pasar el programa xd

  • @miloperez138
    @miloperez138 9 ปีที่แล้ว

    Can you do this on visual basic.net?

  • @M0481
    @M0481 9 ปีที่แล้ว

    I found a guaranteed win method and I was wondering if you could help me with it.
    Basically when my first three moves are A3, C1 and C3 then i'll always win.
    For some reason the AI does not block my row.
    I checked your code and I can't seem to find the solution.
    Any chance you could check it out?
    P.S. I copied the code from your pastebin so I did not forget anything.

    • @M0481
      @M0481 9 ปีที่แล้ว

      I should have watched the entire video before commenting this since I see you also noticed this problem at the end of the video.
      How would you go about this? Would this be fixed by making another if statement inside the other if statements where it basically checks if one sequal has been blocked the turn before?

    • @MrAceDuece
      @MrAceDuece 9 ปีที่แล้ว

      M0481 the reason for this has more to do with tic tac toe logic, and then the "AI"s logic. in ANY tic tac toe game, if the first player is able to select three corners as their first three moves, that first player will always be the winner. Is becomes impossible to block all future winning moves

  • @nancysaleh8131
    @nancysaleh8131 8 ปีที่แล้ว

    please i want the source code

  • @farhanzahid9785
    @farhanzahid9785 8 ปีที่แล้ว

    can u send source code please

  • @nomarxistspls90
    @nomarxistspls90 8 ปีที่แล้ว

    hi, I the AI doesn't do anything but i get no errors? could someone please help? thanks.
    namespace TicTacToe
    {
    public partial class TicTacToe : Form
    {
    bool turn = true;// true = X turn; false = Y turn
    bool against_computer = false;
    int turn_count = 0;
    //static String player1, player2;
    public TicTacToe()
    {
    InitializeComponent();
    }
    /*
    public static void SetPlayerNames(String n1, String n2)
    {
    player1 = n1;
    player2 = n2;
    }
    */
    private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
    {
    MessageBox.Show(" Created by Jack Roper, 6/10/2016.", "Tic Tac Toe about..");
    }
    private void exitToolStripMenuItem_Click(object sender, EventArgs e)
    {
    Application.Exit();
    }
    private void button_click(object sender, EventArgs e)
    {
    Button b = (Button)sender;
    if (turn)
    b.Text = "X";
    else
    b.Text = "O";
    turn = !turn;
    b.Enabled = false;
    turn_count++;
    checkForWinner();
    if ((!turn) && (against_computer))
    {
    computer_make_move();
    }
    }
    private void computer_make_move()
    {
    //priority 1: get tick tac toe
    //priority 2: block x tic tac toe
    //priority 3: go for corner space
    //priority 4: pick open space
    Button move = null;
    //look for tic tac toe opportunities
    move = look_for_win_or_block("O"); //look for win
    if (move == null)
    {
    move = look_for_win_or_block("X"); //look for block
    if (move == null)
    {
    move = look_for_corner();
    if (move == null)
    {
    move = look_for_open_space();
    }//end if
    }//end if
    }//end if
    move.PerformClick();
    }
    private Button look_for_open_space()
    {
    Console.WriteLine("Looking for open space");
    Button b = null;
    foreach (Control c in Controls)
    {
    b = c as Button;
    if (b != null)
    {
    if (b.Text == "")
    return b;
    }//end if
    }//end if
    return null;
    }
    private Button look_for_corner()
    {
    Console.WriteLine("Looking for corner");
    if (A1.Text == "O")
    {
    if (A3.Text == "")
    return A3;
    if (C3.Text == "")
    return C3;
    if (C1.Text == "")
    return C1;
    }
    if (A3.Text == "O")
    {
    if (A1.Text == "")
    return A1;
    if (C3.Text == "")
    return C3;
    if (C1.Text == "")
    return C1;
    }
    if (C3.Text == "O")
    {
    if (A1.Text == "")
    return A3;
    if (A3.Text == "")
    return A3;
    if (C1.Text == "")
    return C1;
    }
    if (C1.Text == "O")
    {
    if (A1.Text == "")
    return A3;
    if (A3.Text == "")
    return A3;
    if (C3.Text == "")
    return C3;
    }
    if (A1.Text == "")
    return A1;
    if (A3.Text == "")
    return A3;
    if (C1.Text == "")
    return C1;
    if (C3.Text == "")
    return C3;
    return null;
    }
    private Button look_for_win_or_block(string mark)
    {
    Console.WriteLine("Looking for win or block: " + mark);
    //HORIZONTAL TESTS
    if ((A1.Text == mark) && (A2.Text == mark) && (A3.Text == ""))
    return A3;
    if ((A2.Text == mark) && (A3.Text == mark) && (A1.Text == ""))
    return A1;
    if ((A1.Text == mark) && (A3.Text == mark) && (A2.Text == ""))
    return A2;
    if ((B1.Text == mark) && (B2.Text == mark) && (B3.Text == ""))
    return B3;
    if ((B2.Text == mark) && (B3.Text == mark) && (B1.Text == ""))
    return B1;
    if ((B1.Text == mark) && (B3.Text == mark) && (B2.Text == ""))
    return B2;
    if ((C1.Text == mark) && (C2.Text == mark) && (C3.Text == ""))
    return C3;
    if ((C2.Text == mark) && (C3.Text == mark) && (C1.Text == ""))
    return C1;
    if ((C1.Text == mark) && (C3.Text == mark) && (C2.Text == ""))
    return C2;
    //VERTICAL TESTS
    if ((A1.Text == mark) && (B1.Text == mark) && (C1.Text == ""))
    return C1;
    if ((B1.Text == mark) && (C1.Text == mark) && (A1.Text == ""))
    return A1;
    if ((A1.Text == mark) && (C1.Text == mark) && (B1.Text == ""))
    return B1;
    if ((A2.Text == mark) && (B2.Text == mark) && (C2.Text == ""))
    return C2;
    if ((B2.Text == mark) && (C2.Text == mark) && (A2.Text == ""))
    return A2;
    if ((A2.Text == mark) && (C2.Text == mark) && (B2.Text == ""))
    return B2;
    if ((A3.Text == mark) && (B3.Text == mark) && (C3.Text == ""))
    return C3;
    if ((B3.Text == mark) && (C3.Text == mark) && (A3.Text == ""))
    return A3;
    if ((A3.Text == mark) && (C3.Text == mark) && (B3.Text == ""))
    return B3;
    //DIAGONAL TESTS
    if ((A1.Text == mark) && (B2.Text == mark) && (C3.Text == ""))
    return C3;
    if ((B2.Text == mark) && (C3.Text == mark) && (A1.Text == ""))
    return A1;
    if ((A1.Text == mark) && (C3.Text == mark) && (B2.Text == ""))
    return B2;
    if ((A3.Text == mark) && (B2.Text == mark) && (C1.Text == ""))
    return C1;
    if ((B2.Text == mark) && (C1.Text == mark) && (A3.Text == ""))
    return A3;
    if ((A3.Text == mark) && (C1.Text == mark) && (B2.Text == ""))
    return B2;
    return null;
    }
    private void checkForWinner()
    {
    bool there_is_a_winner = false;
    //horizontal checks
    if ((A1.Text == A2.Text) && (A2.Text == A3.Text) && (!A1.Enabled))
    there_is_a_winner = true;
    else if ((B1.Text == B2.Text) && (B2.Text == B3.Text) && (!B1.Enabled))
    there_is_a_winner = true;
    else if ((C1.Text == C2.Text) && (C2.Text == C3.Text) && (!C1.Enabled))
    there_is_a_winner = true;
    //vertical checks
    else if ((A1.Text == B1.Text) && (B1.Text == C1.Text) && (!A1.Enabled))
    there_is_a_winner = true;
    else if ((A2.Text == B2.Text) && (B2.Text == C2.Text) && (!A2.Enabled))
    there_is_a_winner = true;
    else if ((A3.Text == B3.Text) && (B3.Text == C3.Text) && (!A3.Enabled))
    there_is_a_winner = true;
    //diagonal checks
    else if ((A1.Text == B2.Text) && (B2.Text == C3.Text) && (!A1.Enabled))
    there_is_a_winner = true;
    else if ((A3.Text == B2.Text) && (B2.Text == C1.Text) && (!C1.Enabled))
    there_is_a_winner = true;

  • @hoseinmousavi771
    @hoseinmousavi771 8 ปีที่แล้ว

    someone please give the source code

  • @thandoimvu
    @thandoimvu 4 ปีที่แล้ว

    Wow thank you ❤

  • @hanbrouwer6717
    @hanbrouwer6717 10 ปีที่แล้ว

    Very nice tutorial but your tic tac toe strategy is terrible. When the fist player opens, for example, with A1, then never answer with C3. His second move will be C1 or A3. You had to block that with B1 or A2. Than the player plays A3 or C1 and you had to block in two places. You lose.

  • @christianarthmanila7948
    @christianarthmanila7948 8 ปีที่แล้ว

    source code please

  • @801yaoichan
    @801yaoichan 8 ปีที่แล้ว

    Thanks!!!!

  • @Parth9PTL
    @Parth9PTL 9 ปีที่แล้ว

    Hey Chris , I dont get why The AI crashes when its a draw vs. Computer. Does it happen to yu?

  • @bayernmunich327
    @bayernmunich327 8 ปีที่แล้ว

    Where is the mistake in this code?
    private void computer_move()
    {
    Button move = null;
    move = look_for_win_or_block("O");
    if (move == null)
    {
    move = look_for_win_or_block("X");
    if (move == null)
    {
    move = look_for_corner();
    if (move == null)
    {
    move = look_for_open_space("O");
    }
    }
    }
    move.PerformClick();
    }

    • @dumypop90
      @dumypop90 6 ปีที่แล้ว

      move=look_for_open_space();

  • @danbush3048
    @danbush3048 10 ปีที่แล้ว +4

    thx Chris very helpful im ready for school now but I got an error in the computer_make_move method where I was getting an unhandled null reference exception but all is good I fix it with a try/catch :D here's the code for anyone who might have the same problem.
    try
    {
    Button move = null;
    //look for tic tac toe opportunities
    move = look_for_win_or_block("O"); //look for win
    if (move == null)
    {
    move = look_for_win_or_block("X"); //look for block
    if (move == null)
    {
    move = look_for_corner();
    if (move == null)
    {
    move = look_for_open_space();
    }//end if
    }//end if
    }//end if
    move.PerformClick();
    }
    catch { }

    • @kyrierevival3658
      @kyrierevival3658 6 ปีที่แล้ว

      if (turn_count != 9)
      move.PerformClick();
      shorter code~

  • @elkhazi
    @elkhazi 6 ปีที่แล้ว

    If anyone is still around here and looking for a real challenging addition to this code:
    pastebin.com/McDBpDnK
    Add an additional priority for the computer to check middle button first, if empty, select it
    then iterate through the rest of the priorities

    • @alexfrawley1833
      @alexfrawley1833 6 ปีที่แล้ว

      I can beat urs every time with top left, then bottom right, then bottom left, then either other one

  • @hanbrouwer6717
    @hanbrouwer6717 10 ปีที่แล้ว

    I started several times with this tutorial and halfway the project everything worked fine. I feft the project open for the night and Microsoft updated everything but all the method where put out of there context and it was one big file without + or - for the methods. I started again and scipt some things about de second form. Now a have a system that works fine but when there is a draw I get an message like this:
    Zie het einde van dit bericht voor meer informatie over het aanroepen
    van JIT-foutopsporing (Just In Time) in plaats van dit dialoogvenster.
    ************** Tekst van uitzondering **************
    System.NullReferenceException: De objectverwijzing is niet op een exemplaar van een object ingesteld.
    bij TikTakTor.Form1.computer_make_move() in c:\Users\Han\Documents\Visual Studio 2012\Projects\TikTakTor\TikTakTor\Form1.cs:regel 83
    bij TikTakTor.Form1.button_click(Object sender, EventArgs e) in c:\Users\Han\Documents\Visual Studio 2012\Projects\TikTakTor\TikTakTor\Form1.cs:regel 55
    bij System.Windows.Forms.Control.OnClick(EventArgs e)
    bij System.Windows.Forms.Button.OnClick(EventArgs e)
    bij System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    bij System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    bij System.Windows.Forms.Control.WndProc(Message& m)
    bij System.Windows.Forms.ButtonBase.WndProc(Message& m)
    bij System.Windows.Forms.Button.WndProc(Message& m)
    bij System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    bij System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    bij System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ************** Geladen assembly's **************
    mscorlib
    Assembly-versie: 4.0.0.0
    Win32-versie: 4.0.30319.18444 built by: FX451RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    TikTakTor
    Assembly-versie: 1.0.0.0
    Win32-versie: 1.0.0.0
    CodeBase: file:///C:/Users/Han/Documents/Visual%20Studio%202012/Projects/TikTakTor/TikTakTor/bin/Debug/TikTakTor.exe
    ----------------------------------------
    System.Windows.Forms
    Assembly-versie: 4.0.0.0
    Win32-versie: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
    Assembly-versie: 4.0.0.0
    Win32-versie: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System
    Assembly-versie: 4.0.0.0
    Win32-versie: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    mscorlib.resources
    Assembly-versie: 4.0.0.0
    Win32-versie: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/mscorlib.resources.dll
    ----------------------------------------
    System.Windows.Forms.resources
    Assembly-versie: 4.0.0.0
    Win32-versie: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_nl_b77a5c561934e089/System.Windows.Forms.resources.dll
    ----------------------------------------
    System.Xml
    Assembly-versie: 4.0.0.0
    Win32-versie: 4.0.30319.18408 built by: FX451RTMGREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    ************** JIT-foutopsporing **************
    Als u JIT-foutopsporing wilt inschakelen, moet in het configuratiebestand voor deze
    toepassing of computer (machine.config) de waarde
    jitDebugging in het gedeelte system.windows.forms zijn ingesteld.
    De toepassing moet ook zijn gecompileerd terwijl foutopsporing
    was ingeschakeld.
    Bijvoorbeeld:
    Wanneer JIT-foutopsporing is ingeschakeld, worden onverwerkte uitzonderingen
    naar het JIT-foutopsporingsprogramma gestuurd dat op de computer is geregistreerd
    en worden niet door dit dialoogvenster verwerkt.

    • @hanbrouwer6717
      @hanbrouwer6717 10 ปีที่แล้ว

      I found the solution. I started the computer_makes move with: if (turn_count !=9) and the rest in brackets.
      You use everywhere if. I don't know why that works. I used if, else if etc. and thats work the same.

  • @azizfredyanto3700
    @azizfredyanto3700 5 ปีที่แล้ว +1

    move.PerformClick(); What id it?

    • @valeanalex1918
      @valeanalex1918 5 ปีที่แล้ว +1

      Hello, i'm a total noobie so please don't take my answer as 100% corect but as u can see that look_for_win_or_block returns a value that's exactly a name of one of the buttons from from1, let's say it return A3 so move (which was declared as a button) has the value A3 so move.PerformClick(); will click the button A3 from the example

    • @azizfredyanto3700
      @azizfredyanto3700 5 ปีที่แล้ว

      @@valeanalex1918 thank you very much for your help

    • @tomraymundo6642
      @tomraymundo6642 4 ปีที่แล้ว

      @@valeanalex1918 move.PerformClick() is this a function that declared ? can u give me the code for this performclick