It is currently Mon May 05, 2025 3:18 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 16 posts ] 
Author Message
Offline
 Post subject: Random "Pippen Fuseki" Generator
Post #1 Posted: Sun Dec 08, 2013 12:36 am 
Lives in sente
User avatar

Posts: 773
Location: Michigan, USA
Liked others: 143
Was liked: 218
Rank: KGS 1 kyu
Universal go server handle: moyoaji
So in the opening move preferences thread Pippen posted this idea.

Pippen wrote:
Here's another one, I call it "Pippen-Fuseki":

1. Mark every intersection on the 3rd and 4th line with a number (=104 numbers).
2. Get a random generator.
3. Play the first move in the corner on x-x (my choice: 4-4).
4. Then let the random generator decide the next moves under the following conditions:
a) If a numver comes up that is already occupied by a stone then let a new number be created.
b) If a number comes up that is (vertically or horizonally) as near as y (my choice: 1) intersections on one of your own stones then let a new number be created.
c) Stop this algorithm after your move y (my choice: 7) or if you have to create a 5th number on a move.
5. Continue the game according to what was dealt to you.

I would tend to believe that the success-rate of a Fuseki like that is as good as any Fuseki as long as we do talk about players weaker than 1p. Obviously one can go into detail of the algorithm even more to make the fuski more fitting. The benefit of a fuseki like that could be that you are unpredictable and to shock your opponent while you forcing yourself to let your creative juices flow instead of staying in some patterns/affections.


That sounded like fun. So I took the time to run with it and slapped together a Java program that actually does this!

It's buggy and easy to break, but hey, it pretty much works! Just don't try to break it and you can enjoy playing games the random way! As an executable JAR file you should be able to run it on any computer or device that has Java (if you can run the KGS client then you can probably run this).

I put it up on SourceForge if you want to give it a whirl: https://sourceforge.net/projects/randomfuseki/

If people like this and want me to try to work out the bugs/polish this up, I will. Otherwise you guys can just enjoy messing around with my crappy program. Or you can modify it yourself if you want. The source is in a zip in the src folder because I decided to make it nice and FLOSSy!

Here are some screenshots:
Attachment:
File comment: The Pippen Fuseki Generator!
FirstWindow.png
FirstWindow.png [ 28.08 KiB | Viewed 9132 times ]

Attachment:
File comment: The game in progress!
GameWindow.png
GameWindow.png [ 29.32 KiB | Viewed 9132 times ]


And Pippen, if you want I can remove your username from the program. That was the working title, but I sort of liked it. Plus it was your idea. :salute:

_________________
"You have to walk before you can run. Black 1 was a walking move.
I blushed inwardly to recall the ignorant thoughts that had gone through
my mind before, when I had not realized the true worth of Black 1."

-Kageyama Toshiro on proper moves


This post by moyoaji was liked by 4 people: Bonobo, daal, macelee, oca
Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #2 Posted: Sun Dec 08, 2013 4:43 am 
Gosei
User avatar

Posts: 1585
Location: Barcelona, Spain (GMT+1)
Liked others: 577
Was liked: 298
Rank: KGS 5k
KGS: RBerenguel
Tygem: rberenguel
Wbaduk: JohnKeats
Kaya handle: RBerenguel
Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
I wrote a small javascript snippet to do something similar: I just restrict the first line and obviously playing on a previous move. If there's an enemy stone in place skip the move. I have not tried it yet with a human (I beat CrazyStone for iPad1, don't remember the level.) I want to try it, though, but I feel it will be insulting to my opponent, specially since it is unexpected

_________________
Geek of all trades, master of none: the motto for my blog mostlymaths.net

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #3 Posted: Sun Dec 08, 2013 7:29 am 
Gosei
User avatar

Posts: 1758
Liked others: 378
Was liked: 375
Rank: 4d
I think this fuseki has a rather large weakness if your opponent knows you're playing it, as they can just play contact moves against your stones which you'll be unable to respond to. It'd also be bad if the RNG gives you two stones close together and your opponent plays a move that threatens to cut them, but you can't connect because you have to play elsewhere.

I don't agree that this fuseki will have a good winrate all the way up to 1p, at least in non-blitz games, but I do think it's an interesting idea. If you allow yourself to respond to contact moves and peeps it loses the main weakness I wrote about. Though you may find it more fun to let the randomness screw you and then try to fight back afterward.

