A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Tic Tac Toe

Threaded View

  1. #3
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    along with what northcode said in terms of the 8 ways to win you should also store 1 variable, one that will store your next winning move, and than when its the ai's turn you give it a 50/50 chance to block your winning move or move somewhere random,

    id store all the moves in an array like this

    var game_slots={
    slot1:[0,0,0],
    slot2:[0,0,0],
    slot3:[0,0,0]
    };

    and when you make you make a move on 3,3, slot 3 would look like

    var game_slots={
    slot1:[0,0,0],
    slot2:[0,0,0],
    slot3:[0,0,1]
    };

    and when the ai makes a move you can store its flag as a 2 since yours is a 1 lets say it made a move on 1,1 it would look like this

    var game_slots={
    slot1:[2,0,0],
    slot2:[0,0,0],
    slot3:[0,0,1]
    };
    Last edited by AS3.0; 01-04-2017 at 05:16 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center