IvanHoe 999946 Beta

Discussion about chess-playing software (engines, hosts, opening books, platforms, etc...)
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

@ tomgdrums

Please see the RobboBases thread which has a lot of info.
PAWN : Knight >> Bishop >> Rook >>Queen
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

Compliments of the season!! IvanHoe 999946h package has been re-uploaded with addition of Android support. It should work on Froyo (2.2), but tested only on Gingerbread (2.3.x). RobboBase usage is untested.

7b920df9ecc1a759bae5c01ea4bab9e6 IvanHoe999946h.7z

Code: Select all

db5cc6b67fdbe18eedf5b75173a04153  ./Android/RobboBaseLib.so
cb097cfaadd7cbf9e3a66986e2febc43  ./Android/IvanHoe999946h
Changes were made to accommodation the portable device build which includes, but not limited to trimmed UCI options:

Code: Select all

option name Hash type spin min 1 max 1024 default 8
option name Threads type spin min 1 max 4 default 4
option name Ponder type check default false
option name RobboBaseDynamicLibraryFile type string default NULL
option name RobboTripleBaseDirectory type string default NULL
option name RobboTotalBaseDirectory type string default NULL
option name LoadOnWeakProbe type combo var AllWays var UnlessPondered var Refrain default AllWays
option name UnloadDeregisterInform type combo var Inert var DeRegisterTotal var UnLoadTriple default Inert
option name MultiPV type spin min 1 max 250 default 1
option name SendCurrmove type check default true
option name UCI_Chess960 type check default false
For some multi-core devices (e.g. my HTC Sensation), number of processors auto-detection is always set to one. /proc/cpuinfo also returns 1, but UCI Threads option allows increasing the value.

Image
Command Line

Image
Benchmark

Image
Chess For Android Settings

Image
Match
PAWN : Knight >> Bishop >> Rook >>Queen
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

IvanHoe 999946h updated! The binaries/executables were rebuilt and re-uploaded. CPU support raised to 16, and time management correction. Happy New Year!

b48b1d2a77157082da33acf23cf9d46a IvanHoe999946h.7z

Code: Select all

49bdd436e2bb6a4c9a20a1df4d832173  ./Android/IvanHoe999946h
03268308db810c26158f0038b32737f5  ./Linux/Mode_Analysis/x86-64/IvanHoe999946h
671e0764ef8872e50128d4c59ff416ec  ./Linux/Mode_Analysis/x86-32/IvanHoe999946h
9816ca86b40b14ba86844432d446710a  ./Linux/Mode_Game_Play/x86-64/IvanHoe999946h
9b85680da0ba8f3856d5f6400210de10  ./Linux/Mode_Game_Play/x86-32/IvanHoe999946h
9385c0ad3bc0737cbeb538ca938eb8b9  ./Windows/Mode_Analysis/x86-64/IvanHoe999946h.exe
0486c66dda0ad59d9a4ad5d3b7a41b10  ./Windows/Mode_Analysis/x86-32/IvanHoe999946h.exe
afde44bfc3dd2e107650be658408ad9d  ./Windows/Mode_Game_Play/x86-64/IvanHoe999946h.exe
e6d23ee6d6b7c89c034b8e0bdf6e837b  ./Windows/Mode_Game_Play/x86-32/IvanHoe999946h.exe
Sample games against Komodo 4:
PAWN : Knight >> Bishop >> Rook >>Queen
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

Well, was a bit in hurry to get out yesterday.

The initial update has the following signatures:

fafd3f9dd85ee10427650dd199855dda IvanHoe999946h.7z

Code: Select all

fba2000d8469a6ad99f77c9ad32cb4d1 ./Android/IvanHoe999946h
03268308db810c26158f0038b32737f5 ./Linux/Mode_Analysis/x86-64/IvanHoe999946h
671e0764ef8872e50128d4c59ff416ec ./Linux/Mode_Analysis/x86-32/IvanHoe999946h
1f320619080ccd3261666ff3c79d8c1d ./Linux/Mode_Game_Play/x86-64/IvanHoe999946h
ca7ea6a4cba41e2abdba794ca4275b35 ./Linux/Mode_Game_Play/x86-32/IvanHoe999946h
9385c0ad3bc0737cbeb538ca938eb8b9 ./Windows/Mode_Analysis/x86-64/IvanHoe999946h.exe
0486c66dda0ad59d9a4ad5d3b7a41b10 ./Windows/Mode_Analysis/x86-32/IvanHoe999946h.exe
7105066c9ce68235c47bab1d7dc9e13c ./Windows/Mode_Game_Play/x86-64/IvanHoe999946h.exe
93f4c2cbf2b40acfb4b75de62f4e1dce ./Windows/Mode_Game_Play/x86-32/IvanHoe999946h.exe
This is the most up-to-date and final release of the 999946h build, and it is worth re-downloading:

