New Year's resolution: a chess engine written in BASH script

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: New Year's resolution: a chess engine written in BASH sc

Post by Dann Corbit »

benstoker wrote:It's stoopid, I know. But, it's been done in Javascript. I would like to see an obviously very basic script that searches 3 or 4 ply, with simple piece value eval. A minimax and no alpha-beta, etc.

Anybody out there who could help?

The world is crying out for a BASH chess engine.
They can enjoy playing chess with this engine on a ship constructed entirely from stones and mortar.

I saw on Mythbusters that a balloon can be constructed from lead foil, along with a concrete glider. So a bash chess program is not alone in its oddness.

Yes, you can produce this engine. The burning question is, "Why?"

P.S.
I guess you can use Hillary's defense.
IanO
Posts: 496
Joined: Wed Mar 08, 2006 9:45 pm
Location: Portland, OR

Re: New Year's resolution: a chess engine written in BASH sc

Post by IanO »

Edmund wrote:
Greg Strong wrote:
Edmund wrote:
Greg Strong wrote:BASH? Too easy. What the world needs is an engine written in Logo 8-)
Is there actually a way to interact with this green spot on the screen once the program has started?
Haha... you caught me! A chess program in Logo is probably not possible, as I don't recall any way to interact with the turtle (although there might be. I haven't programmed in logo since I was like 10 :D)
When I wrote that I have just tried a very basic web application, able to let the turtle walk forwards, right, left and so on.

Then I found a more advanced interpreter. FMSLogo has the following features:
FMSLogo includes support for

* "Standard" Logo parsing
* Turtle Graphics
* Exception handling
* TCP/IP networking
* Text in all available system fonts
* 1024 independent turtles
* Bitmapped turtles
* MIDI devices
* Direct I/O for controlling external hardware (must be admin)
* Serial and parallel port communications
* Saving and loading images in BMP format
* Calling into native DLLs
* Creating windows dialog boxes
* Event driven programming (mouse, keyboard, timer)
* Controlling multimedia devices (WAV sound files, CD-ROM control, etc.)
* 3D Perspective drawing (wire-frame and solids)
* Creating animated GIFs
This one could easily be used to program a chess engine. Also the GUI would be pretty fun; with the feature "1024 independent turtles" you could create 32 turtles then in combination with "Bitmapped turtles" put some bmp of chess pieces on them and let them run over a chess board. And finally with "Event driven programming" you could easily interact with the user.

regards,
Edmund
The bigger problem is that Logo was never designed for speed. With its lists, arrays, and tail recursion, it is about as capable as Scheme, but slower due to lots of reparsing and dynamic scoping. And of course garbage collection kills performance. I've only used UCB Logo. Others may be faster.

Ian
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: New Year's resolution: a chess engine written in BASH sc

Post by UncombedCoconut »

benstoker wrote:It's stoopid, I know. But, it's been done in Javascript. I would like to see an obviously very basic script that searches 3 or 4 ply, with simple piece value eval. A minimax and no alpha-beta, etc.

Anybody out there who could help?
When my attention drifts from coaxing Brutus to compile natively on Linux, I keep adding code to a project like this. It won't end well.
The world is crying out for a BASH chess engine.
No, the world will be crying once there is a BASH chess engine.
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: New Year's resolution: a chess engine written in BASH sc

Post by UncombedCoconut »

OK, Ben, feel free to pick it up from here.
Pure bash -- it doesn't even use arrays!
http://pastebin.com/f18841718
This UCI engine mostly understands the rules. (See comments to learn its limitations, other than having the ELO of a turnip.)
Check out its fight vs Stockfish (10 min / side)!

Code: Select all

1. a4 e5 2. a5 Nf6 3. b3 d5 4. c3 Bd6 5. d3 O-O 6. e3 c5 7. a6 Nxa6 8. f3 Be6
9. g3 d4 10. cxd4 cxd4 11. exd4 Bb4+ 12. Ke2 Qxd4 13. Rxa6 Bc5 14. Rxe6 Qf2# 0-1
Hm, that didn't work so well! Maybe it can get luckier with colors reversed. Oh crap, move ordering is still by source square!

Code: Select all

1. e4 Nc6 2. d4 Nf6 3. d5 Nb8 4. e5 Ng8 5. Nf3 a5 6. Bc4 b6 7. O-O Bb7 8. Nc3
Qc8 9. e6 dxe6 10. dxe6 Bxf3 11. exf7# 1-0
I apologize for creating this.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: New Year's resolution: a chess engine written in BASH sc

Post by Don »

UncombedCoconut wrote:OK, Ben, feel free to pick it up from here.
Pure bash -- it doesn't even use arrays!
http://pastebin.com/f18841718
This UCI engine mostly understands the rules. (See comments to learn its limitations, other than having the ELO of a turnip.)
Check out its fight vs Stockfish (10 min / side)!

Code: Select all

1. a4 e5 2. a5 Nf6 3. b3 d5 4. c3 Bd6 5. d3 O-O 6. e3 c5 7. a6 Nxa6 8. f3 Be6
9. g3 d4 10. cxd4 cxd4 11. exd4 Bb4+ 12. Ke2 Qxd4 13. Rxa6 Bc5 14. Rxe6 Qf2# 0-1
Hm, that didn't work so well! Maybe it can get luckier with colors reversed. Oh crap, move ordering is still by source square!

Code: Select all

1. e4 Nc6 2. d4 Nf6 3. d5 Nb8 4. e5 Ng8 5. Nf3 a5 6. Bc4 b6 7. O-O Bb7 8. Nc3
Qc8 9. e6 dxe6 10. dxe6 Bxf3 11. exf7# 1-0
I apologize for creating this.
Those were epic battles, not soon to be forgotten.
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: New Year's resolution: a chess engine written in BASH sc

Post by UncombedCoconut »

I don't want to give the false impression that I'm maintaining this (yuck!) but I noticed that I introduced a bug when I added e.p. captures to the movegen. Since I want to see the engine lose tragically rather than crash, here's a fixed version.
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: New Year's resolution: a chess engine written in BASH sc

Post by Michel »

It's playing on FICS!
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: New Year's resolution: a chess engine written in BASH sc

Post by jwes »

Michel wrote:It's playing on FICS!
You could call it BASHee (as it is likely to get bashed regularly).
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: New Year's resolution: a chess engine written in BASH sc

Post by UncombedCoconut »

Michel wrote:It's playing on FICS!
What the f:shock: That's funny! If I register for FICS can I watch this cruelty? (You can PM me; I'd bet I'm the only one here with no internet chess experience.)
MattieShoes
Posts: 718
Joined: Fri Mar 20, 2009 8:59 pm

Re: New Year's resolution: a chess engine written in BASH sc

Post by MattieShoes »

FICS is free, you don't need to register to watch games.