_________________
We don't know who we are; we don't know where we are.
Each of us woke up one moment and here we were in the darkness.
We're nameless things with no memory; no knowledge of what went before,
No understanding of what is now, no knowledge of what will be.

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #4 Posted: Sun Dec 08, 2013 8:56 am 
Lives in gote

Posts: 677
Liked others: 6
Was liked: 31
KGS: 2d
Dusk Eagle wrote:
I think this fuseki has a rather large weakness if your opponent knows you're playing it, as they can just play contact moves against your stones which you'll be unable to respond to.


You gotta realize that we talk just about the moves 2-7. There is no way someone can actually make your fuseki real bad, because you could always treat stones as light and aji-makers.

The point of the fuseki is that it is more or less plausible that almost any moves not too tight together and on the 3rd and/or 4th line are playable in fuseki. The further point is to break personal patterns. E.g. I am a guy that usually falls in love with certain patterns and tends to overestimate them. With the Pippen-Fuseki you are forced to play with patterns you'd never have played voluntarily and you might benefit from that - be it that you realize what else is possible to play, be it to be forced to play creatively instead of repeating your database-fuseki/joseki-knowledge. Also I would not underestimate the shock-potential. Imagine you play an important tournament game and you know you are the better "fighter", then be playing randomly you'll be a headscratcher for your opponent and you might bring him to think longer or to lose his style. I know some guys that like to play japanese-like - clear, simple and aestethic. I'd drive them crazy to have to play against a Fuseki like that^^.

One thing I learned through my 10 year Go-journey is that basically there is anything playable in early fuseki...look at Robert Jasiek and his playing style with black. What really differs the weak from the strong is how they do in middle fuseki and middlegame...in the first 10 moves you are hardly worse than Lee Sedol, it's the next 10-20 moves that begins to seperate you from him^^.

Basically my "Pippen-Fuseki" is just a prototype idea: What if you play your first moves semi-randomly, i.e. randomly with some conditions? Is it really worse longterm for your Go or would you benefit? I think programmers could sophisticate it quite more. How to imply not only moves on 3rd and 4th line, but also 5th line? How about to play the first 20 moves randomly for a computer program that will not need and have any strategical, but only tactical knowledge.

Maybe one day I'll play like 500 games with this style and see where it brings me...maybe someone else will...maybe someone will implement this idea into a bot (if it's not already)...maybe some new josekis will be found...maybe it's just another dead-end-idea^^.

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #5 Posted: Sun Dec 08, 2013 9:36 am 
Gosei
User avatar

