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

#1 2012-08-19 15:46:02

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Challenge The Turk to a game of CHESS!

Scratch's First 3-Ply and 4-Ply Chess Engine!

http://scratch.mit.edu/static/projects/BoltBait/2737104_med.png

Play Scratch Chess

Challenge The Turk to a game of chess, or press the "see inside" button to learn about The Turk.

Did you know that The Turk was the first chess playing computer and it was built in 1770?

Learn this and other interesting facts!  (And, a shocking secret!)

Then, when you are ready, challenge The Turk to a real game of chess!

Can you beat him?

Notes:

-The Turk is designed to run in the Flash Beta player in Turbo Mode.  If you need help setting this up, read this: http://wiki.scratch.mit.edu/wiki/Flash_Player.

-The Turk uses a small opening book which I designed myself.
-The Turk uses the MiniMax algorithm with a 3-ply or a 4-ply search depth.  It considers about 25,000 or 800,000 board positions per turn based on ply.
-Once the game has started, click the wrench icon to adjust the ply.  The 3-Ply engine takes ~15-20 seconds per turn.  The 4-Ply engine takes ~3-4 minutes per turn.
-Castling and en passant captures supported.
-Click the "See Inside" button for a brief history of The Turk.
-Pawn promotions are limited to Queen.
-If you leave yourself in "check" The Turk will capture your king without warning.
-Development time: ~30 hours

If you think this is a good project and want to show your appreciation / encouragement, please click the "love it" link below the project window.  Thanks!

Change log:

v1.0 - Initial Release.
v1.1 - Added "check" indicator.
v2.0 - Added the 4-ply chess engine.
v2.1 - Fixed a couple of poor plays the engine was making.
v2.2 - Switched to Algebraic Notation
v2.3 - Fixed black e.p. captures

Last edited by BoltBait (2012-09-29 15:32:57)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#2 2012-08-19 16:17:17

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Listen to what people are saying about this chess game:

zubblewu:
"I must say this is 100% positively the best chess simulation on scratch."

miles71:
"awesome, i've been waiting for a good chess game on scratch and now i've found one."

s_federici:
"simply incredible"

Shouldn't you try it out?  You might learn something...  wink

Last edited by BoltBait (2012-08-19 16:47:40)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#3 2012-08-20 11:08:29

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

New version today!

I received several comments that it would be helpful if The Turk would inform you when it has you in check.  So, I added that.


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#4 2012-08-21 14:28:18

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

I can see that you've played...

Did you win?


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#5 2012-08-21 15:11:17

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

I won once. Out of four tries. It was funny how it ended, in the middle of the board, there was a bunch of pieces set up in defensive positions, kill one and something else kills you, repeat 4 times.  tongue  So the Turk moved his king towards the area, (it was his only free piece) and captured a pawn close to the scene. I then moved a single rook into position behind him, and checkmate. Killed on the next turn.

Last edited by sonicfan12p (2012-08-21 15:11:37)


Why are the secret organizations getting all the attention?  mad

Offline

 

#6 2012-08-22 12:27:55

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Would anyone be interested in an upgrade to The Turk?

I could easily change the 3-ply engine to a 4-ply engine.

The benefits would be that it would play much better.

The down side would be that it would take longer to decide each move.

So, should I do it?


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#7 2012-08-22 12:29:26

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

That would make it too hard!  tongue  It doesn't need to play better, I do!  tongue


Why are the secret organizations getting all the attention?  mad

Offline

 

#8 2012-08-22 12:41:30

TheGuy131312
New Scratcher
Registered: 2012-01-02
Posts: 51

Re: Challenge The Turk to a game of CHESS!

wow this is sweet! how do you make pieces move only in the places they are able to? i clicked love it btw  big_smile

Offline

 

#9 2012-08-22 13:47:07

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

TheGuy131312 wrote:

wow this is sweet! how do you make pieces move only in the places they are able to? i clicked love it btw  big_smile

Each piece knows how it can move, so when you click on a square the system asks the selected piece if it can move there.  If it can not, you hear an error tone.  If it can, the system accepts the move and the piece slides to the new location.


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#10 2012-08-22 14:04:21

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

Re: Challenge The Turk to a game of CHESS!

BoltBait wrote:

Would anyone be interested in an upgrade to The Turk?

I could easily change the 3-ply engine to a 4-ply engine.

The benefits would be that it would play much better.

The down side would be that it would take longer to decide each move.

So, should I do it?

If you did that, you could maybe keep the original as an easier version. I can beat the 3-ply engine without much trouble.


http://i.imgur.com/gp6tZ.gif

Offline

 

#11 2012-08-22 14:14:31

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

Re: Challenge The Turk to a game of CHESS!

I have a question, does a 3-ply engine plan ahead three moves for both players (for a total of six moves - three from each player) or does one move from each player count for 2 of the 3 moves?


