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

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

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

Post by Michel »

Sadly the latest version you posted does something strange.

I get this
position startpos moves c2c4
./chess: line 225: ${MOVING_PIECE,,}: bad substitution
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 »

Michel wrote:Sadly the latest version you posted does something strange.

I get this
position startpos moves c2c4
./chess: line 225: ${MOVING_PIECE,,}: bad substitution
It's probably the version of bash you are using.
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:Sadly the latest version you posted does something strange.

I get this
position startpos moves c2c4
./chess: line 225: ${MOVING_PIECE,,}: bad substitution
Sorry, I'm unable to reproduce this. (Edit: What Don said :wink: )

(Re Matt: fair enough, but I still don't know how to find the engine, if it's even still playing :))
Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

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

Post by Michel »

Ok sorry for the confusion.

It turned out to be bash indeed.

I installed a more modern bash and the script worked again.

It is now playing on my server under the handle "ShouldntExist".

Just logging in to FICS and doing

follow ShouldntExist

should do the job.

Thanks for the wonderful program.
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 »

Thanks! BTW blitz TC are a very bad idea; it will always lose on time. (E: I guess it's OK because it is always well on its way to checkmate anyway.)
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 »

Other thoughts: I find it funny to see players make defensive moves against the script. If they only knew what they were up against... Also, to diversify its opening repertoire, we can randomize between moves it sees as equal by adding this line before #437 ("if [[ $COLOR == 'w' ]]; then" in the eval function):

Code: Select all

  ((SCORE += (RANDOM % 199) - 99))
Michel
Posts: 2271
Joined: Mon Sep 29, 2008 1:50 am

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

Post by Michel »

I added the line. Since the icsclient I use (icsdrone) always restarts the engine after a game it should pick up the new script in the next game.
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 need to let go of this, but the bugs are embarrassing.
I have an update here.
Bugfix: moves from a8 weren't generated
Bugfix: knights could jump between board edges
Bugfix: slider pieces couldn't move past the e.p. target square
Bugfix: promotions weren't handled
Bugfix: some moves were inappropriately interpreted as castling
Bugfix: randomness was too large (I even wrote it right before posting. Whoops.)

BTW, I watched this novelty engine take out an unwary opponent last night. :lol: Thank you, Michel. I thought I'd never see that happen! The engine even faked (unsound but effective) tactical thought well enough to scare the dude away.

[d] 2kr3r/ppp2ppp/3b1q1n/5b2/Pn1p4/N2P1Q1P/1P2PPP1/R1B1KBNR w KQ - 3 13
This human has played 12. ... Nh6? and suffers

Code: Select all

13. Bxh6 gxh6 14. e4 Bg6 15. Qxf6 1-0
benstoker
Posts: 342
Joined: Tue Jan 19, 2010 2:05 am

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

Post by benstoker »

UncombedCoconut wrote:I need to let go of this, but the bugs are embarrassing.
I have an update here.
Bugfix: moves from a8 weren't generated
Bugfix: knights could jump between board edges
Bugfix: slider pieces couldn't move past the e.p. target square
Bugfix: promotions weren't handled
Bugfix: some moves were inappropriately interpreted as castling
Bugfix: randomness was too large (I even wrote it right before posting. Whoops.)

BTW, I watched this novelty engine take out an unwary opponent last night. :lol: Thank you, Michel. I thought I'd never see that happen! The engine even faked (unsound but effective) tactical thought well enough to scare the dude away.

[d] 2kr3r/ppp2ppp/3b1q1n/5b2/Pn1p4/N2P1Q1P/1P2PPP1/R1B1KBNR w KQ - 3 13
This human has played 12. ... Nh6? and suffers

Code: Select all

13. Bxh6 gxh6 14. e4 Bg6 15. Qxf6 1-0
I ran this on a 128 bit 'server' and it kicked the pants off of Rybka 3 on a standard multicore. Will soon have access to a 256 bit 'server'. Can't wait to see. Of course, I had to set the depth to 120.

In the meantime, can you tell me where I can insert a loop counter (let node=node+1) to get a count of the nodes? I aint too smart and caint figer it out.
benstoker
Posts: 342
Joined: Tue Jan 19, 2010 2:05 am

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

Post by benstoker »

UncombedCoconut wrote:I need to let go of this, but the bugs are embarrassing.
I have an update here.
Bugfix: moves from a8 weren't generated
Bugfix: knights could jump between board edges
Bugfix: slider pieces couldn't move past the e.p. target square
Bugfix: promotions weren't handled
Bugfix: some moves were inappropriately interpreted as castling
Bugfix: randomness was too large (I even wrote it right before posting. Whoops.)

BTW, I watched this novelty engine take out an unwary opponent last night. :lol: Thank you, Michel. I thought I'd never see that happen! The engine even faked (unsound but effective) tactical thought well enough to scare the dude away.

[d] 2kr3r/ppp2ppp/3b1q1n/5b2/Pn1p4/N2P1Q1P/1P2PPP1/R1B1KBNR w KQ - 3 13
This human has played 12. ... Nh6? and suffers

Code: Select all

13. Bxh6 gxh6 14. e4 Bg6 15. Qxf6 1-0
One other thing. This is not as useless as you imply. This is a pedagogical chess engine. In my view, it's the best one because it's so absolutely basic. Extra comments to explain what's going on would be the final selling point.