This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-03-18 20:32:57

pixlepix
Scratcher
Registered: 2010-01-18
Posts: 23

Help in creating an AI

I need help in creating an AI for a chess-like game. I think I know how to do it, but I would like to be sure.

Offline

 

#2 2010-03-18 21:49:07

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Help in creating an AI

Try using "if, else" blocks that do different stuff according to the postitions of the other pieces of the board. Example: If the AI player is in check, he'll have to check if he'll still be in check if he moves to certain direction, until he finds a safe spot to move it's king to.


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#3 2010-03-19 16:04:56

pixlepix
Scratcher
Registered: 2010-01-18
Posts: 23

Re: Help in creating an AI

Well, that will work except it will do random moves the rest of th time. BTW the gme os more of a minatures game.

Offline

 

#4 2010-03-19 16:46:43

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Help in creating an AI

pixlepix wrote:

Well, that will work except it will do random moves the rest of th time. BTW the gme os more of a minatures game.

If you don't want random moves, then make the AI "think" about every possible move, then he'll choose the best one.


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#5 2010-03-19 18:02:59

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Help in creating an AI

technoguyx wrote:

pixlepix wrote:

Well, that will work except it will do random moves the rest of th time. BTW the gme os more of a minatures game.

If you don't want random moves, then make the AI "think" about every possible move, then he'll choose the best one.

You can do that by putting them into a list and then, say it was a chess game. make it so that if you are in check to get out of check.that's just an example.


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#6 2010-03-19 20:14:52

pixlepix
Scratcher
Registered: 2010-01-18
Posts: 23

Re: Help in creating an AI

technoguyx wrote:

pixlepix wrote:

Well, that will work except it will do random moves the rest of th time. BTW the gme os more of a minatures game.

If you don't want random moves, then make the AI "think" about every possible move, then he'll choose the best one.

Pretty sure that was the way you do it, thanks.

Offline

 

Board footer