http://i.imgur.com/gp6tZ.gif

Offline

 

#12 2012-08-22 14:29:19

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Click the "See Inside" button on The Turk for a description of the 3-ply engine.

EDIT: Basically, a "ply" is a single move from one side.  So, for a 3-ply engine, The Turk is thinking about (Ply 1) the move he will be making (Ply 2) white's response and (Ply 3) black's response to that response.

Last edited by BoltBait (2012-08-22 14:30:54)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#13 2012-08-22 14:35:12

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

Re: Challenge The Turk to a game of CHESS!

OK.

I just realised, if it takes roughly 30 seconds (although it only takes about 15-20 for me) to find the best move with a 3-ply engine and with a 4-ply it would take about 30 times longer, it would take several minutes to make each move. Which most users wouldn't be happy about.


http://i.imgur.com/gp6tZ.gif

Offline

 

#14 2012-08-22 14:37:50

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Exactly!

That's why I stopped at a 3-ply engine.

Of course, for those with patience, I *could* modify it into a 4-ply engine.  I'm just trying to gauge the interest.


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#15 2012-08-22 14:41:31

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

Re: Challenge The Turk to a game of CHESS!

BoltBait wrote:

Exactly!

That's why I stopped at a 3-ply engine.

Of course, for those with patience, I *could* modify it into a 4-ply engine.  I'm just trying to gauge the interest.

Since I'm starting to try and work on more advanced things, and I've never made a game tree before, maybe I could try to make a Tic Tac Toe AI. It's a simple game, so it shouldn't be too tough.

The question is, is a 4-ply engine much stronger than 3-ply?


http://i.imgur.com/gp6tZ.gif

Offline

 

#16 2012-08-22 14:50:07

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Definitely harder to beat, definitely more intelligent AI. But I'm not sure what you mean by stronger.  tongue

Last edited by sonicfan12p (2012-08-22 15:11:43)


Why are the secret organizations getting all the attention?  mad

Offline

 

#17 2012-08-22 14:55:49

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

Re: Challenge The Turk to a game of CHESS!

sonicfan12p wrote:

Definitely harder to beat, definitely more intelligent AI. But I'm not sure what you mean by stronger.

Exactly that.  tongue


http://i.imgur.com/gp6tZ.gif

Offline

 

#18 2012-08-22 15:11:12

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

benjamin2 wrote:

sonicfan12p wrote:

Definitely harder to beat, definitely more intelligent AI. But I'm not sure what you mean by stronger.  tongue  <--Forgot to add that

Exactly that.  tongue

That's what I thought.


Why are the secret organizations getting all the attention?  mad

Offline

 

#19 2012-08-22 17:31:08

TheGuy131312
New Scratcher
Registered: 2012-01-02
Posts: 51

Re: Challenge The Turk to a game of CHESS!

BoltBait wrote:

TheGuy131312 wrote:

wow this is sweet! how do you make pieces move only in the places they are able to? i clicked love it btw  big_smile

Each piece knows how it can move, so when you click on a square the system asks the selected piece if it can move there.  If it can not, you hear an error tone.  If it can, the system accepts the move and the piece slides to the new location.

how do you script it to make each piece know where it can move?

Offline

 

#20 2012-08-23 12:56:01

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Chess pieces move in a predictable way.  So, that part is actually quiet easy.


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#21 2012-08-24 21:05:19

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Anyone else want to play a game?

The Turk is waiting...  big_smile


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#22 2012-08-25 18:18:51

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

OK, so I did an experiment to see what a 4-ply engine would be like.  I modified The Turk to be 4-ply and uploaded it to my test account.  This is what I found:

The 3-ply engine, for a baseline comparison, takes 15-25 seconds per move.
The 4-ply engine takes 3-4 minutes per move.

I've played a couple of games against the 4-ply engine and I can tell it is playing better than the 3-ply engine.  It does seem to be a little more conservative.  I'm just not sure if the extra ply is worth the extra 3 minutes of think time.

I think there would be more value in expanding the Opening Book.

Last edited by BoltBait (2012-08-25 19:22:23)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#23 2012-08-25 18:25:55

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

just a question: can it do scholar's mate?


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#24 2012-08-25 18:28:49

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

I don't believe it will fall for Scholar's Mate.

You can try...  big_smile

EDIT: By the way, if you open with the moves for Fool's Mate, The Turk will gladly take your king.  wink

Last edited by BoltBait (2012-08-25 18:30:42)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

#25 2012-08-25 20:21:43

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Challenge The Turk to a game of CHESS!

Haha, I'm the first review  smile  Maybe you could add an option to change modes? Maybe you could have 3 game modes! Easy with a 2-ply engine, normal with a 3-ply, and hard with a 4! Just thought that might be cool, since I think a lot of people suggested it.


........................................................................................................................................................................................................................................

Offline

 

Board footer