Linux port of newer versions of TogaII

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Michel
Posts: 2210
Joined: Sun Sep 28, 2008 11:50 pm

Re: Linux port of newer versions of TogaII

Post by Michel » Tue Oct 21, 2008 11:22 am

Can you test the new version at

http://alpha.uhasselt.be/Research/Algeb ... _versions/

The file is called

Code: Select all

Toga14b5c_pthread_cond.tar.gz
Regards,
Michel

PS. I replaced the sem_ functions by my own functions.

Code: Select all

typedef struct {
    int value;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
} my_sem_t;

void my_sem_init(my_sem_t *sem, int value){
    sem->value=value;
    pthread_mutex_init(&(sem->mutex),NULL);
    pthread_cond_init(&(sem->cond),NULL);
}

void my_sem_post(my_sem_t *sem){
    pthread_mutex_lock(&(sem->mutex));
    sem->value++;
    pthread_cond_signal(&(sem->cond));
    pthread_mutex_unlock(&(sem->mutex));
}

void my_sem_wait(my_sem_t *sem){
    pthread_mutex_lock(&(sem->mutex));
    while(sem->value==0){
        pthread_cond_wait(&(sem->cond),&(sem->mutex));
    }
    sem->value--;
    pthread_mutex_unlock(&(sem->mutex));
}

krazyken

Re: Linux port of newer versions of TogaII

Post by krazyken » Tue Oct 21, 2008 11:34 am

That does indeed work.
[Event "Computer Chess Game"]
[Site "Mulert.local"]
[Date "2008.10.21"]
[Round "1"]
[White "Xpdnt 080927"]
[Black "Toga II 1.4 beta5c"]
[Result "0-1"]
[TimeControl "40/60"]

1. Nf3 f5 {+0.01/1 0} 2. Nc3 {+0.32/11 2} Nf6 {-0.25/14 1} 3.
d4 {+0.32/10 0} e6 {-0.23/13 1} 4. Bg5 {+0.33/9 0} Be7 {-0.28/13 1} 5.
e3 {+0.35/9 0} O-O {-0.22/13 2} 6. Bd3 {+0.27/9 1} d5 {-0.20/12 1} 7.
O-O {+0.28/9 1} Ne4 {-0.06/13 2} 8. Bxe7 {+0.27/10 0} Qxe7 {-0.10/12 1} 9.
Bxe4 {+0.24/10 1} fxe4 {+0.08/13 1} 10. Ne5 {+0.22/10 1} Nd7 {+0.19/12 1}
11. Ng4 {+0.22/10 1} b6 {+0.43/13 1} 12. Qd2 {+0.19/9 1} Ba6 {+1.50/13 0}
13. Rfd1 {+0.20/9 1} Rf7 {+1.48/12 1} 14. Qe1 {-0.20/10 1} h5 {+1.50/13 1}
15. Ne5 {-0.43/10 0} Nxe5 {+1.46/13 0} 16. dxe5 {-0.53/9 0}
Raf8 {+1.48/14 1} 17. Rd2 {-0.57/9 0} Qg5 {+1.59/14 1} 18. h3 {-0.57/8 0}
Qxe5 {+1.82/12 1} 19. a4 {-0.66/9 0} Bc4 {+1.92/13 0} 20. Ra3 {-0.72/9 0}
a5 {+2.06/13 1} 21. Qa1 {-0.55/10 0} Ba6 {+1.97/12 1} 22. Rb3 {-0.63/9 1}
Rf6 {+2.02/13 1} 23. Ra3 {-1.03/10 2} Qg5 {+3.09/13 1} 24. h4 {-1.73/10 1}
Qxh4 {+4.06/13 0} 25. Qe1 {-2.43/10 0} Rg6 {+4.21/14 1} 26. Ne2 {-3.01/9 1}
Qg4 {+5.09/14 1} 27. Qf1 {-4.17/9 1} h4 {+7.66/12 0} 28. c4 {-3.65/8 0}
Bxc4 {+9.83/11 1} 29. Ra1 {-5.90/9 1} h3 {+13.88/13 1} 30. g3 {-8.71/8 0}
Rgf6 {+15.44/13 1} 31. f3 {-19.02/6 1} Rxf3 {+17.97/10 1}
{White resigns} 0-1

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

Re: Linux port of newer versions of TogaII

Post by Michel » Tue Oct 21, 2008 11:39 am

That does indeed work.
Fantastic! I will put up new versions then.

I think the Apple people should be shot for providing non working but compiling semaphore functions.

krazyken

Re: Linux port of newer versions of TogaII

Post by krazyken » Tue Oct 21, 2008 11:43 am

