Scratch's First 3-Ply and 4-Ply Chess Engine!
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)
Offline
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...
Last edited by BoltBait (2012-08-19 16:47:40)
Offline
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. 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)
Offline
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?
Offline
That would make it too hard! It doesn't need to play better, I do!
Offline
wow this is sweet! how do you make pieces move only in the places they are able to? i clicked love it btw
Offline
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
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.
Offline
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.
Offline
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)
Offline
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.
Offline
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?
Offline
Definitely harder to beat, definitely more intelligent AI. But I'm not sure what you mean by stronger.
Last edited by sonicfan12p (2012-08-22 15:11:43)
Offline
benjamin2 wrote:
sonicfan12p wrote:
Definitely harder to beat, definitely more intelligent AI. But I'm not sure what you mean by stronger. <--Forgot to add that
Exactly that.
That's what I thought.
Offline
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
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
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)
Offline
I don't believe it will fall for Scholar's Mate.
You can try...
EDIT: By the way, if you open with the moves for Fool's Mate, The Turk will gladly take your king.
Last edited by BoltBait (2012-08-25 18:30:42)
Offline
Haha, I'm the first review 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