b48b1d2a77157082da33acf23cf9d46a IvanHoe999946h.7z

Code: Select all

49bdd436e2bb6a4c9a20a1df4d832173  ./Android/IvanHoe999946h
03268308db810c26158f0038b32737f5  ./Linux/Mode_Analysis/x86-64/IvanHoe999946h
671e0764ef8872e50128d4c59ff416ec  ./Linux/Mode_Analysis/x86-32/IvanHoe999946h
9816ca86b40b14ba86844432d446710a  ./Linux/Mode_Game_Play/x86-64/IvanHoe999946h
9b85680da0ba8f3856d5f6400210de10  ./Linux/Mode_Game_Play/x86-32/IvanHoe999946h
9385c0ad3bc0737cbeb538ca938eb8b9  ./Windows/Mode_Analysis/x86-64/IvanHoe999946h.exe
0486c66dda0ad59d9a4ad5d3b7a41b10  ./Windows/Mode_Analysis/x86-32/IvanHoe999946h.exe
afde44bfc3dd2e107650be658408ad9d  ./Windows/Mode_Game_Play/x86-64/IvanHoe999946h.exe
e6d23ee6d6b7c89c034b8e0bdf6e837b  ./Windows/Mode_Game_Play/x86-32/IvanHoe999946h.exe
PAWN : Knight >> Bishop >> Rook >>Queen
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

kingliveson wrote: This is the most up-to-date and final release of the 999946h build
Well, not quite. After some testing, that time management was still not efficient overall, so I reworked and cleaned it up a bit. It absolutely now should not lose on time, get into time trouble, or play too fast -- it will self-correct over the course of the game. I hope they decide to use it in the next release.

control.c
static void TimeManager (sint64 TIME, sint64 OPP_TIME, sint64 INCREMENT, int mtg)
{  
  double rat;

  if (mtg)
  {
    if (mtg > 25)
      mtg = 25;

    DESIRED_TIME = TIME  / mtg + INCREMENT;

    ABSOLUTE_TIME = (TIME * mtg) / (4 * mtg - 3) - MIN (1000000, TIME / 10);
    if (mtg == 1)
      ABSOLUTE_TIME -= MIN (1000000, ABSOLUTE_TIME / 10);

    if (ABSOLUTE_TIME < 1000) /* porque? */
      ABSOLUTE_TIME = 1000;
  }
  else
  {
    ABSOLUTE_TIME = (TIME * ABSOLUTE_PERCENT) / 100 - 10000;

    if (ABSOLUTE_TIME < 1000)
      ABSOLUTE_TIME = 1000;

    DESIRED_TIME = (TIME * DESIRED_MILLIS) / 1000 + INCREMENT;
  }

  if (SINCE_NEW_GAME < BOOK_EXIT_MOVES)
    DESIRED_TIME += (DESIRED_TIME * (BOOK_EXIT_MOVES - SINCE_NEW_GAME)) / BOOK_EXIT_MOVES;

#if 1

  if (!BUFFER_TIME && TIME > 10000000)
    BUFFER_TIME = 2000;

  if (!DESIRED_TIME_FLAG)
  {
    if (ROOT_DEPTH  && TIME > 60000000 && ROOT_SCORE < -10)
    {
      if (ROOT_SCORE < -10 && ROOT_SCORE >= -20)
        DESIRED_TIME += DESIRED_TIME >> 5;
      else if (ROOT_SCORE < -20 && ROOT_SCORE >= -40)
        DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE < -40 && ROOT_SCORE >= -60)
        DESIRED_TIME += DESIRED_TIME >> 3;
      else if (ROOT_SCORE < -60 && ROOT_SCORE >= -80)
        DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE < -80 && ROOT_SCORE >= -100)
        DESIRED_TIME += DESIRED_TIME >> 5;
    }

    else if (ROOT_DEPTH  && TIME > 60000000 && ROOT_SCORE > 10)
    {
      if (ROOT_SCORE > 10 && ROOT_SCORE <= 20)
        DESIRED_TIME += DESIRED_TIME >> 5;
      else if (ROOT_SCORE > 20 && ROOT_SCORE <= 40)
        DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE > 40 && ROOT_SCORE <= 60)
        DESIRED_TIME += DESIRED_TIME >> 3;
      else if (ROOT_SCORE > 60 && ROOT_SCORE <= 80)
        DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE > 80 && ROOT_SCORE <= 100)
        DESIRED_TIME += DESIRED_TIME >> 5;
    }

    DESIRED_TIME_FLAG = 1;
  }
  else if (DESIRED_TIME_FLAG)
  {
    rat = ((double) (TIME + 1)) / ((double) (OPP_TIME + 1));

    if (rat > 1.125)
      DESIRED_TIME += (8 * DESIRED_TIME) >> 4;
    else if (rat < 0.875)
      DESIRED_TIME -= (8 * DESIRED_TIME) >> 4;

    DESIRED_TIME_FLAG = 0;
  }
