artificial intelligence

Get help using Construct 2

Post » Thu Jan 23, 2014 12:36 pm

Hello,

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

please help...
B
11
S
3
Posts: 56
Reputation: 893

Post » Thu Jan 23, 2014 12:43 pm

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.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Thu Jan 23, 2014 1:03 pm

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?
B
11
S
3
Posts: 56
Reputation: 893

Post » Thu Jan 23, 2014 5:50 pm

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.
B
101
S
32
G
11
Posts: 1,546
Reputation: 21,727

Post » Thu Jan 23, 2014 7:00 pm

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
B
17
S
4
Posts: 31
Reputation: 1,600

Post » Thu Jan 23, 2014 7:28 pm

(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.)
B
240
S
62
G
33
Posts: 903
Reputation: 40,589

Post » Thu Jan 23, 2014 8:13 pm

@paradox

Yeah would be good strategy. Thanks.
B
17
S
4
Posts: 31
Reputation: 1,600


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests