Toga Knight Outpost

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Re: Toga Knight Outpost

Post by Michel »

52,75% would be a very good result for a relatively small change!
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Toga Knight Outpost

Post by lucasart »

Michel wrote:52,75% would be a very good result for a relatively small change!
Indeed: I would be very surprised if the entire knight/bishop outpost code it even worth 52.75% (with or without the refinement compared to Toga with knight/bishop outpost removed).
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
jd1
Posts: 269
Joined: Wed Oct 24, 2012 2:07 am

Re: Toga Knight Outpost

Post by jd1 »

Yes, indeed, 52.75% is nearly 20 elo - so like Lucas said I doubt outposts alone are worth that much. However, it is self-play which may exaggerate. Nevertheless, Ben, do you think you could post the code? I would like to test it myself to see whether I can validate your results.

Thanks,
Jerry
Tennison
Posts: 183
Joined: Sat Nov 26, 2011 2:02 pm

Re: Toga Knight Outpost

Post by Tennison »

To verify, I retried the test of the DV1.65.

Same conditions & 5000 games.

DV1.65 - Test 2 : 52,7%


I just try this night first version of modified bishop eval.

First try is - it's logical - not good :

DV1.66 : 52.1%
Tennison
Posts: 183
Joined: Sat Nov 26, 2011 2:02 pm

Re: Toga Knight Outpost

Post by Tennison »

It's not only Knight Outpost. It's all the Knight Eval in Eval_Piece that is changed.

New Outpost and New Mobility.
Tennison
Posts: 183
Joined: Sat Nov 26, 2011 2:02 pm

Re: Toga Knight Outpost

Post by Tennison »

As I said, I'm not a good programmer and code should be optimized maybe.
But the algorythm seems ok.
Maybe needs some tunings again with values.

Original Code :

Code: Select all

            // mobility

            mob = -KnightUnit;

            mob += unit[board->square[from-33]];
            mob += unit[board->square[from-31]];
            mob += unit[board->square[from-18]];
            mob += unit[board->square[from-14]];
            mob += unit[board->square[from+14]];
            mob += unit[board->square[from+18]];
            mob += unit[board->square[from+31]];
            mob += unit[board->square[from+33]];

            op[me] += mob * KnightMobOpening;
            eg[me] += mob * KnightMobEndgame;


			// 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;
DV1.65 Code :

Code: Select all

            mob = -KnightUnit;
            defender=0;
            attacker=0;
            possible_attacker=0;
            KOM_multi=0;
            no_attack=0;

             if (me == White){

               /// Safe Mobility
               if ((board->square[from-18] != BP && board->square[from-16] != BP))    mob+= unit[board->square[from-33]];
               if ((board->square[from-16] != BP && board->square[from-14] != BP))    mob+= unit[board->square[from-31]];
               if ((board->square[from- 3] != BP && board->square[from- 1] != BP))    mob+= unit[board->square[from-18]];
               if ((board->square[from+ 1] != BP && board->square[from+ 3] != BP))    mob+= unit[board->square[from-14]];
               if ((board->square[from+48] != BP && board->square[from+50] != BP))    mob+= unit[board->square[from+33]];
               if ((board->square[from+46] != BP && board->square[from+48] != BP))    mob+= unit[board->square[from+31]];
               if ((board->square[from+33] != BP && board->square[from+35] != BP))    mob+= unit[board->square[from+18]];
			   if ((board->square[from+29] != BP && board->square[from+31] != BP))    mob+= unit[board->square[from+14]];

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

               if (defender>=1)
                    {
                    if (board->square[from+17] == BP)  attacker+=1;
                    if (board->square[from+15] == BP)  attacker+=1;
                    if ((board->square[from+33] == BP) && (board->square[from+17] != WP)) possible_attacker+=1;
                    if ((board->square[from+31] == BP) && (board->square[from+15] != WP)) possible_attacker+=1;
                    }
            }
            else{
               if ((board->square[from-48] != WP && board->square[from-50] != WP))    mob+= unit[board->square[from-33]];
               if ((board->square[from-46] != WP && board->square[from-48] != WP))    mob+= unit[board->square[from-31]];
               if ((board->square[from-33] != WP && board->square[from-35] != WP))    mob+= unit[board->square[from-18]];
               if ((board->square[from-29] != WP && board->square[from-31] != WP))    mob+= unit[board->square[from-14]];
               if ((board->square[from+18] != WP && board->square[from+16] != WP))    mob+= unit[board->square[from+33]];
               if ((board->square[from+16] != WP && board->square[from+14] != WP))    mob+= unit[board->square[from+31]];
               if ((board->square[from+ 3] != WP && board->square[from+ 1] != WP))    mob+= unit[board->square[from+18]];
               if ((board->square[from- 1] != WP && board->square[from- 3] != WP))    mob+= unit[board->square[from+14]];

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

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

            if (defender==1) KOM_multi+= 8;
                else if (defender==2) KOM_multi+= 15; // 1.65 = 15

            if (attacker == 1) no_attack-= 6;
                else  if (attacker == 2) no_attack-= 8;
                else
                      {
                       if (possible_attacker == 1) no_attack-= 3;
                       else  if (possible_attacker == 2) no_attack-= 4;
                      }

            op[me] += (mob * KnightMobOpening) + (KnightOutpostMatrix[me][SquareTo64[from]]*KOM_multi/8)  + no_attack;
            eg[me] += mob * KnightMobEndgame;

/// From Toga 1.3.4 ----------------------------------

            static const int EndgamePawnKnight = 10; 
            static const int EndgamePassedPawnKnight = 10;

            penalty = 0;
			if (((board->pawn_file[opp][FileA] | board->pawn_file[opp][FileB] | board->pawn_file[opp][FileC]) != 0)
				&& ((board->pawn_file[opp][FileF] | board->pawn_file[opp][FileG] | board->pawn_file[opp][FileH]) != 0))
				penalty -= EndgamePawnKnight;

			if (((pawn_info->passed_bits[opp] & 224)) != 0 && ((pawn_info->passed_bits[opp] & 7) != 0))
				penalty -= EndgamePassedPawnKnight;

            eg[me] += penalty;
/// End of Toga 1.3.4 ----------------------------------

The add-on from Toga 1.3.4 is the only change between DV1.62 and DV1.65 (+0,4%)
Tennison
Posts: 183
Joined: Sat Nov 26, 2011 2:02 pm

Re: Toga Knight Outpost

Post by Tennison »

I made new tests still being played ...

The first and second tests with DV1.65 gave 52,75% and 52,7% as I said.
The Time Control was 10ms/move. 5000 games each test. AMD Processor.

The current test on AMD is 10" + 0,1"/move, 1000 games.
Partial results give 53,1% after 661 games.

The current test on Intel is 100ms/move, 10.000 games.
Partial results give 53,34% after 2198 games.

As we can see, results seems coherents.

I hope a first released version near Christmas. This will be my gift ... :-)
jd1
Posts: 269
Joined: Wed Oct 24, 2012 2:07 am

Re: Toga Knight Outpost

Post by jd1 »

Hi Ben,

Have tried the code myself - I didn't run a long test but was also able to get significant (~25) improvement at bullet. So congratulations!

Curiously enough your code makes Toga significantly slower, however the increased accuracy of the knight mobility evaluation appears to more than compensate.

Jerry
lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Toga Knight Outpost

Post by lucasart »

jd1 wrote:Hi Ben,

Have tried the code myself - I didn't run a long test but was also able to get significant (~25) improvement at bullet. So congratulations!

Curiously enough your code makes Toga significantly slower, however the increased accuracy of the knight mobility evaluation appears to more than compensate.

Jerry
In a bitboard based engine,. that code would be so much more concise and elegant (as well as much faster)...
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
jd1
Posts: 269
Joined: Wed Oct 24, 2012 2:07 am

Re: Toga Knight Outpost

Post by jd1 »

Agreed. Another advantage of bitboards IMO is that evaluation of threats (loose, hanging pieces, etc.) is a lot simpler and more efficient.