Posts: 1585
Location: Barcelona, Spain (GMT+1)
Liked others: 577
Was liked: 298
Rank: KGS 5k
KGS: RBerenguel
Tygem: rberenguel
Wbaduk: JohnKeats
Kaya handle: RBerenguel
Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
When I got the idea (it was 4 months ago or something like this... I'm not exactly sure but the source is in my old computer, and the new one is 4 months old, so..) my idea was to play at random ~25 moves to improve my middle game fighting. The plan was to just throw stones and then fight for the useful, use the rest as aji stones and somewhat find what my "middle game only" level is like (is it far from normal fuseki game? How many stones? And what happens is I do it only for 10 moves? etc)

_________________
Geek of all trades, master of none: the motto for my blog mostlymaths.net

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #6 Posted: Sun Dec 08, 2013 10:43 am 
Lives in gote

Posts: 677
Liked others: 6
Was liked: 31
KGS: 2d
I also wanted to thank moyoaji for his effort. I'd be really curious how a program like crazystone would do with my setting against its original and if there would be significant difference. I think I will also check the sourcecode to learn more about java...I always wanted to be able to program...is there any catchy course at youtube that one can recommend? It's not so much the language but the tools I'd love to have.

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #7 Posted: Sun Dec 08, 2013 10:57 am 
Oza

Posts: 2356
Location: Ireland
Liked others: 662
Was liked: 442
Universal go server handle: Boidhre
Pippen wrote:
I also wanted to thank moyoaji for his effort. I'd be really curious how a program like crazystone would do with my setting against its original and if there would be significant difference. I think I will also check the sourcecode to learn more about java...I always wanted to be able to program...is there any catchy course at youtube that one can recommend? It's not so much the language but the tools I'd love to have.


If you like, poke me on KGS some evening. I can run CrazyStone 2012 on my machine and relay the moves on the board. (I don't know a way to make the program autoplay itself, though is probably possible with Fuego?)

Actually, my idea doesn't work at all unless you've the same processor, memory etc.

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #8 Posted: Sat Feb 28, 2015 6:24 pm 
Lives in sente
User avatar

Posts: 773
Location: Michigan, USA
Liked others: 143
Was liked: 218
Rank: KGS 1 kyu
Universal go server handle: moyoaji
I know it's been a while, but I wanted to let people know that, after over a year, I finally took the time to update this program. It was in pretty bad shape performance-wise (it would update the entire graphics of the board every time the mouse moved around) and had some glaring bugs (like playing illegal moves). It still is far from perfect, but I felt like it deserves at least a bit of an upgrade. Or a huge upgrade in this case. I would estimate its about 90% more resource efficient. That's more to do with how badly I wrote it before, but, to be fair, I wrote this generator in a day. And again, just don't try to break it and it should do fine. ;-) (It's still at the same place on https://sourceforge.net/projects/randomfuseki/).

Why fix it now after all this time? Because I updated the graphics engine for a different program that I'm writing and decided to integrate those improvements into this. I'm pretty happy about this new program and will be posting about it as soon as I've finished preliminary testing. As with this fuseki generator, it will be open source, involve some randomness, and, of course, made for people who love go. :tmbup:

_________________
"You have to walk before you can run. Black 1 was a walking move.
I blushed inwardly to recall the ignorant thoughts that had gone through
my mind before, when I had not realized the true worth of Black 1."

-Kageyama Toshiro on proper moves


This post by moyoaji was liked by: Bonobo
Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #9 Posted: Sun Mar 01, 2015 7:56 am 
Lives in gote

Posts: 677
Liked others: 6
Was liked: 31
KGS: 2d
Cool stuff. I still think such an random opening-style will not harm you. Would be cool to implement it on a strong engine for the first 5-10 moves to see if such an opening can hold with its standard colleagues.

p.s. I don't know if its an error, but your program plays random first two moves even if I set it 4-4 for both colours to begin with.

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #10 Posted: Sun Mar 01, 2015 8:28 am 
Lives in sente
User avatar

Posts: 773
Location: Michigan, USA
Liked others: 143
Was liked: 218
Rank: KGS 1 kyu
Universal go server handle: moyoaji
Pippen wrote:
Cool stuff. I still think such an random opening-style will not harm you. Would be cool to implement it on a strong engine for the first 5-10 moves to see if such an opening can hold with its standard colleagues.

p.s. I don't know if its an error, but your program plays random first two moves even if I set it 4-4 for both colours to begin with.

I'm trying to reproduce the bug, but the setting of the first moves is working for me. Are you putting in "4-4" for both players? The way the program parses that would put both moves on the upper left star point. I suppose I should fix that so it doesn't allow white to play its move on top of black's stone, but it does play 4-4 for white as expected.

_________________
"You have to walk before you can run. Black 1 was a walking move.
I blushed inwardly to recall the ignorant thoughts that had gone through
my mind before, when I had not realized the true worth of Black 1."

-Kageyama Toshiro on proper moves

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #11 Posted: Sun Mar 01, 2015 9:05 am 
Lives in gote

Posts: 677
Liked others: 6
Was liked: 31
KGS: 2d
Here are two actual games, I played black in both cases and had good games going in my opinion. It looks promising, even if I messed up in the first one.





@moyoaji: How about being able to actually put in the coordinates, so that one can fix the first two moves? How about having the option to add a 5th line? (This is basically for me as a reminder) I might really begin to torture KGS with that fuseki^^. It might be more effective than my split fuseki and might change go like V-Style changed ski-jumping :).


This post by Pippen was liked by: moyoaji
Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #12 Posted: Sun Mar 01, 2015 9:13 am 
Lives in sente
User avatar

Posts: 773
Location: Michigan, USA
Liked others: 143
Was liked: 218
Rank: KGS 1 kyu
Universal go server handle: moyoaji
Wow. I can't imagine what your opponents were thinking with those opening moves. I wonder if either of them thought: "Am I playing a random number generator?" More likely, though, they probably thought you were drunk. :lol:

Pippen wrote:
@moyoaji: How about being able to actually put in the coordinates, so that one can fix the first two moves? I might really begin to torture KGS with that fuseki^^.

You mean being able to declare multiple initial moves for each player? Like black played 16-4, 16-16 (nirensei) and white played 4-4, 4-17 (hoshi and komoku) now begin to make random moves for black?

_________________
"You have to walk before you can run. Black 1 was a walking move.
I blushed inwardly to recall the ignorant thoughts that had gone through
my mind before, when I had not realized the true worth of Black 1."

-Kageyama Toshiro on proper moves

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #13 Posted: Sun Mar 01, 2015 11:54 am 
Lives in gote

Posts: 677
Liked others: 6
Was liked: 31
KGS: 2d
@moyoaji: Let's take the interface of your actual program to explain my ideas:

1. First line you could put in black's move, e.g. d4, or leave it blank to let the program choose a random move for black.
2. Second line you could put in white's move, e.g. q4, or leave it blank to let the programm choose a random move for white.
2a) In an extra line you can choose which color you want to go random from there. You can choose Black and White and e.g. after 1. & 2. both Black and White get random moves or just Black so that just Black gets random moves while one inputs the actual White moves to which Black reacts randomly.
3. Third and Fourth line are the same as now.
4. In a fifth line you could choose the line parameter from 3 to 5 (maybe even 6 or 7), meaning: if you put in e.g. 4 then the program will just consider 3 and 4th lines moves, if 5 then it consider 3,4 and 5th line.

