Re: [computer-go] Random weighted patterns

2009-07-20 Thread Isaac Deutsch
Thanks to both for the elaborate feedback! I was wondering about pattern symmetry, too, and I also had a lookup table in mind since there are only about 65000 combinations (and only a fraction of them legal). I had another idea for the zero weight problem: Keep a counter of how many times

Re: [computer-go] Random weighted patterns

2009-07-20 Thread Gunnar Farnebäck
Isaac Deutsch wrote: > I'm about to implement this. Since I have multiple features > (patterns, is in atari, is adjacent to last play, etc.), the weight > is the product of the weight of all matching features. > > I'm thinking about having a table of weights, storing the sum of > each row and the

Re: [computer-go] Random weighted patterns

2009-07-20 Thread Juho Pennanen
Isaac Deutsch kirjoitti: In my example, #=border/edge of the board, not black. I was just trying to come up with an example feature that might have weight zero to illustrate my problem. I see. I was already thinking there may be no 3x3 patterns that should never be played. But I cannot think

Re: [computer-go] Random weighted patterns

2009-07-20 Thread Isaac Deutsch
In my example, #=border/edge of the board, not black. I was just trying to come up with an example feature that might have weight zero to illustrate my problem. ___ computer-go mailing list computer-go@computer-go.org http://www.computer-go.org/mailm

Re: [computer-go] Random weighted patterns

2009-07-20 Thread Juho Pennanen
Isaac Deutsch kirjoitti: My question/problem: How do I deal with features that have a weight of zero? I'm sure there are certain 3x3 patterns that have the weight zero, such as ### #*. #.. with * to be played. It's clear that when this pattern matches, the total weight is set to zero. Hmm

Re: [computer-go] Random weighted patterns

2009-07-20 Thread Isaac Deutsch
I'm about to implement this. Since I have multiple features (patterns, is in atari, is adjacent to last play, etc.), the weight is the product of the weight of all matching features. I'm thinking about having a table of weights, storing the sum of each row and the total (like Rémi suggested

Re: [computer-go] Random weighted patterns

2009-07-16 Thread Peter Drake
On Jul 15, 2009, at 11:19 PM, Steve Kroon wrote: This code should work with "r -= weights[i++]" in the loop body, and comes down to a linear search through You're right -- I forgot to increment i. 2009/7/16 Peter Drake I must be missing something. Isn't the obvious trick: int r = rand

Re: [computer-go] Random weighted patterns

2009-07-16 Thread George Dahl
Thanks! I had never seen the alias method before and it is quite ingenious! - George On Thu, Jul 16, 2009 at 3:04 AM, Martin Mueller wrote: > If you want to take many samples from a fixed, or infrequently changing, > distribution, you can do it in O(1) time per sample, with O(n) initial setup > co

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Steve Kroon
This code should work with "r -= weights[i++]" in the loop body, and comes down to a linear search through cumulative sum of the weights. If the weights will be static for a number of selections, you can store the cumulative weights in an array and use binary search for selecting the move. So

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Don Dailey
On Wed, Jul 15, 2009 at 11:37 PM, David Fotland wrote: > So many complex ideas :) Why not just multiply the weight of each pattern > by a random number and pick the biggest result? This is fine if you are looking for the slowest algorithm you can find. But it does have the merit of being straig

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Don Dailey
In the loop i is always zero. I think your code is wrong. You probably meant to loop over all the weights (or I should say on average half the weights), and this code is slow if there are a lot of weights. 2009/7/16 Peter Drake > I must be missing something. Isn't the obvious trick: > int r

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Peter Drake
I must be missing something. Isn't the obvious trick: int r = random(); int i = 0; while (r > weights[i]) { r -= weights[i]; } return i; This way, you only have to generate one random number. Peter Drake http://www.lclark.edu/~drake/ On Jul 15, 2009, at 8:55 PM, Zach Wegner wrote: O

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Zach Wegner
On Wed, Jul 15, 2009 at 10:37 PM, David Fotland wrote: > So many complex ideas :) Why not just multiply the weight of each pattern > by a random number and pick the biggest result? > > David That involves generating N random numbers and then doing N-1 comparisons. The n-ary tree has only 1 random

RE: [computer-go] Random weighted patterns

2009-07-15 Thread David Fotland
o-boun...@computer-go.org [mailto:computer-go- > boun...@computer-go.org] On Behalf Of Darren Cook > Sent: Wednesday, July 15, 2009 8:47 PM > To: computer-go > Subject: Re: [computer-go] Random weighted patterns > > > So many complex ideas :) Why not just multiply the weight of eac

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Darren Cook
> So many complex ideas :) Why not just multiply the weight of each pattern > by a random number and pick the biggest result? Good for 5 patterns, not so good for 5000 patterns. Darren ___ computer-go mailing list computer-go@computer-go.org http://ww

RE: [computer-go] Random weighted patterns

2009-07-15 Thread David Fotland
So many complex ideas :) Why not just multiply the weight of each pattern by a random number and pick the biggest result? David > -Original Message- > From: computer-go-boun...@computer-go.org [mailto:computer-go- > boun...@computer-go.org] On Behalf Of Mark Boon > Sent: Wednesday, July

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Don Dailey
I think you could do this with a binary tree - at each node keep a total of the weight values of the subtree below the node. If the pattern was hashed, then each bit could define a branch of the tree, 0 = left branch 1 = right branch. Then you have a very simple divide and conquer algorithm. Th

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Michael Williams
If your weights are all between 0 and 1: do double r = rand(0 to 1) int i = rand(0 to weightCount - 1) until weight[i] > r I think that's right. Mark Boon wrote: When using patterns during the playout I had improvised some code to select patterns randomly, but favour those with higher w

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Peter Drake
You might look in the genetic algorithm literature, where they have to do this for fitness-proportional reproduction. A useful buzzword is "roulette wheel". Peter Drake http://www.lclark.edu/~drake/ On Jul 15, 2009, at 4:06 PM, Mark Boon wrote: When using patterns during the playout I ha

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Darren Cook
> When using patterns during the playout I had improvised some code to > select patterns randomly, but favour those with higher weights more or > less proportionally to the weight.. How many patterns, and are the weights constant for the whole game? If relatively few, and constant, you can make a

Re: [computer-go] Random weighted patterns

2009-07-15 Thread Jason House
On this list I've heard of row sums. You scan by row subtracting weights and then scan by column adding weight... Each time looking for zero crossings. Sent from my iPhone On Jul 15, 2009, at 7:06 PM, Mark Boon wrote: When using patterns during the playout I had improvised some code to se