Life In 19x19 http://www.lifein19x19.com/ |
|
Looking for an influence function (in javascript) http://www.lifein19x19.com/viewtopic.php?f=18&t=11203 |
Page 1 of 1 |
Author: | oca [ Mon Dec 15, 2014 4:35 am ] |
Post subject: | Looking for an influence function (in javascript) |
Hi all, I'm looking for an "influence" function in javascript. Something I can use like : Code: var influenceArray = buildInfluence(gameArray); So before I build my own, did anybody allready have something to share ? |
Author: | RBerenguel [ Mon Dec 15, 2014 5:16 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
oca wrote: Hi all, I'm looking for an "influence" function in javascript. Something I can use like : Code: var influenceArray = buildInfluence(gameArray); So before I build my own, did anybody allready have something to share ? I don't ![]() And you'll definitely be able to use this: http://gameschoolgems.blogspot.com.es/2 ... aps-i.html to avoid having to think too much while implementing a JS version, too. |
Author: | oca [ Tue Dec 16, 2014 3:56 am ] | ||
Post subject: | Re: Looking for an influence function (in javascript) | ||
So Let's try to build one... May let's start with a simple Zorbist like function... I'm not 100% sure exactly what the algorythm is but I think it's something like this : each black stones get a value of 50 each white stones get a value of -50 each position that is adjacent to a black stone get +1 (per adjacent black stone) each position that is adjacent to a white stone get -1 (per adjacent white stone) repeat that 4 times ... so... for a 5x5 borad with only one black stone in the center : 1) set it's value to 50 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 2) apply the transformation one time 0 0 0 0 0 0 0 1 0 0 0 1 50 1 0 0 0 1 0 0 0 0 0 0 0 two times : 0 0 1 0 0 0 2 2 2 0 1 2 54 2 1 0 2 2 2 0 0 0 1 0 0 three times : 0 2 2 2 0 2 4 6 4 2 2 6 58 6 2 2 4 6 4 2 0 2 2 2 0 for times : 2 4 5 4 2 4 8 10 8 4 5 10 62 10 5 4 8 10 8 4 2 4 5 4 2 so given that method, we have got some influence on the whole board here ... let's try with a black stone and a white stone : Position : . . . . . . . . . . . X . O . . . . . . . . . . . Influence (after 4 iterations): x x . o o x x . o o x X . O o x x . o o x x . o o 4 4 0 -4 -4 7 8 0 -8 -7 8 59 0 -59 -8 7 8 0 -8 -7 4 4 0 -4 -4 One thing that surprise me is that the distance to the border is not taken into consideration... that's weird to me as a stone near the border as not the same influence as a stone in the center is it ? Anyway... I will now try to see what happend with adding an erosion function (Bouzy's method) like discribed here : http://www.delorie.com/gnu/docs/gnugo/gnugo_201.html The code so far is attached to this post. If you want to try, you can open the html file in a browser on see the message in the console (the inf.js file must be in the same repository than the html file). or for whose who have node.js intalled, you can just use it too. Code: >node inf.js
|
Author: | RobertJasiek [ Tue Dec 16, 2014 4:38 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
What is the purpose of the influence function? I can't help feeling that the only purpose is getting its javascript implementation. However, does really any bad function do or are you asking for a meaningful function? |
Author: | oca [ Tue Dec 16, 2014 5:28 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
RobertJasiek wrote: What is the purpose of the influence function? I can't help feeling that the only purpose is getting its javascript implementation. However, does really any bad function do or are you asking for a meaningful function? Hi Robert, Well... by curiousity... as I'm interested in understanding how the influence tools works. And also for study purpose, even if I know that the results is not accurate. I'm a weak player and still have problems in lots of area, including choosing the best area to play in. when I play against the computer, I noticed that using the "territory button" help me in deciding where to play and I win more ofen. I don't use systematicaly that button, which would be a very bad habit I think, I try to separate the games where I play "alone" from the one wher I play "in study mode" with the help of a joseki book, territory analysis tool or "hint" button) I would by far prefer playing more ofen with a real strong player but I don't have that much opportunity to do that, and the computer is still way better than me anyway so wining without handicap stones is still a big challenge for me. |
Author: | RBerenguel [ Tue Dec 16, 2014 5:39 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
oca wrote: RobertJasiek wrote: What is the purpose of the influence function? I can't help feeling that the only purpose is getting its javascript implementation. However, does really any bad function do or are you asking for a meaningful function? Hi Robert, Well... by curiousity... as I'm interested in understanding how the influence tools works. And also for study purpose, even if I know that the results is not accurate. I'm a weak player and still have problems in lots of area, including choosing the best area to play in. when I play against the computer, I noticed that using the "territory button" help me in deciding where to play and I win more ofen. I don't use systematicaly that button, which would be a very bad habit I think, I try to separate the games where I play "alone" from the one wher I play "in study mode" with the help of a joseki book, territory analysis tool or "hint" button) I would by far prefer playing more ofen with a real strong player but I don't have that much opportunity to do that, and the computer is still way better than me anyway so wining without handicap stones is still a big challenge for me. I love writing exploratory code just for the sake of it, but as for games... Are you sure it's that hard to play with a strong opponent online? I mean, I don't play that much online, but roughly 50% of my opponents are "strong" ![]() ![]() Play more with people and less with computers! |
Author: | mimano [ Tue Dec 16, 2014 6:16 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
Yes but you forget about the not-being-able-to-fall-asleep-plus-having-kids-part! OCA,I understand you ![]() |
Author: | RBerenguel [ Tue Dec 16, 2014 6:21 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
mimano wrote: Yes but you forget about the not-being-able-to-fall-asleep-plus-having-kids-part! OCA,I understand you ![]() Yes, I don't have kids, so my free time is more fluid. But I'd rather not play than play computers! |
Author: | RobertJasiek [ Tue Dec 16, 2014 6:55 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
oca, for just understanding how the influence tool works, you do not even need influence but you can use something similar: proximity. You can start with a simple proximity function: +1 for 'adjacent to more black than white stones', 0 for 'not adjacent to any stone' or 'adjacent to equally many black and white stones', -1 for 'adjacent to more white than black stones'. If this is too simple, then measure Manhattan distances. Influence is not proximity, so if you really want influence, you must measure influence. I have defined influence as a 6-tuple per intersection carefully, but for you such a careful influence function is beyond the computational complexity of your program, I suppose. Influence is degrees of connection, life and territory for either player, therefore a 6-tuple. One can treat territory separately, so you can ignore it if you like. The next simplification is consideration of influence at an intersection for only the player having the greater influence degree of a kind there (in your influence function, then positive values favour and denote Black, negative White). This leaves you with two values per intersection. Connection and life can meaningfully produce different values, but nevertheless you can further simplify and combine the degrees for connection and life: take the value AMBIGUOUS if one value favours Black and the other value favours White or if both values are negative for both players, take the non-negative value n to be the minimum of the connection and life degrees. Here you find the definitions of the degrees: http://senseis.xmp.net/?NConnection http://senseis.xmp.net/?NAlive Further simplification: allow only the values 0, 1 or 2+ for n. Yes, determination of the minimal value requires the program to read. However, in return you get a very meaningful influence value! *** Alternative approach: instead of using influence, you can mark the influence stones with significant outside impact (details to be worked out by you), +1 per black influence stone, -1 per white influence stone. Then you can determine a region's influence stone difference from all surrounding influence stones. Influence stone difference is a concept different from and simpler than influence, but maybe it is good enough for your purpose. It is already much more useful than proximity. EDITS |
Author: | oca [ Tue Dec 16, 2014 7:59 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
RBerenguel wrote: Play more with people and less with computers! Sure I agree with that advice, Really, when I have 2 hours available to spent on go, I always choose to go online (IGS for me) and play a real person. but that's not that ofen that I can play someone that accept to give me stones. I'm not that a fan of "long term game"... I like to play a "one shot" intense game. now to the balance coding/playing, well that's a question that comes ofen in my head... "you should play instead of writing code" but I like writing code too... and I like taking a problem form diffrents prespectives, that helps me to memorize things. I play against the computer during my travel time to work which is 20 minutes long. Most of the time, I perfer spending this time doing something else than playing a computer (mainly reading a book, doing a tsumego, or watching a badukmovies video) |
Author: | oca [ Wed Dec 17, 2014 12:30 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
Hi Robert, Thank you very much for that detailed answer ! RobertJasiek wrote: oca, for just understanding how the influence tool works, you do not even need influence but you can use something similar: proximity. You can start with a simple proximity function: +1 for 'adjacent to more black than white stones', 0 for 'not adjacent to any stone' or 'adjacent to equally many black and white stones', -1 for 'adjacent to more white than black stones'. If this is too simple, then measure Manhattan distances. Influence is not proximity, so if you really want influence, you must measure influence. I have defined influence as a 6-tuple per intersection carefully, but for you such a careful influence function is beyond the computational complexity of your program, I suppose. proximity seems to be a good strating point for my exploration as I want to start small and simple. RobertJasiek wrote: Influence is degrees of connection, life and territory for either player, therefore a 6-tuple. One can treat territory separately, so you can ignore it if you like. The next simplification is consideration of influence at an intersection for only the player having the greater influence degree of a kind there (in your influence function, then positive values favour and denote Black, negative White). This leaves you with two values per intersection. Connection and life can meaningfully produce different values, but nevertheless you can further simplify and combine the degrees for connection and life: take the value AMBIGUOUS if one value favours Black and the other value favours White or if both values are negative for both players, take the non-negative value n to be the minimum of the connection and life degrees. Here you find the definitions of the degrees: http://senseis.xmp.net/?NConnection http://senseis.xmp.net/?NAlive Further simplification: allow only the values 0, 1 or 2+ for n. Yes, determination of the minimal value requires the program to read. However, in return you get a very meaningful influence value! *** Alternative approach: instead of using influence, you can mark the influence stones with significant outside impact (details to be worked out by you), +1 per black influence stone, -1 per white influence stone. Then you can determine a region's influence stone difference from all surrounding influence stones. Influence stone difference is a concept different from and simpler than influence, but maybe it is good enough for your purpose. It is already much more useful than proximity. EDITS Thanks again, that's really interseting. lots of stuff to explore... |
Author: | oca [ Wed Dec 17, 2014 4:42 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
Proximity (1 space near including diagonal) : I like that one... we can see black trying to spliting white Zorbist : Useless ? Bouzy 5/21 : hmmm... not that bad to me... Bouzy 4/13 : Funny, nothing here... Edit code used : |
Author: | oca [ Wed Dec 17, 2014 6:52 am ] |
Post subject: | Re: Looking for an influence function (in javascript) |
oups.. did a small bug... bouzy is more like that : Code: Bouzy (5 dilations then 21 erosions)
o o o o o o o . . o o o o o o o o . o o o O . . . . . o o . . . . . . . . . . . X . . . . . . . . . . . . . . . . X O o o o o . . . . . o o o o . . . . . o o o . Bouzy (4 dilations then 13 erosions) . o o o o o . . . o o o o o o o . . o o o O . . . . . o o . . . . . . . . . . . X . . . . . . . . . . . . . . . . X O o o o o . . . . . o o o . . . . . . o o . . |
Page 1 of 1 | All times are UTC - 8 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |