Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

TicTacToe AI bot

 
Ranch Hand
Posts: 543
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

I have been meaning to do this for some time and now I want to implement it anyway I want to know how to make a AI for  a GUI tic tac toe game,

I don't want any solutions but tips and resources would be appreciated or a breakdown of what I should do,

I feel this task will bring my knowledge of Java up to the next level

my deadline for finishing this project well I will sat it for this weekend

thanks
 
Bartender
Posts: 7197
65
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by  "AI".

It seems to me that there are 3 main approaches to computing moves:
  • Hard code the logic.
  • Keep track of the probabilities that playing in a particular position would have.
  • Start with zero knowledge and "learn" from each game.

  • This list is also in order of increasing code complexity. I think even hard coding would possibly take as long as your target date.
     
    Sheriff
    Posts: 15779
    264
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Adam Chalkley wrote:
    I feel this task will bring my knowledge of Java up to the next level


    This isn't so much about Java as it is about software development. This can literally be implemented in any language. In fact, the language implementation is the easy part. The hard part is organizing your ideas and figuring out the algorithm.

    I suggest you start by searching for strategies for winning tictactoe

    A good understanding of the different "rules" for making moves that increase your chances of winning or at least eliminate your chances of losing will give you the basis for writing your program logic.
     
    Adam Chalkley
    Ranch Hand
    Posts: 543
    4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks guys,much appreciated

    also what I meant by AI was artificial intelligence

    will start trying to implement this asap
     
    Junilu Lacar
    Sheriff
    Posts: 15779
    264
    Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Adam Chalkley wrote:
    also what I meant by AI was artificial intelligence


    I don't think that term means what you think it means. Just because it can be programmed so that one of the players is the computer doesn't necessarily make it AI.
     
    Marshal
    Posts: 25677
    69
    Eclipse IDE Firefox Browser MySQL Database
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    When I was a child (in the 1960's) my father made an AI device to play tic-tac-toe. It consisted of a set of matchboxes, one for each possible arrangement of X's and O's. On the outside of each was a label marking the possible plays from that position, and inside were coloured chips for each possible play. As the controller of the AI you would pick a coloured chip at random and make that play. If that play was an immediate loser you would throw away that chip. Repeatedly playing against a human player allowed the AI to learn what bad moves to avoid, and eventually you would be left with only chips which weren't losers. (There's no strategy to win at tic-tac-toe except playing against naive opponents.)

    You could no doubt program something like this in Java or, as Junilu said, in many other languages.
     
    Marshal
    Posts: 69806
    277
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Paul Clapham wrote:. . . There's no strategy to win at tic-tac-toe except playing against naive opponents.) . . .

    I would say there is no strategy to won full stop. There are however naïve strategies to lose.
      Bookmark Topic Watch Topic
    • New Topic