artificial intelligence

0 favourites
  • 7 posts
From the Asset Store
High quality sound effect pack, in the following categories: computer voice
  • Hello,

    How can i built tic tac toe game with "artificial intelligence" to play vs computer??

    please help...

  • Arrays will help you alot in this situation,Being that a tic-tac-toe board only has 6 slots it should be fairly easy to make logic for such a project.

    Arrays are your best friend,trust me i was really depressed before i found my friend Array.It will help you figure out how to draw tiles into slots,That along with basic knowledge of the system and you should have a tic-tac-toe game in no time.

    If you need help with something more in depth,you should be more specific.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thank you so much for your answer.

    actually the game is ready. but game is played by 2 players. i wanna play vs computer. so after my move in game, computer should play according to my move to win me..

    how method should i try?

  • You just need to program in the logic.

    If player places piece here, CPU should place piece here. If that spot is taken, place piece here, etc.

  • When it is the computer's turn, check to see if the player has two in a row and block it, otherwise start checking for open spaces in order of best position and fill the first available slot.

    no capx so it's hard to give specific example since I'm not going to write one from scratch but I'd check boxes from center, diagonals, then sides for open moves. Not sure what a good strategy for tic-tac-toe would be.

    You might be able to find a strategy in this javascript AI example

    http://www.javascriptkit.com/script/script2/tactoe.shtml

  • (actually, you would also check to see if the computer player has two in a row, and fill that one as well, and win. possibly using the same "check for two" routine.)

  • Paradox

    Yeah would be good strategy. Thanks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)