• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

TicTacToe user vs computer

 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im developing an application which represents the popular game of TicTacToe,
its configured for 2 players, my project is to let user play vs computer.
I need guide lines on how to module such behavior.

the game:
In a game of Tic Tac Toe, two players take turns marking an available cell in a 3x3 grid with their respective tokens(either X or O). When one player has placed 3 tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A draw (no winner) occurs when all the spaces on the grid have been filled with tokens and neither player has achieved a win.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not quite clear on what you're asking - is it about how to design such a program, or about how the computer would choose the next move, or about something else?
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I ve designed my class to work on 1 v 1, and could be modified to involve computer through invoking compMove() when in comp mode for example.
think the problem now is how to implement computer moves.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you need to come up with how the computer will react to any given board setup. That's not too hard with TicTacToe, as there are only a limited number of situations that can be encountered. Before considering a move you'd probably want to check if the opponent has two in row with the third one open (in which case you'd put the piece on the open field). The corners are important, so it's good to put pieces there if possible (and if the opponents move was to put the first piece in a corner, then the computer needs to put its first piece in the opposing corner). Try to write down all the "rules" you as a human use during a match, and then see if you can translate those to code.
[ January 13, 2007: Message edited by: Ulf Dittmer ]
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic