Author: Robert Hyatt
Date: 08:30:34 01/01/03
Go up one level in this thread
On January 01, 2003 at 02:08:37, Uri Blass wrote: >On January 01, 2003 at 01:01:24, Robert Hyatt wrote: > >>On December 31, 2002 at 20:32:28, Uri Blass wrote: >> >>>On December 31, 2002 at 19:50:43, Robert Hyatt wrote: >>> >>>>On December 31, 2002 at 17:49:52, Uri Blass wrote: >>>> >>>>>From Ed programmer stuff >>>>> >>>>>Killer-One [current ply] 110 >>>>>Killer-One [current ply-2] 108 >>>>>Killer-Two [current ply] 106 >>>>>Killer-Two [current ply-2] 104 >>>>> >>>>>I until today used only >>>>> >>>>>Killer-One [current ply] >>>>>Killer-Two [current ply] >>>>> >>>>>I am interested to know if using 4 killers is a new idea or maybe this idea is >>>>>known to be used by other programs. >>>> >>>>It was known in 1975. Chess 4.0 used this. You can find it mentioned in >>>>the chess 4.7 chapter of "Chess Skill in Man and Machine." >>>> >>>>We did that in Cray Blitz, but we also did more killers, going back to the >>>>root in fact... >>>> >>>> >>>> >>>>> >>>>>I did try part of the idea that Ed suggested without clear results. >>>>> >>>>>I changed the order of moves in movei to >>>>> >>>>>Killer-One [current ply] >>>>>Killer-One [current ply-2] >>>>>Killer-Two [current ply] >>>>> >>>>>instead of >>>>> >>>>>Killer-One [current ply] >>>>>Killer-Two [current ply] >>>>> >>>>>I found that it is better only in part of the cases and have not clear results >>>>>if it is better or worse than previous order but I had a bug in the >>>>>implementation and I checked killer[ply-2] even in cases when ply-2<0. >>>>> >>>>>It is surprising that the program did not crush and even performed better in >>>>>part of the cases. >>>>> >>>>>I still do not use check bound software. >>>>>I asked in a previous discussion about checking bounds but I solved the >>>>>problem that caused me to ask about it and I also read a claim that if a >>>>>varaible is out of bound the program should crush. >>>>> >>>>>I also looked for a software that will help me under visual C++ but after I >>>>>asked to get it for free evaluation and I only got an email that suggest me to >>>>>contact them by fax or telephone I did not respond(I responded by email but my >>>>>email was blocked for some reason and I decided that the subject is probably not >>>>>very important). >>>>> >>>>>I think now that it may be important because a chess program may even play well >>>>>inspite of the fact that it calls killer[-1] so it is possible that I have more >>>>>mistakes like that. >>>>> >>>> >>>>That probably won't hurt a thing. That move probably would not pass your >>>>legality check, so even a garbage move would just waste a tiny bit of time >>>>as you notice it is not legal in the current position. >>> >>>Yes but I can still imagine problems. >>> >>>1)If I am unlucky a garbage move may be legal so it can be counterproductive. >>> >>>2)I thought that garbage may do something worse than giving a random >>>number. >>>I thought that if my program try to look at some place that does not exist the >>>program may crush and not give me a random number or may change another array. >>> >>>I also cared not to have -1 >>> A[x]=1; and not >>>if (x>=0) >>>A[x]=1; >> >>That doesn't hurt a thing. a[-1] is one "thing" before a[0]. If a is an >>integer, a[-1] is simply 4 bytes in front of a[0]... >> >>> >>>If you are right then it means that there are cases when I can save time by >>>doing something like >>> >>>A[x]=1; instead of >>>if (x>=0) >>>A[x]=1; >> >>You can do that just so you _know_ what is in front of A. IE in fortran, >>arrays go from 1 to N, rather than 0 to N-1 as in C. But in Cray Blitz we >>wanted to reference a[i] where i could be 0, 1, ... and all we did was make >>sure that there was a memory word that could safely be zapped, in front of >>a[1]. We did it like this: >> >>common /x/ dummy, a(10) >> >>a(1) thru a(10) are normal array references. a(0) actually stores on top of >>"dummy". >> >> >> >> >>> >>>The point is that if I understand correctly then I understand from your post >>>that a[x]=1 when x=-1 can not change relevant information. >> >>No, it can _definitely_ change something, just not exactly what you think it >>is changing. :) It will change what is in _front_ of the array. In C, the >>only way to know what is in front of the array is to put the array in a >>structure, and then put something right in front of that array declaration >>to declare the "dummy" space needed for a[-1]. Or a[-2] if you want to go >>backward even farther. >> >> >> >>> >>>If I assume that the condition x>=0 happen in most of the cases then it seems >>>clear that A[x]=1 is faster. >> >>Correct. If you know that -1 <= x <= N, then one dummy word in front of the >>array will let you eliminate the test. > >This was only thinking about a theoretical case but I found other things in my >code. > >In a lot of places in my program >I have a condition like > >while (target!=-1&&info[target]==EMPTY) > >In most cases target!=-1 > >I thought that I need to do the && in this order >Do you say that I can change the order without risks? Yes. I would put the most likely to be false _first_. And I would get rid of the -1 altogether and use one of the tricks pointed out in this thread to make -1 safe as a subscript to get rid of a branch... > >Suppose that the loop stops in most of the cases because of the fact that >info[target]=EMPTY. Good optimization: In the case of && compound conditionals, put the most likely to be false _first_. Put the least likely to be false _last_. > >Does it going to do my program faster or maybe the compiler can detect these >cases in profile optimazions? It should probably catch it in profile-feedback, but even better is to simply eliminate the branch completely by making -1 legal if you want to do that. Or you can simply add 1 to _all_ subscripts so that -1 becomes 0... > >I thought that even checking the value of info[-1] can give an error or change >some varaible that I do not want. You can't change something without an operator to modify the value. IE reading a value will never change it unless you use a ++/-- modifier, for example... -1 will not give an error on most machines. There are a _few_ where it will cause problems but you will probably never run into one of those. > >Uri
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.