Forums

I am trying to write a program for the Witch

Sort:
evert823

I am trying to write a program that can handle the Witch. Since I haven't heard of any other person taking this up. And as for existing engines, the Witch will be quite specific and it won't be easy to add this piece to existing code, that only deals with more or less normal pieces.

At this moment:
- It has no nice UI at all, no whatsoever board
- It has XML import and export routines and that's what I use while testing
- Imported XML is validated thoroughly
- It's supposed to handle all Witch rules, all normal FIDE rules (50 moves, repetition, castling, en passant etc etc), and various board sizes
- Creating list of all valid moves from a given position --> implemented and tested
- Executing the move on the board --> implemented and tested (sounds simple but this was the hardest thing so far)

- I have drafted the algorithm/pseudo code to evaluate a position, calculate from that position, detect Mate and Stalemate, and come up with the preferred move

My first target is that this program can find forced mate sequences, so I can draft a mate in 2 and it will solve it.

Long term target is of course: play a proper game, and have a proper visual board with dragging pieces etc etc

The draft that is now written and tested is here:

http://www.scrybqj.com/downloads/csharp/

amusingmouse

It will be hard...

amusingmouse

good luck!

evert823

I'm afraid this has my priority over modding other games, except my own games of course.

evert823

I've never heard of nebiyu before.

evert823
musketeerchess2017 wrote:
evert823 wrote:

I've never heard of nebiyu before.

It’s part of the package in your download link that’s why i was asking.

It should download one zip file with the components of a Visual Studio 2019 C# project for a simple Windows Forms application. I don't see the nebiyu anywhere, perhaps you were confused with another link???

evert823

I did to one more evening of programming, and now I have a result:

 

This is mate in 3 plies (mate in 2):

1. Qxe7+ Kxe7

2. Wf3#

The program found it. happy.png

To find the first move it took a bit less than 20 seconds meh.png

The link in the OP now points to this version of the code that gave me this result.

evert823

The above also includes some very (very!!!) basic evaluation of material advantage, and draw by insufficient material.

tehanu

Wow

evert823

I have implemented substantial improvements, and some half an hour before posting this I updated the files behind the link in the OP. The improvements are: more compact code, and a really very big step towards better performance. W.r.t. performance: a 4 plies deep calculation of an avarage Bulldog chess position will take some 5 minutes.

evert823
rychessmaster1 wrote:

does the program know that RvW is drawn

No not yet. These kind of observations are work in progres.

Legendary_Basilisk
evert823 wrote:

I am trying to write a program that can handle the Witch. Since I haven't heard of any other person taking this up. And as for existing engines, the Witch will be quite specific and it won't be easy to add this piece to existing code, that only deals with more or less normal pieces.

At this moment:
- It has no nice UI at all, no whatsoever board
- It has XML import and export routines and that's what I use while testing
- Imported XML is validated thoroughly
- It's supposed to handle all Witch rules, all normal FIDE rules (50 moves, repetition, castling, en passant etc etc), and various board sizes
- Creating list of all valid moves from a given position --> implemented and tested
- Executing the move on the board --> implemented and tested (sounds simple but this was the hardest thing so far)

- I have drafted the algorithm/pseudo code to evaluate a position, calculate from that position, detect Mate and Stalemate, and come up with the preferred move

My first target is that this program can find forced mate sequences, so I can draft a mate in 2 and it will solve it.

Long term target is of course: play a proper game, and have a proper visual board with dragging pieces etc etc

The draft that is now written and tested is here:

http://www.scrybqj.com/downloads/csharp/

 

To make a chess engine that can play bulldog chess, you should make a variant of stockfish that can play bulldog chess, you won't have to make the pruning function and the evaluation function from scratch. 

evert823
Legendary_Basilisk wrote:
evert823 wrote:

I am trying to write a program that can handle the Witch. Since I haven't heard of any other person taking this up. And as for existing engines, the Witch will be quite specific and it won't be easy to add this piece to existing code, that only deals with more or less normal pieces.

At this moment:
- It has no nice UI at all, no whatsoever board
- It has XML import and export routines and that's what I use while testing
- Imported XML is validated thoroughly
- It's supposed to handle all Witch rules, all normal FIDE rules (50 moves, repetition, castling, en passant etc etc), and various board sizes
- Creating list of all valid moves from a given position --> implemented and tested
- Executing the move on the board --> implemented and tested (sounds simple but this was the hardest thing so far)

- I have drafted the algorithm/pseudo code to evaluate a position, calculate from that position, detect Mate and Stalemate, and come up with the preferred move

My first target is that this program can find forced mate sequences, so I can draft a mate in 2 and it will solve it.

Long term target is of course: play a proper game, and have a proper visual board with dragging pieces etc etc

The draft that is now written and tested is here:

http://www.scrybqj.com/downloads/csharp/

 

To make a chess engine that can play bulldog chess, you should make a variant of stockfish that can play bulldog chess, you won't have to make the pruning function and the evaluation function from scratch. 

Yes that's how this can be approached. Advice taken.

evert823

A small step.

Convert a won position to an actual win is a bit tricky. Because the winning plan must be represented as a higher score for the moves that fit in the winning plan. The progress must be reflected in the score for a position.

Now I have a routine that covers this for the situation that I have to chase a lone opponent's King. It was a matter of giving a higher score for coming closer to the opponent's King, and the opponent's King coming closer to a preferred corner.

 

It's been tricky, but now TheWeirdEngine successfully chases the King into a corner and mates.

 

evert823

White to move.

I don't master K+N+B vs K.
In this position, Fritz says mate in 8. That's mate in 15 plies.
I gave it to TheWeirdEngine with 7 plies. It doesn't see the mate yet but just does corner chasing.

Countermoves done by Fritz.

Kb4 Ka2
Nd3 Kb1
Kb3 Ka1
Kc2 and tells me that it sees mate in 4
... Ka2
Bc1 Ka1
Bb2+ Ka2
Nc1#

PerpetuallyPinned

How much time are you giving the engine?

evert823

In the above position, to calculate 7 plies and find Kb4 took one minute and 40 seconds

PerpetuallyPinned

I'd try giving it more time.

How long to find mate in 7?

evert823

Mate in 7 requires 13 plies.

When I increase with 1 ply, the computing time potentially increases with some factor, being the average number of moves possible from positions in that context.

So from 7 plies to 13 plies will increase computing time substantially. It will explode, and perhaps display an answer when Andromeda Nebula is done merging with our own Milky Way.

evert823

Debug time

cry.png

Let's look at two positions, both white to move.

In the evaluator, the part that looks at just the position itself without calculating more moves deep, the first position is evaluated much better for Black, while the second position is evaluated much better for White. I know why he does this. I gave 2 points (as in worth 2 pawns!) for just having a pawn move to the 7th rank.
The stupid thing is: in the first position, this one black f-pawn has 3 moves to the 7th rank and they were each rewarded 2 points seperately. Ouch!

We know that in the first position, white can now take the black pawn and has an extra Knight compared to the second position. But the evaluator is just not at all looking to next moves. It is already at the end of the calculation chain.

Now a few steps back:

2 plies deep - Here it favours Ne6+??? Because of the earlier explained situation, I can now also explain this move.
A few steps back:

4 plies deep - Here it favours d3 instead of taking the Knight. Again, this follows from the earlier explained situation.

 

The last position happened in a game between TheWeirdEngine (white), and another engine (black) written by someone else who had also incorporated the Witch. TheWeirdEngine still won the game.