• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
patishi

Hashing connect -4 board (for Transposition table)..need some help :)

82 posts in this topic

This is my New Transposition Table code  (in my own simple way smile.png  )    please give me corrections
 

private final int N = 8306069;
private long[] table;
 
 
 
 
public NewTT(){
       table = new long[N];
}
 
 
 
 
public void initTable(){
      for(int i = 0; i<table.length; i++){
            table[i] = 0L;
     }
}
 
 
 
private int compress(long key){
        return (int)(key % N);
}
 
 
 
public void insert(long key,int value,int valueType){
      int index = compress(key);
      long entry = 0;
      if(value == -1){
             entry = 3 + (valueType << 2) + (key & 9223372036854775792L);     // if the value is  -1  i translate it to 3  ( 11  in binary )
      }
   else{
             entry = value + (valueType << 2) + (key & 9223372036854775792L);
     }
   table[index] = entry;
 
}
 
 
 
public long find(long key){
        int index = compress(key);
        if((key & 9223372036854775792L) == (table[index] & 9223372036854775792L)){
               return table[index];
        }
        else{
              return 0;
       }
 
}
 
 
 
public int getValue(long entry){
       if((entry & 3) == 3){               //  here i again translate the 3 back to -1  
          return -1;
       }
       else{
              return (int)(entry & 3);
       }
}
 
 
 
public int getValueType(long entry){      //   1 = EXACT_VALUE,   2 = LOWERBOUND,   3 = UPPERBOUND
         return (int)((entry >> 2) & 3);
}
 
 
 
 
EDIT:  OH MAN!!  what a major improvement in speed!  still not like john tromp engine, but much much better than what i had before smile.png   
        Alvaro,  now only 3 seconds with the position you showed above!!   OH man i am so happy
Edited by patishi
0

Share this post


Link to post
Share on other sites

Update:  I improved my engine's speed incredibely!  the trick was actually to change the static move ordering (combined with killer moves ofcourse).  now my default columns order is {1,5,4,3,2,0,6}  starting at the root node and changing dynamically with the help of killer moves.  I will try to improve the move ordering by maybe trying (again) to use the hash move.    No matter what variant of the history heuristic i tried to use, the killer moves gives me greatest boost in speed.      

Now my engine analyses the most complex position i encountered so far (took 2-3 minutes in the beginning),  now only in 16-17 seconds!  which is exactly the same time as john tromp engine take to solve the exact position.    smile.png   

Another question i have is:    is it ok if i use only 47 bits in my TT entry  for the hash key?  (the most left ones).    is it enough in order to be unique?   

I just want to mention that when i am saving to the table, i am using the full hash key (zobrist) for the compression process (key % Size of Table)  to find the index in the table,and only when actually saving iam cutting it  to 53 bits only  (cause i also store the depth,score,valueType...)  

 

Edited by patishi
0

Share this post


Link to post
Share on other sites


Another question i have is: is it ok if i use only 47 bits in my TT entry for the hash key? (the most left ones). is it enough in order to be unique?

I just want to mention that when i am saving to the table, i am using the full hash key (zobrist) for the compression process (key % Size of Table) to find the index in the table,and only when actually saving iam cutting it to 53 bits only (cause i also store the depth,score,valueType...)

 

Yes, that's enough. You can probably prove it formally using the Chinese remainder theorem.

 

How many positions per second does your program examine?

0

Share this post


Link to post
Share on other sites

can you advice me how can i measure the nodes per second rate?   i assume that i need to put some sort of a counter somwhere in the alpha beta, but can't figure out where exactly?    (maybe inside the for loop where i go through each possible move? )      right now i am just measuring the start and end time of the calculation so i have the total seconds.    if i have the total number of nodes i can just divide it by the seconds

0

Share this post


Link to post
Share on other sites

The two popular options for counting nodes are:

(1) Count calls to the alpha-beta function

(2) Count calls to make_move

 

I use (1), and so does Fhourstones, so that's the number I am more interested in.

0

Share this post


Link to post
Share on other sites

well, from a rather rough measurment i get something like 4600000+  ...4800000   but it's constantly changing .  and  also, my computer (desktop) processor is rather weak (2.4 GHZ)and the memory is old and slow (DDR2) if that's count for something..  smile.png    Actually on my 2.1 GHZ laptop  with DDR3 memory (1333 )  it is  a little bit faster 

Edited by patishi
0

Share this post


Link to post
Share on other sites

I would like to suggest an alternative and I think more intuitive way to calculate a hash of a connect-four position on a 6-row, 7-column board. The state of each column on the board can be represented as a bijective numeral in base 2. To construct the numeral for a column, read it from the bottom up using 1 and 2 to represent pieces of each player, and stopping when you encounter an empty position.

 

For example, if a column looks like (e means empty):

e

e

e

w

b

w

 

Then the bijective representation could look like: 121 (if 1 means white, 2 means black).

 

You can encode that as a binary number easily. 121 in base 10 would be 1 * 2^0 + 2 * 2^1 + 1 * 2^2 = 9. In binary, the largest value for a column will occupy 7 bits. If you have 7 bits for each of 7 columns that turns out to be 49 bits.

0

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0