#endif

  if (DESIRED_TIME > ABSOLUTE_TIME)
    DESIRED_TIME = ABSOLUTE_TIME;
  if (DESIRED_TIME < 1000)
    DESIRED_TIME = 1000;
  EASY_TIME = (DESIRED_TIME * EASY_FACTOR) / 100;
  if (UCI_PONDER)
    EASY_TIME = (DESIRED_TIME * EASY_FACTOR_PONDER) / 100;
  BATTLE_TIME = (DESIRED_TIME * BATTLE_FACTOR) / 100;
  ORDINARY_TIME = (DESIRED_TIME * ORDINARY_FACTOR) / 100;
}
main.c

Code: Select all

 
DESIRED_TIME_FLAG = 0;
EASY_FACTOR_PONDER = 25;
BATTLE_FACTOR = 80;
ORDINARY_FACTOR = 60;
ABSOLUTE_PERCENT = 20;
robbolito.h

Code: Select all

int DESIRED_TIME_FLAG;
After testing is complete, a new build will be released. Also, alternative time management code is removed along with some timing UCI options, perhaps this might help some Fritz users having issue displaying all UCI options due to bug in the GUI.
PAWN : Knight >> Bishop >> Rook >>Queen
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

Ok, after some more testing, IvanHoe 999946h has been rebuilt and re-uploaded once more, and hopefully the last. The 32-bit version now supports 32 CPUs and the 64-bit version, 64. The new time management was tested against Komodo 4 and Critter 1.4 at 1+0, 3+0, 3+2, 5+0, 5+3, 10+0, 15+10, and 60+0 time controls. The build has the following md5sum signatures:

8206de704af4a7463038509ae334fa26 IvanHoe999946h.7z

Code: Select all

87d35b20edb9774a6d661b2cdefdf56a  ./Android/IvanHoe999946h
71a4c1b85e06ea9b75202bed27699cce  ./Linux/Mode_Analysis/x86-64/IvanHoe999946h
93f76295865ab412a9095e0bf5dd2e22  ./Linux/Mode_Analysis/x86-32/IvanHoe999946h
1836d5a0ac63062bc8f7c2d08448ed75  ./Linux/Mode_Game_Play/x86-64/IvanHoe999946h
72641a69177860069912f65dc8d782cb  ./Linux/Mode_Game_Play/x86-32/IvanHoe999946h
cbc12a704d2fe4fe6539cfb4a5855cbc  ./Windows/Mode_Analysis/x86-64/IvanHoe999946h.exe
cd38cb8b5b116b753428be38199fe499  ./Windows/Mode_Analysis/x86-32/IvanHoe999946h.exe
60521c66f10e69651d805339dc94fae7  ./Windows/Mode_Game_Play/x86-64/IvanHoe999946h.exe
1881abb97f6263a6dc2e8ee1559d0d4a  ./Windows/Mode_Game_Play/x86-32/IvanHoe999946h.exe
An example of getting into time trouble and losing:


Changes made to the time management:

control.c
void TimeManager (sint64 TIME, sint64 OPP_TIME, sint64 INCREMENT, int mtg)
{  
  double rat;

  if (mtg)
  {
    if (mtg > 25)
      mtg = 25;

    DESIRED_TIME = TIME  / mtg + INCREMENT;

    ABSOLUTE_TIME = (TIME * mtg) / (4 * mtg - 3) - MIN (1000000, TIME / 10);
    if (mtg == 1)
      ABSOLUTE_TIME -= MIN (1000000, ABSOLUTE_TIME / 10);

    if (ABSOLUTE_TIME < 1000) /* porque? */
      ABSOLUTE_TIME = 1000;
  }
  else
  {
    ABSOLUTE_TIME = (TIME * ABSOLUTE_PERCENT) / 100 - 10000;

    if (ABSOLUTE_TIME < 1000)
      ABSOLUTE_TIME = 1000;

    DESIRED_TIME = (TIME * DESIRED_MILLIS) / 1000 + INCREMENT;
  }

  if (SINCE_NEW_GAME < BOOK_EXIT_MOVES)
    DESIRED_TIME += (DESIRED_TIME * (BOOK_EXIT_MOVES - SINCE_NEW_GAME)) / BOOK_EXIT_MOVES;

#if 1

  if (!BUFFER_TIME && !INCREMENT &&  TIME > 10000000) BUFFER_TIME = 2000;

  if (DESIRED_TIME_FLAG)
  {
    if (ROOT_DEPTH  && TIME > 60000000 && ROOT_SCORE < -10)
    {
      if (ROOT_SCORE < -10 && ROOT_SCORE >= -20)       DESIRED_TIME += DESIRED_TIME >> 5;
      else if (ROOT_SCORE < -20 && ROOT_SCORE >= -40)  DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE < -40 && ROOT_SCORE >= -60)  DESIRED_TIME += DESIRED_TIME >> 3;
      else if (ROOT_SCORE < -60 && ROOT_SCORE >= -80)  DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE < -80 && ROOT_SCORE >= -100) DESIRED_TIME += DESIRED_TIME >> 5;
    }

    else if (ROOT_DEPTH  && TIME > 60000000 && ROOT_SCORE > 10)
    {
      if (ROOT_SCORE > 10 && ROOT_SCORE <= 20)       DESIRED_TIME += DESIRED_TIME >> 5;
      else if (ROOT_SCORE > 20 && ROOT_SCORE <= 40)  DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE > 40 && ROOT_SCORE <= 60)  DESIRED_TIME += DESIRED_TIME >> 3;
      else if (ROOT_SCORE > 60 && ROOT_SCORE <= 80)  DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE > 80 && ROOT_SCORE <= 100) DESIRED_TIME += DESIRED_TIME >> 5;
    }

    DESIRED_TIME_FLAG = 0;
  }
  else
  {
    rat = ((double) (TIME + 1)) / ((double) (OPP_TIME + 1));

    if (rat > 1.125)
      DESIRED_TIME += (8 * DESIRED_TIME) >> 4;
    else if (rat < 0.875)
      DESIRED_TIME -= (8 * DESIRED_TIME) >> 4;

    DESIRED_TIME_FLAG = 1;
  }
#endif

  if (DESIRED_TIME > ABSOLUTE_TIME)
    DESIRED_TIME = ABSOLUTE_TIME;
  if (DESIRED_TIME < 1000)
    DESIRED_TIME = 1000;
  EASY_TIME = (DESIRED_TIME * EASY_FACTOR) / 100;
  if (UCI_PONDER)
    EASY_TIME = (DESIRED_TIME * EASY_FACTOR_PONDER) / 100;
  BATTLE_TIME = (DESIRED_TIME * BATTLE_FACTOR) / 100;
  ORDINARY_TIME = (DESIRED_TIME * ORDINARY_FACTOR) / 100;
}
main()

Code: Select all

  
DESIRED_TIME_FLAG = 0;

EASY_FACTOR_PONDER = 25;
BATTLE_FACTOR = 85;
ORDINARY_FACTOR = 64;
ABSOLUTE_PERCENT = 24;
robbolito.h

Code: Select all

int DESIRED_TIME_FLAG;
Negative criticisms are welcomed. :D
PAWN : Knight >> Bishop >> Rook >>Queen
velmarin
Posts: 39
Joined: Thu Mar 17, 2011 11:31 am
Real Name: Jose Mº Velasco

Re: IvanHoe 999946 Beta

Post by velmarin »

I make one executable with their modifications and it seems that I was going well, even fast, have played with DESIRED MILLIS to 48, with no bad results, times from 1 to 3 minutes game.

Indeed ¿As you in order that your archives have always the same date, 9-12-2011, 05,33 make,?

Thank you very much for your efforts.
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

velmarin wrote: ¿As you in order that your archives have always the same date, 9-12-2011, 05,33 make,?
First, If you are in America, that says Sept. 12, 2011, and other parts of the world, Dec. 9, 2011. And if in Eastern Time Zone, 11:33 PM. :) I think IvanHoe 999946h is the 33rd source published, but 29th build from me -- a few releases in the sub-versions (999958[x], 999949[x], and 999948[x]) were one right after another to correct bugs, and so only the newer was built. What am trying to say is, the next major or minor version build from me will have a time stamp, your time, 5:34. Yes the date does not change but the builds are different -- you can see in the UCI parameters. Also, If you check the md5sum signature, you'll see they are not the same. I know it's kind of silly, but everyone has his/her own quirks.

Some additional sample games, ponder-off, 1-core, egtb-on, 5+0:


Edit: there's been 34 published IvanHoe sources.
PAWN : Knight >> Bishop >> Rook >>Queen
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

I was still not satisfied with the time management, so it was tweaked just a little yet again. Rather than halving desired time when in time trouble or given 50% increase if really ahead, ~30% decrease/increase seem sufficient. The idea is a more adaptive, opponent and evaluation based time management.

This is where things are:
void TimeManager (sint64 TIME, sint64 OPP_TIME, sint64 INCREMENT, int mtg)
{  
  double rat;

  if (mtg)
  {
    if (mtg > 25)
      mtg = 25;

    DESIRED_TIME = TIME  / mtg + INCREMENT;

    ABSOLUTE_TIME = (TIME * mtg) / (4 * mtg - 3) - MIN (1000000, TIME / 10);
    if (mtg == 1)
      ABSOLUTE_TIME -= MIN (1000000, ABSOLUTE_TIME / 10);

    if (ABSOLUTE_TIME < 1000) /* porque? */
      ABSOLUTE_TIME = 1000;
  }
  else
  {
    ABSOLUTE_TIME = (TIME * ABSOLUTE_PERCENT) / 100 - 10000;

    if (ABSOLUTE_TIME < 1000)
      ABSOLUTE_TIME = 1000;

    DESIRED_TIME = (TIME * DESIRED_MILLIS) / 1000 + INCREMENT;
  }

  if (SINCE_NEW_GAME < BOOK_EXIT_MOVES)
    DESIRED_TIME += (DESIRED_TIME * (BOOK_EXIT_MOVES - SINCE_NEW_GAME)) / BOOK_EXIT_MOVES;

#if 1

  if (!BUFFER_TIME && !INCREMENT &&  TIME > 10000000) BUFFER_TIME = 2000;

  if (DESIRED_TIME_FLAG)
  {
    if (ROOT_DEPTH  && TIME > 60000000 && ROOT_SCORE < -25)
    {
      if (ROOT_SCORE >= -50)                           DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE < -50 && ROOT_SCORE >= -75)  DESIRED_TIME += DESIRED_TIME >> 3;
      else if (ROOT_SCORE < -75 && ROOT_SCORE >= -100) DESIRED_TIME += DESIRED_TIME >> 4;
    }

    else if (ROOT_DEPTH  && TIME > 60000000 && ROOT_SCORE > 25)
    {
      if (ROOT_SCORE <= 50)                           DESIRED_TIME += DESIRED_TIME >> 4;
      else if (ROOT_SCORE > 50 && ROOT_SCORE <= 75)   DESIRED_TIME += DESIRED_TIME >> 3;
      else if (ROOT_SCORE > 75 && ROOT_SCORE <= 100)  DESIRED_TIME += DESIRED_TIME >> 4;
    }

    DESIRED_TIME_FLAG = 0;
  }
  else
  {
    rat = ((double) (TIME + 1)) / ((double) (OPP_TIME + 1));

    if (rat > 1.25)
      DESIRED_TIME += (DESIRED_TIME >> 2) + DESIRED_TIME >> 2;
    else if (rat < 0.90)
      DESIRED_TIME -= (DESIRED_TIME >> 2) + DESIRED_TIME >> 2;

    DESIRED_TIME_FLAG = 1;
  }
