ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Possible Search Algorithms for GPUs?
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
Daniel Shawul



Joined: 14 Mar 2006
Posts: 2186
Location: Ethiopia

PostPost subject: Re: Possible Search Algorithms for GPUs?    Posted: Sat Jan 07, 2012 2:29 pm Reply to topic Reply with quote

Hello Srdja
I was working on a Hex game using CUDA some time ago. I dud the monte-carlo simulations on gpu and that is it. The game winning condition is to make a line (horizontal/vertical) which I implemented using some bitboard trick I got from here. Anyway since you are looking for inspiration, I though I will cheap in. Here is the source code
Code:

__device__
int BOARD::playout(int N) {
   __shared__ U64 wpawns_;
   __shared__ U64 bpawns_;
   __shared__ U64 all_;
   __shared__ char player_;
   __shared__ char emptyc_;

   wpawns_ = wpawns;
   bpawns_ = bpawns;
   all_ = all;
   player_ = player;
   emptyc_ = emptyc;

   int wins = 0;
   for(int i = 0;i < N;i++) {
      wpawns = wpawns_;
      bpawns = bpawns_;
      all = all_;
      player = player_;
      emptyc = emptyc_;

      while(emptyc) {
         randn *= 1103515245;
         randn += 12345;

         U32 rbit = randn % emptyc;
         U64 mbit = all;
         for(U32 i = 0;i < rbit;i++)
            mbit &= mbit - 1;
         mbit = mbit & -mbit;

         if(player == 0)
            wpawns ^= mbit;
         else
            bpawns ^= mbit;
         all ^= mbit;
         player ^= 1;
         emptyc--;
      }

      U64 m = (wpawns & UINT64(0x00000000000000ff)),oldm;
      do {
         oldm = m;
         m |=((((m << 8) | (m >> 8)) |
             (((m << 9) | (m << 1)) & UINT64(0xfefefefefefefefe)) |
             (((m >> 9) | (m >> 1)) & UINT64(0x7f7f7f7f7f7f7f7f)))
             & wpawns
            );
         if(m & UINT64(0xff00000000000000)) {
            wins++;
            break;
         }
      } while(m != oldm);

   }
   return wins;
}

You can download the full source code here

regards,
Daniel
_________________
https://sites.google.com/site/dshawul/
https://github.com/dshawul
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Subject Author Date/Time
Possible Search Algorithms for GPUs? Srdja Matovic Sat Jan 07, 2012 1:49 pm
      Re: Possible Search Algorithms for GPUs? Daniel Shawul Sat Jan 07, 2012 2:29 pm
            Re: Possible Search Algorithms for GPUs? Srdja Matovic Sat Jan 07, 2012 2:56 pm
            Good Work Les Sun Jan 08, 2012 10:34 pm
            Re: Possible Search Algorithms for GPUs? Daniel Shawul Mon Feb 13, 2012 4:00 pm
      Re: Possible Search Algorithms for GPUs? Dan Andersson Sat Jan 07, 2012 3:36 pm
            Re: Possible Search Algorithms for GPUs? Srdja Matovic Sat Jan 07, 2012 3:54 pm
                  Re: Possible Search Algorithms for GPUs? Dan Andersson Sat Jan 07, 2012 4:28 pm
                        Re: Possible Search Algorithms for GPUs? Srdja Matovic Sat Jan 07, 2012 5:01 pm
                  Re: Possible Search Algorithms for GPUs? Srdja Matovic Fri Feb 10, 2012 12:56 pm
                        Re: Possible Search Algorithms for GPUs? Srdja Matovic Wed Feb 29, 2012 3:50 pm
      Re: Possible Search Algorithms for GPUs? Paul Gift Fri Feb 10, 2012 1:09 pm
            Re: Possible Search Algorithms for GPUs? Srdja Matovic Fri Feb 10, 2012 1:33 pm
            Re: Possible Search Algorithms for GPUs? Marcel van Kervinck Sun Feb 12, 2012 10:49 am
                  Re: Possible Search Algorithms for GPUs? Cuda - MSCP Srdja Matovic Tue Feb 14, 2012 11:52 am
      Re: Possible Search Algorithms for GPUs? APHID Srdja Matovic Sun Feb 12, 2012 9:29 pm
            Re: Possible Search Algorithms for GPUs? APHID Daniel Shawul Sun Feb 12, 2012 10:00 pm
            Re: Possible Search Algorithms for GPUs? APHID Dan Andersson Mon Feb 13, 2012 6:14 pm
                  Re: Possible Search Algorithms for GPUs? APHID Srdja Matovic Mon Feb 13, 2012 9:24 pm
                        Re: Possible Search Algorithms for GPUs? APHID Dan Andersson Tue Feb 14, 2012 10:29 am
                              Re: Possible Search Algorithms for GPUs? new gpus Srdja Matovic Tue Feb 14, 2012 12:40 pm
                                    Re: Possible Search Algorithms for GPUs? new gpus Srdja Matovic Mon Feb 20, 2012 6:25 pm
            Re: Possible Search Algorithms for GPUs? APHID Robert Hyatt Thu Feb 16, 2012 12:08 am
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads