Toga Knight Outpost

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Tennison
Posts: 183
Joined: Sat Nov 26, 2011 1:02 pm

Toga Knight Outpost

Post by Tennison » Mon Dec 10, 2012 10:49 pm

Please can I have your advice about this change :

Original Toga 1.4 beta 5c :

Code: Select all

// Knight Outpost

			mob = 0;
			if (me == White){
				if (board->square[from-17] == WP)
					mob += KnightOutpostMatrix[me][SquareTo64[from]];
				if (board->square[from-15] == WP)
					mob += KnightOutpostMatrix[me][SquareTo64[from]];
			}
			else{
				if (board->square[from+17] == BP)
					mob += KnightOutpostMatrix[me][SquareTo64[from]];
				if (board->square[from+15] == BP)
					mob += KnightOutpostMatrix[me][SquareTo64[from]];
			}

			op[me] += mob;
My new version :

Code: Select all

            mob = 0;
            defender=0;
            attacker=0;

            if (me == White){
                if (board->square[from-17] == WP) defender+=1;

                if (board->square[from-15] == WP) defender+=1;

                if (defender==1) mob += KnightOutpostMatrix[me][SquareTo64[from]];
                else if (defender==2) mob += KnightOutpostMatrix[me][SquareTo64[from]]*8/5;

                if ((board->square[from+17] == BP) || ((board->square[from+33] == BP) && (board->square[from+17] != WP))) attacker+=1;
                if ((board->square[from+15] == BP) || ((board->square[from+31] == BP) && (board->square[from+15] != WP))) attacker+=1;

                if (attacker == 0) mob+= 4;
                else
                if (attacker == 1) mob-= 2;
                else mob-= 4;


            }
            else{
                if (board->square[from+17] == BP) defender+=1;

                if (board->square[from+15] == BP) defender+=1;

                if (defender==1) mob += KnightOutpostMatrix[me][SquareTo64[from]];
                else if (defender==2) mob += KnightOutpostMatrix[me][SquareTo64[from]]*8/5;

                if ((board->square[from-17] == WP) || ((board->square[from-33] == WP) && (board->square[from-17] != BP))) attacker+=1;
                if ((board->square[from-15] == WP) || ((board->square[from-31] == WP) && (board->square[from-15] != BP))) attacker+=1;

                if (attacker == 0) mob+= 4;
                else
                if (attacker == 1) mob-= 2;
                else mob-= 4;


            }

			op[me] += mob;
I'm not a good programmer; I'm just a beginner so code is not yet optimized.
My goal is to understand a little bit chess engine programming ...

Thanks a lot

jd1
Posts: 266
Joined: Wed Oct 24, 2012 12:07 am

Re: Toga Knight Outpost

Post by jd1 » Mon Dec 10, 2012 11:33 pm

Hi Ben,

Welcome to computer chess programming!

As probably the only active developer of Toga II, here are my comments:

1. You have introduced a penalty for a knight attacked or attackable by a pawn. This is something which dan be improved and in the latest version, soon to be released, I do not score outposts attacked by a pawn. In your code, you however may have negative mob if the knight is not on an outpost and can be attacked. Did you intend this?

2. Personally I don't think it matters whether one or 2 pawns attacks a knight - you have a different penalty.

3. Use "defender++" rather than "defender += 1", it is more usual.

4. Your bonuses/penalties are quite small (2 or 4), so they will not change the engines play significantly, I think you will also have a measurable slowdown from the extra code. In particular the unattacked knight bonus could probably go up to 10. A similar idea is on my TODO list.

Lastly, test your changes. I would be interested to see your results.

All the best,
Jerry

Tennison
Posts: 183
Joined: Sat Nov 26, 2011 1:02 pm

Re: Toga Knight Outpost

Post by Tennison » Mon Dec 10, 2012 11:52 pm

Thanks for your time,

I made two changes :

First,I add an "attacker bonus" as you said;

Second, if 2 defenders I don't do an "outpost bonus"X2 but an "outpost bonus"X1.6 because I think X2 is too much in my own OTB playing history.

On the first change, I put only little "bonus" because values aren't optimize now, I'm just verifying the ideas.

As you ask, maybe it's better to don't have negative mob if not an outpost ... I must try the two solutions.

As a beginner, I have problems to correctly compile : so to do my tests I have compiled a personal "original 1.4 beta 5c" and I test against it.

After some thousands ultra fasts games I have a +10/+25 elo gain.

jd1
Posts: 266
Joined: Wed Oct 24, 2012 12:07 am

Re: Toga Knight Outpost

Post by jd1 » Tue Dec 11, 2012 2:57 am

Hi Ben,

Most interesting :)

I agree that 2x bonus for two defenders is too much. Thinking about it, I would suggest 1.5 (*3/2) as the difference is neglible and this may be slightly faster.

That is good - it always best to compare the same compiles. Do you think you could pm me the new code - I will try it in the latest Toga version. If you would like the latest Toga please also pm me - I will send it to you.

In the future, you are also welcome to post patches like this at the Toga forum http://www.computerchess.info/tdbb/phpBB3/index.php

And one last question, how many games did you play, what was the score, and at what time control?

The current patch to beta5c is worth about +5 elo, so +10-25 elo would be an improvement.

Thanks,
Jerry

Tennison
Posts: 183
Joined: Sat Nov 26, 2011 1:02 pm

Re: Toga Knight Outpost

Post by Tennison » Tue Dec 11, 2012 7:10 am

Hi Jerry,

Here is a simplified version of the code (I hope a little bit easier to read and a little bit faster); I change the values from 8/5 to 3/2 as you said.

I'm now testing it ...

Code: Select all

mob = 0;
            defender=0;
            attacker=0;
            KOM_multi=0;

            if (me == White){
                if (board->square[from-17] == WP) defender+=1;
                if (board->square[from-15] == WP) defender+=1;

                if (defender==1) KOM_multi+= 4;
                else if (defender==2) KOM_multi+= 6;

                if ((board->square[from+17] == BP) || ((board->square[from+33] == BP) && (board->square[from+17] != WP))) attacker+=1;
                if ((board->square[from+15] == BP) || ((board->square[from+31] == BP) && (board->square[from+15] != WP))) attacker+=1;

                if (defender>=1)
                    {
                    if (attacker == 0) KOM_multi+= 4;
                    else
                    if (attacker == 1) KOM_multi-= 1;
                    else  KOM_multi-= 2;
                    }

            }
            else{
                if (board->square[from+17] == BP) defender+=1;
                if (board->square[from+15] == BP) defender+=1;

                if (defender==1) KOM_multi+= 4;
                else if (defender==2) KOM_multi+= 6;

                if ((board->square[from-17] == WP) || ((board->square[from-33] == WP) && (board->square[from-17] != BP))) attacker+=1;
                if ((board->square[from-15] == WP) || ((board->square[from-31] == WP) && (board->square[from-15] != BP))) attacker+=1;

                if (defender>=1)
                    {
                    if (attacker == 0) KOM_multi+= 4;
                    else
                    if (attacker == 1) KOM_multi-= 1;
                    else  KOM_multi-= 2;
                    }

            }
            mob+= KnightOutpostMatrix[me][SquareTo64[from]]*KOM_multi/4;

Tennison
Posts: 183
Joined: Sat Nov 26, 2011 1:02 pm

Re: Toga Knight Outpost

Post by Tennison » Tue Dec 11, 2012 8:26 am

Currently, with ultra fast games, here are the results :

Code: Select all

Games Completed = 2168 of 7420

Settings = Gauntlet/128MB/10ms per move/M 1000cp for 12 moves, D 150 moves/EPD:8moves.epd(3710)               

 1.   Toga Returns Base     1047.0/2168   803-877-488     (L: m=877 t=0 i=0 a=0)   (D: r=351 i=81 f=45 s=2 a=9)   (tpm=23.0 d=6.2 nps=0)
 2.   Toga Returns Outpost 002   1121.0/2168   877-803-488     (L: m=803 t=0 i=0 a=0)   (D: r=351 i=81 f=45 s=2 a=9)   (tpm=23.0 d=6.2 nps=0)

--> 51,7 % (elo gain : +10/+12)

jd1
Posts: 266
Joined: Wed Oct 24, 2012 12:07 am

Re: Toga Knight Outpost

Post by jd1 » Tue Dec 11, 2012 9:37 am

Hi Ben,

That is promising!

I wonder whether you could also test afterwards not giving a bonus at all to an attacked knight outpost? From my (~2100 elo) chess knowledge this would seem most logical. To do that just set KOM_multi = 0 if attacker > 0.

Also, could you test the current Toga II 1.9e knight outpost code against yours:

Code: Select all

// outpost
            mob = 0;
            if (me == White && (board->square[from+17] != BP && board->square[from+15] != BP)){// not attacked: idea from William H. Mowery
                if (board->square[from-17] == WP)
                    mob += KnightOutpostMatrix[me][SquareTo64[from]]; 
                if (board->square[from-15] == WP)
                    mob += KnightOutpostMatrix[me][SquareTo64[from]]; 
            }
            else if (me == Black && (board->square[from-17] != WP && board->square[from-15] != WP)){
                if (board->square[from+17] == BP)
                    mob += KnightOutpostMatrix[me][SquareTo64[from]]; 
                if (board->square[from+15] == BP)
                    mob += KnightOutpostMatrix[me][SquareTo64[from]]; 
            } 

            op[me] += mob;
The current code still doubles the bonus for a twice defended outpost. I also feel that the value in the table KnightOutpostMatrix are rather small - also on my TODO list!

Whichever code is best will be used in the forthcoming release of Toga II 2.0, currently about 30-50 elo stronger than 1.4 beta 5c. Your contribution will of course be noted :D

Thanks a lot,
Jerry

Michel
Posts: 2046
Joined: Sun Sep 28, 2008 11:50 pm

Re: Toga Knight Outpost

Post by Michel » Tue Dec 11, 2012 10:05 am

Whichever code is best will be used in the forthcoming release of Toga II 2.0, currently about 30-50 elo stronger than 1.4 beta 5c.
Nice! It would be good if there were finally some real improvements in Toga, rather than just recompiles with slightly altered settings or trivial modifications.

Although the people who did that seemed to have all moved on to the Ippo family.

User avatar
Rebel
Posts: 4700
Joined: Thu Aug 18, 2011 10:04 am

Re: Toga Knight Outpost

Post by Rebel » Tue Dec 11, 2012 10:44 am

jd1 wrote:Hi Ben,

Welcome to computer chess programming!

As probably the only active developer of Toga II, here are my comments:

1. You have introduced a penalty for a knight attacked or attackable by a pawn. This is something which dan be improved and in the latest version, soon to be released, I do not score outposts attacked by a pawn.
About the latter, if a knight can be attacked by an enemy pawn it can't be called an outpost. YMMV. When there is a white knight on d5 and there is a black pawn on c6/c7 | e6/e7 I don't reward an outpost bonus.

Gerd Isenberg
Posts: 2127
Joined: Wed Mar 08, 2006 7:47 pm
Location: Hattingen, Germany

Re: Toga Knight Outpost

Post by Gerd Isenberg » Tue Dec 11, 2012 11:06 am

Rebel wrote:
jd1 wrote:Hi Ben,

Welcome to computer chess programming!

As probably the only active developer of Toga II, here are my comments:

1. You have introduced a penalty for a knight attacked or attackable by a pawn. This is something which dan be improved and in the latest version, soon to be released, I do not score outposts attacked by a pawn.
About the latter, if a knight can be attacked by an enemy pawn it can't be called an outpost. YMMV. When there is a white knight on d5 and there is a black pawn on c6/c7 | e6/e7 I don't reward an outpost bonus.
Hi Ed,
that seems the usual definition as implemented in computer chess, but see Nimzowitsch's classical definition of the Outpost, provoking to weaken an opponent pawn on a half-open file no longer "Biting on Granite".

https://chessprogramming.wikispaces.com/Outposts

Post Reply