Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 35 of 35

Thread: Let's build tic-tac-toe (noughts and crosses) together...

  1. #26
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    Hello everyone. @Tjstretch: The latest version you uploaded here, seems to have multiple errors in it. Are these errors occuring at your side too?

  2. #27
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    For AI Script, i will first check the grid size. Then algorithm will start working, let's say it's my turn, so i will mark at the place whose probability of winning is more than any other box. Opponent will mark, algorithm will now check the possibility of winning of the remaining grid. There will be a method which will be called after every turn opponent makes, which will check and return the highest winning probability cell (box).

    Now, how this method will work.
    If the grid is empty, most probably the center one has the highest probability to win (as far as i know ) so mark center, opponent will make his/her turn and this method will be called, initially there will be 3 main logic to implement on this.
    1. Check if there is any place if opponent can win, if there is, mark the place or if it can win.
    2. If 1 fails, (means no place to win for opponent), see the diagonals and parallel places for empty box to place a mark.
    3. If 2 fails too, Count for the number of empty boxes, evaluate if there can be a win for either player, if yes, see the (well.... ummm... it's confusing, i guess i can't explain it here but implement )

  3. #28
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    @ 2cd Post Well that is certainly very impressive. , can't wait to see it implemented! The play method will always be called on your turn, and (when another bug is fixed) there will always be a spot open.

    Yes, there are multiple bugs/missing functionality (Especially in the TTTBot) in the one I have, it is most certainly not complete! However it should compile without any errors (It does), if you are having issues compiling it may be because I am on java 1.7, which has some slightly different syntax.

  4. #29
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    if you are having issues compiling it may be because I am on java 1.7, which has some slightly different syntax.
    Yeah i figured it out on my own
    And sure, i will implement it as soon as i could coz i am going to have up-coming project this January first week so i will finish with this, early January.

  5. #30
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    Well, after googling i found many of already developed AI algorithms for Tic Tac Toe. Why don't you use those instead of developing new? That's just a question from you, may be you have some reasons. But i want to make them clear.

  6. #31
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    Yeah, I assumed they were out there, but I didn't want to remove anyone the fun of developing an algorithm themselves. If you don't feel a need to develop a new algorithm or attempt to implement a new one, that's certainly fine. (I'm sure the ones released are pretty amazing )

  7. #32
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    Quote Originally Posted by Tjstretch View Post
    Yeah, I assumed they were out there, but I didn't want to remove anyone the fun of developing an algorithm themselves. If you don't feel a need to develop a new algorithm or attempt to implement a new one, that's certainly fine. (I'm sure the ones released are pretty amazing )
    I don't feel bad attempting to implement a new algorithm but what i thought was to use Alpha-Beta Pruning and after search i found there are already several algorithms implemented for this then why need to write our own? As said, Write Once Use Everytime you need to. So, why bothering implementing the same thing twice with just wasting time of implementing the same scenarios, conditions etc stuff

  8. #33
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    Quote Originally Posted by Mr.777 View Post
    So, why bothering implementing the same thing twice with just wasting time of implementing the same scenarios, conditions etc stuff
    Why bother doing anything if it has already been done? Why bother going back to the moon or taking a second look at those fuzzy patches in the telescope? It is not the end result I am interested in here; tic-tac-toe is hardly exciting. All I am interested in is if I can do it and if not then what do I need to learn.

    Anyway, I have started work on my own AI and had a flash of inspiration. I am going to create an abstract bot class and implement it in several 'personality' classes. Game will use polymorphism to ask the given personality which move to make given the board as a parameter.
    - Bot 1 never makes a mistake
    - Bot 2 randomly makes a mistake every n turns
    - Bot 3 randomly picks a square without any thought
    - Bot 4 randomly picks a square but remembers options that did not work

    et cetera. My idea is to have a choice of bots to play against, better yet; play bots against each other. Could even swap bots in and out of play while a round is in progress.

  9. #34
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    Why bother doing anything if it has already been done? Why bother going back to the moon or taking a second look at those fuzzy patches in the telescope? It is not the end result I am interested in here; tic-tac-toe is hardly exciting. All I am interested in is if I can do it and if not then what do I need to learn.
    Fine. Going to the moon, nice, what if you can't afford going to moon? What you do is a look of previous visits or the history.
    Same, if you got enough time to develop your own AI script, go on but what if you are making this for a client and it's deadline after two days and you need to complete this in the day end? Will you still write your own? Don't be such a pessimist, i just said, why bothering writing and wasting a huge time, waiting for AI scripts to implement, instead use already developed AI algorithms.
    As i don't have enough time to do all this or to waste my time on already developed algorithms, one of the many things i was taught is to use already developed thing to let your work get completed.

    Why do you use API's? Why don't you create your own?

    I guess, this thread will get too personal. So, let these comments come to PM. Christopher if you got any comments, against this, PM me.

    Thanks

  10. #35
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Let's build tic-tac-toe (noughts and crosses) together...

    @Mr. 777 - pm sent with an apology.

    I have been too lazy to do much, but I have implemented the random bot and the perfect bot. Unfortunately, there is a problem with my algorithm for the perfect bot and it falls back to random behavior. It is not calculating the weights correctly. I will take a look at it next year.

    I have also decided to put in a 'thinking time' for the bots to give them human reactions. There is an object diagram in the zip file.

    Happy new year all!
    Attached Files Attached Files

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 6
    Last Post: October 5th, 2011, 07:21 AM
  2. can anyone help me pls to build this program
    By Xhejn in forum Member Introductions
    Replies: 1
    Last Post: May 31st, 2011, 05:05 PM
  3. HELP: how and where was this build?
    By timosilver in forum Object Oriented Programming
    Replies: 1
    Last Post: December 15th, 2010, 11:19 AM
  4. Incremental Build
    By ashwin in forum Java IDEs
    Replies: 0
    Last Post: January 12th, 2010, 06:21 AM
  5. How to build a .car file in Vignette?
    By andrew222 in forum Java Theory & Questions
    Replies: 2
    Last Post: November 22nd, 2009, 04:49 PM