With such a program I could play on KGS, because the first move(s) I could put in precisely and then choose the randomness for one color.

@all: What do you think of the games, I think my random-fuseki worked OK, I didn't blunder the fuseki, did I?

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #14 Posted: Mon Mar 02, 2015 3:02 pm 
Lives in sente
User avatar

Posts: 773
Location: Michigan, USA
Liked others: 143
Was liked: 218
Rank: KGS 1 kyu
Universal go server handle: moyoaji
Pippen wrote:
@moyoaji: Let's take the interface of your actual program to explain my ideas:

1. First line you could put in black's move, e.g. d4, or leave it blank to let the program choose a random move for black.
2. Second line you could put in white's move, e.g. q4, or leave it blank to let the programm choose a random move for white.
2a) In an extra line you can choose which color you want to go random from there. You can choose Black and White and e.g. after 1. & 2. both Black and White get random moves or just Black so that just Black gets random moves while one inputs the actual White moves to which Black reacts randomly.
3. Third and Fourth line are the same as now.
4. In a fifth line you could choose the line parameter from 3 to 5 (maybe even 6 or 7), meaning: if you put in e.g. 4 then the program will just consider 3 and 4th lines moves, if 5 then it consider 3,4 and 5th line.

With such a program I could play on KGS, because the first move(s) I could put in precisely and then choose the randomness for one color.

So you wish it, so shall it be... ;-)

https://sourceforge.net/projects/randomfuseki/

_________________
"You have to walk before you can run. Black 1 was a walking move.
I blushed inwardly to recall the ignorant thoughts that had gone through
my mind before, when I had not realized the true worth of Black 1."

-Kageyama Toshiro on proper moves

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #15 Posted: Mon Mar 02, 2015 5:53 pm 
Lives in gote

