Chess Game in Forth?

113 views
Skip to first unread message

Christoph C

unread,
Jun 2, 2015, 3:02:32 PM6/2/15
to fign...@googlegroups.com
Hi,
i was working on some Forth Ideas and i had a question, if someone would like to try my chess algorithm. Could someone implement it? It is an idea for evaluating every position. I will explain it. I call this Algorithm the GSG-Algorithm.... for General-Strategic-Game-Algorithm. This algorithm is not the best, but it is able to expand and you can play every game with the right variables. 
The normal evaluation says:
F1 + F2 + Fi + Fs - Ffs = Wf 
F1 = Coordinates of field one added. For example (E2 would be 5+2 = 7)
F2 = is the field where your piece can move (E4 is 5+4=9)
Fi = is the value of the piece you are moving. 
here is the list:
pawn = 1 
knight = 2
Bishop = 3
Rook = 4
Queen = 5 
King = 6

So and Fs is a variable, which says if a piece can be taken:
If you can take a pawn, then add +20
if you can take a knight, then add +40
if you can take a bishop, then add +50
if you can take a rook, then add +70
if you can take the queen, then add +80
if you can take the king ( check ), then add +100 ( but subtract one field away from this piece, you can't defeat the king.. )

Now Ffs:
If a piece is able to take your piece, then do this calculations:
for every piece, which can defeat you, subtract the Fs value and add on this value +50. 

Now something important for the king:
if the computer's king is in check, then the computer has to look, if the king is able to move or a piece is able to protect the king.
if a piece protected a king from check and wants to move away, you have to subtract -100
if a piece can protect the king, then add +100
and if the king can move away, then add +150

Now the workings of the program:
the program has to do this steps:

after initializing the board and setting up the pieces:
1. draw the board
2. wait for an input 
// for this program i don't think it's a good idea to check for a legal move
3. make whites move ( you can program the computer to play black or white, if you change the code of the pieces)
4. now store all legal moves of black ( including, if black is in check )
5. calculate all moves and store the best move 
6. make the move
7. goto 1

this is all. Just an idea of an 9. grade boy, who plays chess :D . Ok the system is complex, but you all can understand it and the algorithm can be expanded by another variables. 
I am writing a BASIC version for the ZX81 computer ( I call it PeChess ). So if someone is interested in or has some questions, then ask. 
I hope you all understand, it's just a simple algorithm, but if you are a bad chess player, the program will maybe win :D.
Greetings
  Christoph

Christoph C

unread,
Jun 2, 2015, 3:08:09 PM6/2/15
to fign...@googlegroups.com
I forget to make an example: 
the Queen is able to move from D1 to D8 and defeat black's queen. this is the calculation:
(4+1 (D1))+ (4+8 (D8))+ 5 + (100+80 (the queen is able to set black in check and can take the queen)) - (150 (king can take queen +50 (king's Fs is 100)))= 52 
so the move is as good as 52 points ( if i would calculate more moves, there is maybe a better move).

pablo reda

unread,
Jun 2, 2015, 3:27:16 PM6/2/15
to fign...@googlegroups.com
You have the BASIC version for see the code?

Christoph C

unread,
Jun 2, 2015, 3:44:49 PM6/2/15
to fign...@googlegroups.com
Hi,
i havn't finished the program yet. 
I will finish it in the next months

Carl Attrill

unread,
Jun 2, 2015, 4:18:32 PM6/2/15
to fignition@googlegroups com
Hi Christoph,
 I think Julz made a start on a chess game, there ere some sprites about somewhere, do a search for 'Chessica' hope this helps and good luck :-)

Carl.

--
You received this message because you are subscribed to the Google Groups "FIGnition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fignition+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christoph C

unread,
Jun 2, 2015, 11:51:11 PM6/2/15
to fign...@googlegroups.com
I know that there is a chessica. But this game has no evaluation function. That was the reason, why i wrote my algorithm in here

Carl Attrill

unread,
Jun 3, 2015, 2:52:44 AM6/3/15
to fignition@googlegroups com

That cool I get it,  just knew that there were some sprites for chess here if you wanted to find some.

On 3 Jun 2015 04:51, "Christoph C" <geni...@gmail.com> wrote:
I know that there is a chessica. But this game has no evaluation function. That was the reason, why i wrote my algorithm in here

--

Julian Skidmore

unread,
Jun 3, 2015, 7:27:35 AM6/3/15
to FIGnition
Yes, the idea of Chessica was to provide the UI for a proper chess game :-)

-cheers from Julz
--
                             
                  The DIY 8-bit computer from nichemachines™

FIG - black on whiteMini.jpg
NmLogoMini.jpg

Julian Skidmore

unread,
Jun 3, 2015, 7:33:57 AM6/3/15
to FIGnition
...part 2..

what Christoph's designed, as far as I can tell, is a chess evaluation algorithm. It assumes the code for generating potential chess moves is already there and his algorithm calculates whether any move is good or not.

I did some work a while back on a simple chess algorithm, but I never tested it. Here it is as an attachment.

-cheers from Julz
FIGgyChess.fth
FIG - black on whiteMini.jpg
NmLogoMini.jpg

Christoph C

unread,
Jun 3, 2015, 3:06:30 PM6/3/15
to fign...@googlegroups.com
The Story why i created a chess algorithm is, because i was not able to program a min-max-algorithm ... And an evaluation function based on calculating is very simple. 
I will finish the chess program in BASIC soon and then play a game. I will look, who will win, but i always know the answer.... :)
Reply all
Reply to author
Forward
0 new messages