NNUE Versions of Old Open Source Engines

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

BrendanJNorman
Posts: 2584
Joined: Mon Feb 08, 2016 12:43 am
Full name: Brendan J Norman

NNUE Versions of Old Open Source Engines

Post by BrendanJNorman »

I had an idea that might be of interest to some people.

The idea is to revive old, but legendary open source engines and "fix em up" - including changing the eval to NNUE with nets trained on their own games/eval at depth x (or whatever, I'm not a programmer).

I mean, does anyone remember how interesting was the playing style of Phalanx, Romichess and others?

Wouldn't the aggressive Phalanx or the positional, knight outpost loving Romi be interesting as NNUE?

Others you can think of?

IMO it would be interesting, but some would consider it a waste of time due to Elo. :cry:
User avatar
towforce
Posts: 12630
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Re: NNUE Versions of Old Open Source Engines

Post by towforce »

BrendanJNorman wrote: Wed Aug 21, 2024 12:04 pm I had an idea that might be of interest to some people.

The idea is to revive old, but legendary open source engines and "fix em up" - including changing the eval to NNUE with nets trained on their own games/eval at depth x (or whatever, I'm not a programmer).

I mean, does anyone remember how interesting was the playing style of Phalanx, Romichess and others?

Wouldn't the aggressive Phalanx or the positional, knight outpost loving Romi be interesting as NNUE?

Others you can think of?

IMO it would be interesting, but some would consider it a waste of time due to Elo. :cry:

Ed and Chris did this together: the result was two programs, one of which was a new version of Rebel. It was discussed in this thread - link.
Human chess is partly about tactics and strategy, but mostly about memory
Elorejano
Posts: 125
Joined: Sat Mar 20, 2010 3:31 am

Re: NNUE Versions of Old Open Source Engines

Post by Elorejano »

Hi!
Excellent idea! Jim Abblett will be the heroe
I propose, as a first "modernization", a PROTECTOR
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: NNUE Versions of Old Open Source Engines

Post by Mike Sherwin »

BrendanJNorman wrote: Wed Aug 21, 2024 12:04 pm I had an idea that might be of interest to some people.

The idea is to revive old, but legendary open source engines and "fix em up" - including changing the eval to NNUE with nets trained on their own games/eval at depth x (or whatever, I'm not a programmer).

I mean, does anyone remember how interesting was the playing style of Phalanx, Romichess and others?

Wouldn't the aggressive Phalanx or the positional, knight outpost loving Romi be interesting as NNUE?

Others you can think of?

IMO it would be interesting, but some would consider it a waste of time due to Elo. :cry:
Hi Brendan, If Romi went NNUE Romi would not be Romi anymore. The knight outpost and all the other human like qualities that you have noted over the years are part of a handcrafted evaluation. And if I'm honest it can be made much better but not by me. Ever since my mom became sick in 2007 requiring me to take care of her until her passing I have not been able to fully recover myself. If there are others that feel like you do about RomiChess then you should lead a resurrect RomiChess movement and find a chess programmer to join you.

Here is the code that makes Romi seem so human at times. I have not messed with it since 2005. Basically I wrote it, took a week working on it and haven't touched it since. You would need a good chess player in your group and a good programmer and the sky is the limit as far as human like play. I know that Romi's cult following is small but it is very dedicated! So get together and adopt RomiChess and make it yours! :D

Code: Select all

if(!(wBlocker[sq] & bPawns) && (wFrontal[sq] & bPawns))
    {
      if(ray8p[sq] & below[FirstBit(ray8p[sq] & bPawns)] & wPawns)
      {
        wQueenTbl[sq] += 4;
        wRookTbl[sq] -= 4;
        wBishopTbl[sq] += (8 + row);
        wKnightTbl[sq] += (12 + row);
        wKingTbl[sq] += (10 + row);
      }else
      {
        wQueenTbl[sq] +=8;
        wRookTbl[sq] += 6;
        wBishopTbl[sq] += (8 + row * 2);
        wKnightTbl[sq] += (12 + row * 2);
        wKingTbl[sq] += (20 + row * 4);
      }
    }

    if(!(bBlocker[sq] & wPawns) && (bFrontal[sq] & wPawns))
    {
      if(ray8m[sq] & above[LastBit(ray8m[sq] & wPawns)] & bPawns)
      {
        bQueenTbl[sq] += 4;
        bRookTbl[sq] -= 4;
        bBishopTbl[sq] += (8 + (7 - row));
        bKnightTbl[sq] += (12 + (7 - row));
        bKingTbl[sq] += (10 + (7 - row));
      }else
      {
        bQueenTbl[sq] += 8;
        bRookTbl[sq] += 6;
        bBishopTbl[sq] += (8 + (7 - row) * 2);
        bKnightTbl[sq] += (12 + (7 - row) * 2);
        bKingTbl[sq] += (20 + (7 - row) * 4);
      }
    }

    if(row == ROW_7)
    {
      wRookTbl[sq] += 40;
      wRookTbl[sq + 8] += 30;
    }

    if(row == ROW_2)
    {
      bRookTbl[sq] += 40;
      bRookTbl[sq - 8] += 30;
    }
  }

  // Blocked Pawn Penalties
  if(wPawns & D2bit)
  {
    wBishopTbl[D3] -= (BLOCKED_PAWN_BISHOP);
    wKnightTbl[D3] -= (BLOCKED_PAWN_KNIGHT);
    wRookTbl[D3]   -= (BLOCKED_PAWN_ROOK);
    wQueenTbl[D3]  -= (BLOCKED_PAWN_QUEEN);
  }

  if(wPawns & E2bit)
  {
    wBishopTbl[E3] -= (BLOCKED_PAWN_BISHOP);
    wKnightTbl[E3] -= (BLOCKED_PAWN_KNIGHT);
    wRookTbl[E3]   -= (BLOCKED_PAWN_ROOK);
    wQueenTbl[E3]  -= (BLOCKED_PAWN_QUEEN);
  }

  if(bPawns & D7bit)
  {
    bBishopTbl[D6] -= (BLOCKED_PAWN_BISHOP);
    bKnightTbl[D6] -= (BLOCKED_PAWN_KNIGHT);
    bRookTbl[D6]   -= (BLOCKED_PAWN_ROOK);
    bQueenTbl[D6]  -= (BLOCKED_PAWN_QUEEN);
  }

  if(bPawns & E7bit)
  {
    bBishopTbl[E6] -= (BLOCKED_PAWN_BISHOP);
    bKnightTbl[E6] -= (BLOCKED_PAWN_KNIGHT);
    bRookTbl[E6]   -= (BLOCKED_PAWN_ROOK);
    bQueenTbl[E6]  -= (BLOCKED_PAWN_QUEEN);
  }

  // Keep Pawns at Home if King is on same side
  if(bMat > 4600) {
    if(wKings & (E1bit | F1bit | G1bit | H1bit)) {
      wPawnTbl[F2] = (PAWNSHOME_2_7_SQ);
      wPawnTbl[G2] = (PAWNSHOME_2_7_SQ);
      wPawnTbl[H2] = (PAWNSHOME_2_7_SQ);
      wPawnTbl[F3] = (PAWNSHOME_3_6_SQ);
      wPawnTbl[G3] = (PAWNSHOME_3_6_SQ);
      wPawnTbl[H3] = (PAWNSHOME_3_6_SQ); }

    if(wKings & (E1bit | D1bit | C1bit | B1bit | A1bit)) {
      wPawnTbl[C2] = (PAWNSHOME_2_7_SQ);
      wPawnTbl[B2] = (PAWNSHOME_2_7_SQ);
      wPawnTbl[A2] = (PAWNSHOME_2_7_SQ);
      wPawnTbl[C3] = (PAWNSHOME_3_6_SQ);
      wPawnTbl[B3] = (PAWNSHOME_3_6_SQ);
      wPawnTbl[A3] = (PAWNSHOME_3_6_SQ); } }

  if(wMat > 4600) {
    if(bKings & (E8bit | F8bit | G8bit | H8bit)) {
      bPawnTbl[F7] = (PAWNSHOME_2_7_SQ);
      bPawnTbl[G7] = (PAWNSHOME_2_7_SQ);
      bPawnTbl[H7] = (PAWNSHOME_2_7_SQ);
      bPawnTbl[F6] = (PAWNSHOME_3_6_SQ);
      bPawnTbl[G6] = (PAWNSHOME_3_6_SQ);
      bPawnTbl[H6] = (PAWNSHOME_3_6_SQ); }

    if(bKings & (E8bit | D8bit | C8bit | B8bit | A8bit)) {
      bPawnTbl[C7] = (PAWNSHOME_2_7_SQ);
      bPawnTbl[B7] = (PAWNSHOME_2_7_SQ);
      bPawnTbl[A7] = (PAWNSHOME_2_7_SQ);
      bPawnTbl[C6] = (PAWNSHOME_3_6_SQ);
      bPawnTbl[B6] = (PAWNSHOME_3_6_SQ);
      bPawnTbl[A6] = (PAWNSHOME_3_6_SQ); } }

  // Penalty if piece blocks bishop 
  if(wBishops & F1bit) {
    wQueenTbl[E2] -= (BLOCKBISH_QUEEN_2_7_SQ);
    wQueenTbl[D3] -= (BLOCKBISH_QUEEN_3_6_SQ);
    wRookTbl[E2]  -= (BLOCKBISH_ROOK_2_7_SQ);
    wRookTbl[D3]  -= (BLOCKBISH_ROOK_3_6_SQ);
    if(wPawns & G2bit)   {
      wKnightTbl[E2] -= (20);
      if(wPawns & (E2bit | D3bit)) {
        wPawnTbl[G3] += (20);
        wBishopTbl[G2] += (20);
        wPawnTbl[E2] -= (10); } } }

  if(wBishops & C1bit) {
    wQueenTbl[D2] -= (BLOCKBISH_QUEEN_2_7_SQ);
    wQueenTbl[E3] -= (BLOCKBISH_QUEEN_3_6_SQ);
    wRookTbl[D2]  -= (BLOCKBISH_ROOK_2_7_SQ);
    wRookTbl[E3]  -= (BLOCKBISH_ROOK_3_6_SQ);
    if(wPawns & B2bit)   {
      wKnightTbl[D2] -= (10);
      if(wPawns & (D2bit | E3bit)) {
        wPawnTbl[B3] += (20);
        wBishopTbl[B2] += (20);
        wPawnTbl[D2] -= (10); } } }

  if(bBishops & F8bit) {
    bQueenTbl[E7] -= (BLOCKBISH_QUEEN_2_7_SQ);
    bQueenTbl[D6] -= (BLOCKBISH_QUEEN_3_6_SQ);
    bRookTbl[E7]  -= (BLOCKBISH_ROOK_2_7_SQ);
    bRookTbl[D6]  -= (BLOCKBISH_ROOK_3_6_SQ);
    if(bPawns & G7bit)   {
      bKnightTbl[E7] -= (20);
      if(bPawns & (E7bit | D6bit)) {
        bPawnTbl[G6] += (20);
        bBishopTbl[G7] += (20);
        bPawnTbl[E7] -= (10); } } }

  if(bBishops & C8bit) {
    bQueenTbl[D7] -= (BLOCKBISH_QUEEN_2_7_SQ);
    bQueenTbl[E6] -= (BLOCKBISH_QUEEN_3_6_SQ);
    bRookTbl[D7]  -= (BLOCKBISH_ROOK_2_7_SQ);
    bRookTbl[E6]  -= (BLOCKBISH_ROOK_3_6_SQ);
    if(bPawns & B7bit)   {
      bKnightTbl[D7] -= (10);
      if(bPawns & (D7bit | E6bit)) {
        bPawnTbl[B6] += (20);
        bBishopTbl[B7] += (20);
        bPawnTbl[D7] -= (10); } } }

  // Penalty for not Castleing
  wKingTbl[H1] = wKingTbl[G1];
  if(wIndexs & WCASKbit) {
    wKingTbl[F1] = wKingTbl[E1] - (CASTLEPENALTY);
    wKingTbl[G1] -= (CASTLEPENALTY);
    wKingTbl[D1] = wKingTbl[E1] - (CASTLEPENALTY);
    wKingTbl[C1] -= (CASTLEPENALTY);
    wKingTbl[B1] -= (CASTLEPENALTY); }
  wKingTbl[A1] = wKingTbl[B1];

  bKingTbl[H8] = bKingTbl[G8];
  if(bIndexs & BCASKbit) {
    bKingTbl[F8] = bKingTbl[E8] - (CASTLEPENALTY);
    bKingTbl[G8] -= (CASTLEPENALTY);
    bKingTbl[D8] = bKingTbl[E8] - (CASTLEPENALTY);
    bKingTbl[C8] -= (CASTLEPENALTY);
    bKingTbl[B8] -= (CASTLEPENALTY);}
  bKingTbl[A8] = bKingTbl[B8];

  // Penalty for not moving center pawns
  if(wPawns & (E2bit | D2bit)) {
    wPawnTbl[E2] -= (NOTMOVINGCENTRE_2_7);
    wPawnTbl[E3] -= (NOTMOVINGCENTRE_3_6);
    wPawnTbl[D2] -= (NOTMOVINGCENTRE_2_7);
    wPawnTbl[D3] -= (NOTMOVINGCENTRE_3_6);
    if(bPawns & E5bit)
      wPawnTbl[E4] += (CENTRE_PAWN_BONUS);
    if(bPawns & D5bit)
      wPawnTbl[D4] += (CENTRE_PAWN_BONUS); }

  if(bPawns & (E7bit | D7bit)) {
    bPawnTbl[E7] -= (NOTMOVINGCENTRE_2_7);
    bPawnTbl[E6] -= (NOTMOVINGCENTRE_3_6);
    bPawnTbl[D7] -= (NOTMOVINGCENTRE_2_7);
    bPawnTbl[D6] -= (NOTMOVINGCENTRE_3_6);
    if(wPawns & E4bit)
      bPawnTbl[E5] += (CENTRE_PAWN_BONUS);
    if(wPawns & D4bit)
      bPawnTbl[D5] += (CENTRE_PAWN_BONUS); }

  // Encourage development of minor Pieces
  if(ply < 20) { 
    wKnightTbl[G1] -= (ENCOURAGE_KNIGHT_BONUS);
    wKnightTbl[B1] -= (ENCOURAGE_KNIGHT_BONUS);
    wBishopTbl[F1] -= (ENCOURAGE_BISHOP_BONUS);
    wBishopTbl[C1] -= (ENCOURAGE_BISHOP_BONUS);
    bKnightTbl[G8] -= (ENCOURAGE_KNIGHT_BONUS);
    bKnightTbl[B8] -= (ENCOURAGE_KNIGHT_BONUS);
    bBishopTbl[F8] -= (ENCOURAGE_BISHOP_BONUS);
    bBishopTbl[C8] -= (ENCOURAGE_BISHOP_BONUS); }

  // Encourage C2 and C7 Pawns to move
  if((wPawns & C2bit) && !(wKings & (D1bit | C1bit | B1bit | A1bit))) {
    if(wPawns & (E2bit | E3bit)) {
      wKnightTbl[C3] -= (C2C7_PAWN_BONUS-20);
      wKnightTbl[D2] += (C2C7_PAWN_BONUS-30);
      wPawnTbl[D2]   -= (C2C7_PAWN_BONUS-20);
      wPawnTbl[D3]   -= (C2C7_PAWN_BONUS-20);
      wPawnTbl[C2]   -= (C2C7_PAWN_BONUS-30);
      wPawnTbl[C3]   += (C2C7_PAWN_BONUS-30);
      wPawnTbl[C4]   += (C2C7_PAWN_BONUS); }
    else
    if((wPawns & D4bit) && (bPawns & (D5bit | D6bit | D7bit))) {
      wKnightTbl[C3] -= (C2C7_PAWN_BONUS-20); 
      if(wPawns & (B2bit | B3bit)) {
        wPawnTbl[B3] += (C2C7_PAWN_BONUS-20);
        wPawnTbl[C3] += (C2C7_PAWN_BONUS-30);
        wPawnTbl[C4] += (C2C7_PAWN_BONUS); }
      else {
        wPawnTbl[C2] -= (C2C7_PAWN_BONUS-30);
        wPawnTbl[C3] += (C2C7_PAWN_BONUS); } }
    else
    if((wPawns & E4bit) && (bPawns & (E5bit | C5bit)) &&
       (wPawns & (D2bit | D3bit))) {
      wPawnTbl[C3]   += (C2C7_PAWN_BONUS-10);
      wPawnTbl[D4]   += (C2C7_PAWN_BONUS-20);
      wKnightTbl[C3] -= (C2C7_PAWN_BONUS-20);
      wKnightTbl[D2] += (C2C7_PAWN_BONUS-20); } } 

  if((bPawns & C7bit) && !(bKings & (D8bit | C8bit | B8bit | A8bit))) {
    if(bPawns & (E7bit | E6bit)) {
      bKnightTbl[C6] -= (C2C7_PAWN_BONUS-20);
      bKnightTbl[D7] += (C2C7_PAWN_BONUS-20);
      bPawnTbl[D7]   -= (C2C7_PAWN_BONUS-20);
      bPawnTbl[D6]   -= (C2C7_PAWN_BONUS-20);
      bPawnTbl[C7]   -= (C2C7_PAWN_BONUS-34);
      bPawnTbl[C6]   += (C2C7_PAWN_BONUS-34);
      bPawnTbl[C5]   += (C2C7_PAWN_BONUS); }
    else
    if((bPawns & D5bit) && (wPawns & (D4bit | D3bit | D2bit))) {
      bKnightTbl[C6] -= (C2C7_PAWN_BONUS-20);
      bKnightTbl[D7] += (C2C7_PAWN_BONUS-30);
      if(bPawns & (B7bit | B6bit)) {
        bPawnTbl[B6] += (C2C7_PAWN_BONUS-20);
        bPawnTbl[C6] += (C2C7_PAWN_BONUS-30);
        bPawnTbl[C5] += (C2C7_PAWN_BONUS); }
      else {
        bPawnTbl[C7] -= (C2C7_PAWN_BONUS-30);
        bPawnTbl[C6] += (C2C7_PAWN_BONUS-20); } }
    else
    if((bPawns & E5bit) && (wPawns & (E4bit | C4bit)) &&
       (bPawns & (D7bit | D6bit))) {
      bPawnTbl[C6]   += (C2C7_PAWN_BONUS-20);
      bPawnTbl[D5]   += (C2C7_PAWN_BONUS-20);
      bKnightTbl[C6] -= (C2C7_PAWN_BONUS-20);
      bKnightTbl[D7] += (C2C7_PAWN_BONUS-20); } } 
  
  // Discourage Pawn Moves from row 4 to row 5 releasing tension
  wPawnTbl[C5] = wPawnTbl[C4] - (DISCOURAGE_PAWN_4_5);
  wPawnTbl[D5] = wPawnTbl[D4] - (DISCOURAGE_PAWN_4_5-4);
  wPawnTbl[E5] = wPawnTbl[E4] - (DISCOURAGE_PAWN_4_5-4);
  bPawnTbl[C4] = bPawnTbl[C5] - (DISCOURAGE_PAWN_4_5);
  bPawnTbl[D4] = bPawnTbl[D5] - (DISCOURAGE_PAWN_4_5-4);
  bPawnTbl[E4] = bPawnTbl[E5] - (DISCOURAGE_PAWN_4_5-4);

  // Discourage King Moves into corner when not needed
  wKingTbl[A1] = wKingTbl[B1] - (DISCOURAGE_KING_MOVES);
  wKingTbl[H1] = wKingTbl[G1] - (DISCOURAGE_KING_MOVES);
  bKingTbl[A8] = bKingTbl[B8] - (DISCOURAGE_KING_MOVES);
  bKingTbl[H8] = bKingTbl[G8] - (DISCOURAGE_KING_MOVES);