• Post Reply Bookmark Topic Watch Topic
  • New Topic

TicTacToe AI bot  RSS feed

 
Ranch Hand
Posts: 518
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
 
Saloon Keeper
Posts: 3330
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor 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: 11494
    180
    Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
    • 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: 518
    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: 11494
    180
    Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
    • 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.
     
    Sheriff
    Posts: 22846
    43
    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: 56608
    172
    • 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.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!