Posts: 677
Liked others: 6
Was liked: 31
KGS: 2d
Hopefully your little tool makes my breakthrough to a new level (maybe I'll get some easy resigns because people feel bothered^^). Also I'd be interested in the code since I think it's not too difficult so I could learn a little bit (but only if its convenient with you). Did you also have pseudo-code before programming or did you write the whole thing out of the cold hand? In any way: Big thank you. You invested time to write a code, just to help someone and make him happier. That's special, thx bro.

Top
 Profile  
 
Offline
 Post subject: Re: Random "Pippen Fuseki" Generator
Post #16 Posted: Mon Mar 02, 2015 6:48 pm 
Lives in sente
User avatar

Posts: 773
Location: Michigan, USA
Liked others: 143
Was liked: 218
Rank: KGS 1 kyu
Universal go server handle: moyoaji
Pippen wrote:
Hopefully your little tool makes my breakthrough to a new level (maybe I'll get some easy resigns because people feel bothered^^). Also I'd be interested in the code since I think it's not too difficult so I could learn a little bit (but only if its convenient with you). Did you also have pseudo-code before programming or did you write the whole thing out of the cold hand? In any way: Big thank you. You invested time to write a code, just to help someone and make him happier. That's special, thx bro.

You're welcome Pippen.

I wrote this fairly quickly, so I didn't write out pseudo-code or plan out a structure beforehand. I had already written the logic for a go board once before; I think every go playing programmer does that at some point. ;-) Actually, the documentation of the class for actually generating the moves is just your description from that fuseki thread over a year ago. The rest was making a go board, which I had partially done before.

The program is very much object-oriented. In general terms, here's how it works:

The application begins and brings up the first window. When the user hits Star Game, the program reads and interprets the information they entered. Using that, it brings up the second window and begins the game. If the user wants black to play a random move, then it generates one and plays it on the board. The graphical go board is by far the most complex part of the program. However, once I taught the program how to interpret user input from the board, it just comes down to the move generator class.

I commented the class fairly well (which I thank myself for because it made coming back to it after a year a lot easier) so I'll put the code here. If you want to see how it works, you can take a look. The main method for move generation is "public Point getNextMove()" so I'll put that in first and, if you want to take a look at the rest, I'll include it too.

Code:
/**
* Gets the next move as a new point and adds the new move to the move list
*
* @return the next move
*/
public Point getNextMove() {
   Point move = NO_MOVE;
   boolean tooClose = true;
   long tries = 0L;
   long tooMany = 31415926L; // You got a better number in mind?

   // While the move is too close for comfort, keep getting a new one until
   // we've tried too many times. Then there probably isn't a legal move...
   while (tooClose && tries < tooMany) {
      tries++;
      tooClose = false;

      // Determines where on the line the move is (between lines 3 and 17)
      int coor1 = rand.nextInt(15) + 3;
      int coor2 = rand.nextInt(15) + 3;

      // Make sure the move isn't too high or low on the board
      if (coor1 > maxHeight && coor2 > maxHeight
            && coor1 < 19 - maxHeight + 1 && coor2 < 19 - maxHeight + 1) {
         tooClose = true; // Mark it as too close because that's effectively the same
      }

      // Mark the move as a point on the board
      move = new Point(coor1, coor2);

      // Check if the move is too close to one of our own stones
      for (int x = 0; x < moves.size() && !tooClose; x++) {
         if ((Math.abs((moves.get(x).x - move.x))) <= ownDistance
               && (Math.abs((moves.get(x).y - move.y))) <= ownDistance) {
            tooClose = true;
         }
      }

      // Check if the move is too close to an opponent's stone
      for (int y = 0; y < enemyMoves.size() && !tooClose; y++) {
         if ((Math.abs(enemyMoves.get(y).x - move.x)) <= enemyDistance
               && (Math.abs(enemyMoves.get(y).y - move.y)) <= enemyDistance) {
            tooClose = true;
         }
      }
   }

   // If we tried too many times, return a non-move instead.
   if (tries >= tooMany) {
      System.out.println("You're playing too many moves!");
      return NO_MOVE;
   }

   // If we made it this far, play the move and return the point
   moves.add(move);
   return new Point(move.x, move.y);
}

Here's the full code for that class:
Code:
package com.lifein19x19.pippenFuseki.engine;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Random;

/**
* Generates a "Pippen Fuseki" based on these parameters
*
* 1. Mark every intersection on the 3rd and 4th line with a number (=104
* numbers).
*
* 2. Get a random generator.
*
* 3. Play the first move in the corner on x-x (my choice: 4-4).
*
* 4. Then let the random generator decide the next moves under the following
* conditions:
*
* a) If a numver comes up that is already occupied by a stone then let a new
* number be created.
*
* b) If a number comes up that is (vertically or horizonally) as near as y (my
* choice: 1) intersections on one of your own stones then let a new number be
* created.
*
* c) Stop this algorithm after your move y (my choice: 7) or if you have to
* create a 5th number on a move.
*
* 5. Continue the game according to what was dealt to you.
*
* @author moyoaji
*/
public class Generator {

   /** Signifies a non-move */
   public static final Point NO_MOVE = new Point(-1, -1);

   /** The minimum distance between two of your own moves */
   private int ownDistance;

   /**
    * The minimum distance between one of your moves and one of your opponent's
    * moves
    */
   private int enemyDistance;

   /** The RNG */
   private Random rand = new Random();

   /** The list of moves */
   private ArrayList<Point> moves;

   /** The list of opponent's moves */
   private ArrayList<Point> enemyMoves;

   /** The highest point on the board that a random move can be */
   private int maxHeight;

   /**
    * Creates a generator based on parameters
    *
    * @param firstMove black's first move
    * @param secondMove white's first move
    * @param ownDistance how far apart you want moves to be from your own
    *            stones
    * @param enemyDistance how far you want moves to be from opponent's stones
    */
   public Generator(Point firstMove, Point secondMove, int ownDistance,
         int enemyDistance, int maxHeight) {
      moves = new ArrayList<Point>();
      enemyMoves = new ArrayList<Point>();

      this.ownDistance = ownDistance;
      this.enemyDistance = enemyDistance;
      this.maxHeight = maxHeight;

      // Add the first and second moves if they were given, otherwise don't
      if (!firstMove.equals(NO_MOVE)) {
         moves.add(firstMove);
      }
      if (!secondMove.equals(NO_MOVE)) {
         enemyMoves.add(secondMove);
      }
   }

   /**
    * Inputs a move the opponent made
    *
    * @param move the move the opponent just made
    */
   public void inputMove(Point move) {
      if (move != NO_MOVE) {
         enemyMoves.add(move);
      }
   }

   /**
    * Gets the next move as a new point and adds the new move to the move list
    *
    * @return the next move
    */
   public Point getNextMove() {
      Point move = NO_MOVE;
      boolean tooClose = true;
      long tries = 0L;
      long tooMany = 31415926L; // You got a better number in mind?

      // While the move is too close for comfort, keep getting a new one until
      // we've tried too many times. Then there probably isn't a legal move...
      while (tooClose && tries < tooMany) {
         tries++;
         tooClose = false;

         // Determines where on the line the move is (between lines 3 and 17)
         int coor1 = rand.nextInt(15) + 3;
         int coor2 = rand.nextInt(15) + 3;

         // Make sure the move isn't too high or low on the board
         if (coor1 > maxHeight && coor2 > maxHeight
               && coor1 < 19 - maxHeight + 1 && coor2 < 19 - maxHeight + 1) {
            tooClose = true; // Mark it as too close because that's
                           // effectively the same
         }

         // Mark the move as a point on the board
         move = new Point(coor1, coor2);

         // Check if the move is too close to one of our own stones
         for (int x = 0; x < moves.size() && !tooClose; x++) {
            if ((Math.abs((moves.get(x).x - move.x))) <= ownDistance
                  && (Math.abs((moves.get(x).y - move.y))) <= ownDistance) {
               tooClose = true;
            }
         }

         // Check if the move is too close to an opponent's stone
         for (int y = 0; y < enemyMoves.size() && !tooClose; y++) {
            if ((Math.abs(enemyMoves.get(y).x - move.x)) <= enemyDistance
                  && (Math.abs(enemyMoves.get(y).y - move.y)) <= enemyDistance) {
               tooClose = true;
            }
         }
      }

      // If we tried too many times, return a non-move instead.
      if (tries >= tooMany) {
         System.out.println("You're playing too many moves!");
         return NO_MOVE;
      }

      moves.add(move);

      return new Point(move.x, move.y);
   }

   /**
    * Gets the moves generated so far as a new ArrayList
    *
    * @return the moves generated so far
    */
   public ArrayList<Point> getMoves() {
      ArrayList<Point> theMoves = new ArrayList<Point>(moves.size());
      for (int i = 0; i < moves.size(); i++) {
         theMoves.add(moves.get(i));
      }
      return theMoves;
   }

   /**
    * Gets the moves your opponent played so far as a new ArrayList
    *
    * @return the moves played so far
    */
   public ArrayList<Point> getOppMoves() {
      ArrayList<Point> theMoves = new ArrayList<Point>(moves.size());
      for (int i = 0; i < enemyMoves.size(); i++) {
         theMoves.add(enemyMoves.get(i));
      }
      return theMoves;
   }

   /**
    * Generates the list of moves
    */
   public String generateList() {
      String list = "In this game I played the rare ";

      for (int i = 0; i < moves.size(); i++) {
         list = list + moves.get(i).x + "-" + moves.get(i).y;
         if (i < moves.size() - 1) {
            list = list + ", ";
         }
      }

      list = list + " opening";

      return list;
   }
}

EDIT: And I took the time to whip up an icon for this.


Attachments:
File comment: Generator Icon
RandomFuseki128.png
RandomFuseki128.png [ 3.24 KiB | Viewed 8479 times ]

_________________
"You have to walk before you can run. Black 1 was a walking move.
I blushed inwardly to recall the ignorant thoughts that had gone through
my mind before, when I had not realized the true worth of Black 1."

-Kageyama Toshiro on proper moves
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group