Page 1 of 2

Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 3:38 pm
by omnivorist
Some years ago, having read an article about chess programming and the alpha-beta algorithm in particular I found myself musing on the possibility of a chess engine whose evaluation function would simply count the difference in the number of legal moves available to each side. My hunch was that maybe this could be calculated very quickly (almost for free) and that the potential saving could be used to search to a greater depth. My hope was that this simple evaluation might actually give rise to interesting, creative (and quite possibly winning) moves.
So I have recently written an engine based on Vice, the UCI engine written by Bluefever software and described in an excellent series of YouTube videos. I have tested it on the Arena platform, both by playing it myself and secondly in a tournament with Vice. The results are interesting - if a little disappointing.
On the positive side, it plays interesting' non-obvious moves, some of which appear quite promising. On the negative side, the simplicity of the evaluation function is offset by the fact that it is necessary to evaluate an extra set of legal moves at each leaf node and consequently the expected increase in search depth didn’t materialise.
In terms of style of play, restricting the evaluation of a position to the number of moves and no more, results in some disastrous sacrifices. For example a rook with no moves immediately available is considered effectively worthless. I anticipated this but thought that maybe it’s potential might be recognised deeper into the tree. But of course, rooks have a tendency to remain on the sidelines till much later in the play than would be accessible to my search depth.
I also experimented with weighting the valuation of a move according to the piece concerned. So this way, the moves available to the Queen can be weighted sufficiently to avoid the Queen being taken but the side effect is that lesser pieces are readily sacrificed for little more than simply increasing the number of moves available to the Queen, regardless of their immediate usefulness.

All in all, a failed experiment but then, there are few experiments that don’t yield interesting insights.
My intention was to investigate whether chess ‘insight’ could ‘emerge’ from a trivial view of what constitutes a strong position.
I don’t have any plans for further development beyond possibly introducing an additional component of the evaluation based simply on material balance. I imagine this will improve things.
While the approach might have limited value during openings and in the middle game, it could be interesting in the endgame.

If you have any comments or suggestions I’d be most interested to hear from you.

Adv<thanks>ance,
David Wilson

Re: Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 4:49 pm
by abulmo2
n terms of style of play, restricting the evaluation of a position to the number of moves and no more, results in some disastrous sacrifices. For example a rook with no moves immediately available is considered effectively worthless. I anticipated this but thought that maybe it’s potential might be recognised deeper into the tree. But of course, rooks have a tendency to remain on the sidelines till much later in the play than would be accessible to my search depth.
If you think about it, the potential mobility of a piece is approximately contained in the piece value and its positional value.

Re: Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 5:57 pm
by YUFe
omnivorist wrote: Thu Jan 16, 2020 3:38 pmcount the difference in the number of legal moves available to each side.
So a knight would add a maximum of four and a bishop 14 ?
How did the program know that the king is special?
It might be a nice idea for those who make a sport out of writing the smallest possible chess programs.

Re: Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 7:03 pm
by omnivorist
Thanks abulmo for your response:
Yes, you are right mobility is equivalent to the piece value and positional value.
But mobility also reflects the extent to which the piece is blocked in (either by its own side or the opponents).
Representations of position can be quite complex and costly to compute (is this true?). I was hoping that by simply scoring mobility I might capture a more adaptable and abstract representation of positional value and one that was cheap to compute also.
I would be the first to agree that I have failed so far but it has been an interesting ride.

Re: Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 7:13 pm
by omnivorist
Yes YUFe - in my first implementation, knights were being given away cheap on account of maximum 8 moves, compared with the bishop’s 14. I attempted to get over this by assigning a weighting to each piece type and consequently biasing it to value knights more highly. It does appear to make a significant difference.
I didn’t assign a high value to the king as I didn’t want to encourage the king to move into wide open spaces.
The motivation to drive towards check situations arises entirely from the fact that the side that is in check has very few legal moves available and only legal moves contribute to mobility.

Re: Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 7:31 pm
by JohnWoe
Congrats on your engine!

Legal moves are bit costly in eval(). I do only pseudo legals on eval()

Re: Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 7:39 pm
by omnivorist
Yes, computing legal moves purely for eval is almost as costly as a whole extra level of search depth. The code comes for free but not the compute !
I naively thought, when I started out, that the compute would be free also.

Re: Exploring an unusual evaluation function

Posted: Thu Jan 16, 2020 7:51 pm
by omnivorist
How one’s dreams can come crashing down.
When I first began to think about this project I thought the evaluation function would be so fast that I’d be able to explore a whole bunch more levels of the search tree and consequently uncover the long-range results of maximising mobility.
No such luck. But nothing ventured, nothing gained.

Even so, I think the idea of ‘going back’ to some form of simple abstract metric of positional strength is a project worth pursuing.

Re: Exploring an unusual evaluation function

Posted: Fri Jan 17, 2020 9:33 am
by YUFe
omnivorist wrote: Thu Jan 16, 2020 7:51 pm Even so, I think the idea of ‘going back’ to some form of simple abstract metric of positional strength is a project worth pursuing.
Can you give reason for that?
I think a linear increase in compute for the eval is more promising than an exponential inc. in comp. for the search.

Re: Exploring an unusual evaluation function

Posted: Fri Jan 17, 2020 12:30 pm
by omnivorist
YUFe wrote: Fri Jan 17, 2020 9:33 am
omnivorist wrote: Thu Jan 16, 2020 7:51 pm Even so, I think the idea of ‘going back’ to some form of simple abstract metric of positional strength is a project worth pursuing.
Can you give reason for that?
I think a linear increase in compute for the eval is more promising than an exponential inc. in comp. for the search.
I have to say my reason is partly 'aesthetic' in the sense that I am drawn to systems in which some seemingly 'simple' rule gives rise to complexity.
But then I fully understand your point about the relative costs improvements to the eval versus the search depth.
Of course, in some ways my approach might seem like a backward step since the most primitive chess engine is probably one that searches as deep as it can and then evaluates each position purely in terms of material balance. I guess I was hoping that 'mobility' might prove to be a more meaningful measure than pure material balance.
Of course the way strong human players play chess might be said to be all in the evaluation function.

Despite these points, I still like to believe that there might be some simple yet powerful metric that could serve as an evaluation function. It might be called 'opportunity'. But what is that meant to mean? The answer is 'I don't know'.

From your own posts, I realise I am something of a novice in this area and there is still a lot I don't understand. All the same, I hope my musings might inspire others to look for a 'sweet spot' in the eval/search balance.