Michel wrote:
That does indeed work.
Fantastic! I will put up new versions then.

I think the Apple people should be shot for providing non working but compiling semaphore functions.
Shooting may be kind, Lets put them to work porting all the known chess engines instead.

glorfindel

Re: Linux port of newer versions of TogaII

Post by glorfindel » Thu Nov 20, 2008 11:06 pm

How do you compile toga? There is no makefile in the sources.

krazyken

Re: Linux port of newer versions of TogaII

Post by krazyken » Thu Nov 20, 2008 11:26 pm

There is in the ones I downloaded. You using the link in this thread?

glorfindel

Re: Linux port of newer versions of TogaII

Post by glorfindel » Fri Nov 21, 2008 11:39 am

krazyken wrote:There is in the ones I downloaded. You using the link in this thread?
Now I am! Thank you, I did find it.

bob
Posts: 20923
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: Linux port of newer versions of TogaII

Post by bob » Mon Nov 24, 2008 10:18 pm

glorfindel wrote:
krazyken wrote:There is in the ones I downloaded. You using the link in this thread?
Now I am! Thank you, I did find it.
Or you can use Fruit's. :)

User avatar
Eelco de Groot
Posts: 4279
Joined: Sun Mar 12, 2006 1:40 am
Location: Groningen

Re: Linux port of newer versions of TogaII

Post by Eelco de Groot » Tue Nov 25, 2008 5:04 pm

Michel wrote:Can you test the new version at

http://alpha.uhasselt.be/Research/Algeb ... _versions/

The file is called

Code: Select all

Toga14b5c_pthread_cond.tar.gz
Regards,
Michel

PS. I replaced the sem_ functions by my own functions.

Code: Select all

typedef struct {
    int value;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
} my_sem_t;

void my_sem_init(my_sem_t *sem, int value){
    sem->value=value;
    pthread_mutex_init(&(sem->mutex),NULL);
    pthread_cond_init(&(sem->cond),NULL);
}

void my_sem_post(my_sem_t *sem){
    pthread_mutex_lock(&(sem->mutex));
    sem->value++;
    pthread_cond_signal(&(sem->cond));
    pthread_mutex_unlock(&(sem->mutex));
}

void my_sem_wait(my_sem_t *sem){
    pthread_mutex_lock(&(sem->mutex));
    while(sem->value==0){
        pthread_cond_wait(&(sem->cond),&(sem->mutex));
    }
    sem->value--;
    pthread_mutex_unlock(&(sem->mutex));
}
Michel, something to try, maybe I'm wrong but I think there might be an error in the original 1.4 Beta5c and earlier Fruit and Toga sources. Have not checked earlier versions though.

My reasoning is the following:

The History Research in full_search () is tried when value goes over beta but I think the assumption for 'Late Moves' or History Pruning is that these moves will not increase alpha :idea: . So if the LMR/History reduced search goes over alpha this assumption fails and a re-search is called for.

Actually if the reduced search goes over beta even for a 'Late Move' the/a previous move of the opposing colour is probably bad and a re-search (or a search of an early, better move) would to some likelyhood still be larger than beta, the value in that case is not really that important anymore :) But a re-search still prudent in case the re-searched move falls into the alpha beta window after all.

If you do more than one ply of reductions, by Extended History Pruning or something to that effect probably the re-search should be done in steps not just a single ply extension, I don't see that in the sources at the moment but I have not tried a correction of this yet. >= alpha I just tried and I think it might be an improvement? But very early days :) ! I just thought this looks wrong in the code but on the other hand many people must have studied this part of the Fruit and Toga sources :shock:


Line 783 in search_full.cpp

Code: Select all


      // history-pruning re-search

	  if (HistoryReSearch && reduced && value >= beta) { // [EdG: value >= alpha seems a correct bugfix here?]

         ASSERT(node_type!=NodePV);
         
		 new_depth++;
		 ASSERT(new_depth==depth-1);
		 
         value = -full_search(board,-beta,-alpha,new_depth,height+1,new_pv,NODE_OPP(node_type),cap_extended,ThreadId);
      } 

      move_undo(board,move,undo);



Regards, Eelco
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan

Harald Johnsen

Re: Linux port of newer versions of TogaII

Post by Harald Johnsen » Tue Nov 25, 2008 6:33 pm

EdG: value >= alpha seems a correct bugfix here?
No, the correct code is value > alpha.

Also, testing value > alpha and value >= beta is the same as long as you do not reduce the search in PV nodes (in non PV nodes we have beta == alpha + 1).
Only some versions of Toga are reducing in pv nodes. It is in those reduced pv nodes that there can be a problem.

HJ.

Post Reply