#endif

  if (DESIRED_TIME > ABSOLUTE_TIME)
    DESIRED_TIME = ABSOLUTE_TIME;
  if (DESIRED_TIME < 1000)
    DESIRED_TIME = 1000;
  EASY_TIME = (DESIRED_TIME * EASY_FACTOR) / 100;
  if (UCI_PONDER)
    EASY_TIME = (DESIRED_TIME * EASY_FACTOR_PONDER) / 100;
  BATTLE_TIME = (DESIRED_TIME * BATTLE_FACTOR) / 100;
  ORDINARY_TIME = (DESIRED_TIME * ORDINARY_FACTOR) / 100;
}
main():

Code: Select all

  
DESIRED_TIME_FLAG = 0;

EASY_FACTOR_PONDER = 32;
BATTLE_FACTOR = 88;
ORDINARY_FACTOR = 64;
ABSOLUTE_PERCENT = 24;
RobboLito.h:

Code: Select all

int  DESIRED_TIME_FLAG;
PAWN : Knight >> Bishop >> Rook >>Queen
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: IvanHoe 999946 Beta

Post by kingliveson »

Another approach is leaving the default settings of the time management in main(). Instead of trying to increase how fast it plays then decreasing it based on eval score, which adds too many cycles, just only worry about making sure it doesn't fall too behind:
void TimeManager (sint64 TIME, sint64 OPP_TIME, sint64 INCREMENT, int mtg)
{  
  double rat;

  if (mtg)
  {
    if (mtg > 25)
      mtg = 25;

    DESIRED_TIME = TIME  / mtg + INCREMENT;

    ABSOLUTE_TIME = (TIME * mtg) / (4 * mtg - 3) - MIN (1000000, TIME / 10);
    if (mtg == 1)
      ABSOLUTE_TIME -= MIN (1000000, ABSOLUTE_TIME / 10);

    if (ABSOLUTE_TIME < 1000) /* porque? */
      ABSOLUTE_TIME = 1000;
  }
  else
  {
    ABSOLUTE_TIME = (TIME * ABSOLUTE_PERCENT) / 100 - 10000;

    if (ABSOLUTE_TIME < 1000)
      ABSOLUTE_TIME = 1000;

    DESIRED_TIME = (TIME * DESIRED_MILLIS) / 1000 + INCREMENT;
  }

  if (SINCE_NEW_GAME < BOOK_EXIT_MOVES)
    DESIRED_TIME += (DESIRED_TIME * (BOOK_EXIT_MOVES - SINCE_NEW_GAME)) / BOOK_EXIT_MOVES;

#if 1

  if (!BUFFER_TIME && !INCREMENT &&  TIME > 10000000) BUFFER_TIME = 2000;

  if (DESIRED_TIME_FLAG)
  {
    rat = ((double) (TIME + 1)) / ((double) (OPP_TIME + 1));

    if (rat > 1.25)
      DESIRED_TIME += (DESIRED_TIME >> 2) + DESIRED_TIME >> 2;
    else if (rat < 0.90)
      DESIRED_TIME -= (DESIRED_TIME >> 2) + DESIRED_TIME >> 2;

    DESIRED_TIME_FLAG = 0;
  }
  else
    DESIRED_TIME_FLAG = 1;
  
#endif

  if (DESIRED_TIME > ABSOLUTE_TIME)
    DESIRED_TIME = ABSOLUTE_TIME;
  if (DESIRED_TIME < 1000)
    DESIRED_TIME = 1000;
  EASY_TIME = (DESIRED_TIME * EASY_FACTOR) / 100;
  if (UCI_PONDER)
    EASY_TIME = (DESIRED_TIME * EASY_FACTOR_PONDER) / 100;
  BATTLE_TIME = (DESIRED_TIME * BATTLE_FACTOR) / 100;
  ORDINARY_TIME = (DESIRED_TIME * ORDINARY_FACTOR) / 100;
}
main():

Code: Select all

  
DESIRED_TIME_FLAG = 0;
RobboLito.h:

Code: Select all

int  DESIRED_TIME_FLAG;
PAWN : Knight >> Bishop >> Rook >>Queen
Post Reply