Board Game problem

Hi!
Im creating a board game and I'm having a problem. The aim of the game is to eliminate the opponent's pieces. Each time a player gets a three in a row of pieces, they are allowed to remove any one of the opponent's pieces.
My problem is this: If a player gets a three in a row, in his next two moves I want to disallow him moving one piece out of this three in a row and then back into it so as to try and remove another of the opponent's pieces with the same three in a row.
Here is the Player Class
public class Player
     char piece;
     String name;
     int numberofPieces;
     Player(char pieceVal, String name){
               this.piece=pieceVal;
               this.name=name;
               numberofPieces = 5;
}So when a player gets three in a row, I want to record his 3 in a row, and watch his next two steps and prevent him from having the same 3 in a row after 2 steps.
Can anyone help me? It has been wrecking my head for 2 days now!!
Thank you.

How about keeping a turn counter as well as the coordinates of the pieces in the player's last 3 in a row?

Similar Messages

  • How to create board game in InDesign

    I
    am trying to create a board game in InDesign, similar to the trivial pursuit board game. In other words, an outer wheel that has been
    divided up in sectionsand then spoes to the center. I think I can figure out how to do the spoes and the center, but I am having problems doing the outer wheel.
    Any ideas? Should I be doing this in photoshop instead?
    Thanks,
    FG

    Pretty much the same thing in Illustrator or ID, but Illy has more sophisticated drawing tools, including things like polar coordinates and duplication that will allow you to drag a copy of one of the line segments around an arc, then repeat at the same angle.
    In any case, you want to make two concentric circles, then draw a series of radial line segments between them. I'd then select all and creat a compound path.

  • About MultiplayerOnline Flash Board game

    Here is my three tier applcation:
    Client Layer : Flash AS3
    Application Layer: Asp.net
    Database Layer: SQL Server
    i have created my websites for asp.net, game programming has
    been done, but the only problem is i want a real time basis for
    creating a MMO Flash board game. But, how am i going to do that? I
    tried webservice package, but It only have PULL technology which is
    not suitable for real time basis. Is there any good ideas on what i
    should use? i heard about Sockets, XMLSockets, .NET Flash
    Remoting..but i am confused on what to use.

    Basically you can use anything that uses the rtmp protocol,
    like FMS, Red5, Wowza, SmartfoxServer and you can have a look at
    WebORB, a remoting package that also has a Publisher/Producer
    (comes in a .net flavor too).

  • Tables and Rounding Errors on Board Game Gui

    Hello,
    So I am in a software development class , and my team and I are developing a software version of a board game that uses numbered tiles placed on a board in a somewhat scrabble-esque way.
    Here is a picture of the game board:
    [http://img90.imageshack.us/img90/1052/untitledqv3.png|http://img90.imageshack.us/img90/1052/untitledqv3.png]
    Currently, a problem that we are working on is that as the tiles get further and further away from the center of the board, they are displayed further and further askew from the board lines. I have another picture to demonstrate what I'm talking about more clearly.
    [http://img225.imageshack.us/img225/4605/untitled2nn0.png|http://img225.imageshack.us/img225/4605/untitled2nn0.png]
    As the tiles get further away from the center, they are displayed more askew.
    We think that this happens because we are using a gridbag layout to add tile objects to, which displays the tiles in a certain spacing and orientation, and then we draw the board ourselves. When we draw the board, we get rounding errors inherent in the use of ints, and the lines become a bit off, with the problem getting worse as it gets further and further away from the center.
    Here is the code that we use to initialize the layout and add the tiles to it:
         //set the layout
    setLayout(new GridLayout(7, 7, 7, 7));
    //initialize the array with the references to all the tiles that we are going to add
    //to the layout
    squares = new SquareView[7][7];
    for (int i = 0; i < 7; i++) {
         for (int j = 0; j < 7; j++) {
              //create the tile, put a reference to it in the array
              squares[i][j] = new SquareView(boardModel.getSquare(new Point(j, i)), listener, handler);
              //add the tile to the layout
              add(squares[i][j]);
    }And here is the code that we are using to draw the lines for the board:
    GridLayout layout = (GridLayout) getLayout();
    //getting the dimensions of the board
    int rows = layout.getRows();
    int columns = layout.getColumns();
    int width = (getWidth() / columns);
    int height = (getHeight() / rows);
    g2.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), null);
    for (int i = 0; i < 8; i++) {
         // Vertical lines
         g2.drawLine(i * width, 0, i * width, rows * height);
         // Horizontal lines
         g2.drawLine(0, i * height, columns * width, i * height);
    }I think that our problems come from the innacuracy of ints, but if there is some addition or subtraction trick that we could pull, then let me know.
    Also, I was sort of looking into tables, and I was wondering if maybe we could use tables to do this, and have Java do our resizing for us.

    j.law wrote:
    We think that this happens because we are using a gridbag layout to add tile objects to, From the snippets of code, it's looking as though you're using GridLayout. But that's OK as GridLayout should work fine here.
    GridLayout layout = (GridLayout) getLayout();
    //getting the dimensions of the board
    int rows = layout.getRows();
    int columns = layout.getColumns();
    int width = (getWidth() / columns);
    int height = (getHeight() / rows);
    g2.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), null);
    for (int i = 0; i < 8; i++) {
         // Vertical lines
         g2.drawLine(i * width, 0, i * width, rows * height);
         // Horizontal lines
         g2.drawLine(0, i * height, columns * width, i * height);
    }I have no idea of this will improve things, but what about:
    GridLayout layout = (GridLayout) getLayout();
    int rows = layout.getRows();
    int columns = layout.getColumns();
    double width = (getWidth() / columns); //** how about using doubles here
    double height = (getHeight() / rows);  //** how about using doubles here
    g2.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), null);
    for (int i = 0; i < 8; i++) {
         // Vertical lines
         g2.drawLine(i * width, 0, (int)(i * width), (int)(rows * height)); // and casting?
         // Horizontal lines
         g2.drawLine(0, (int)(i * height), (int)(columns * width), (int)(i * height));
    }

  • Board game -alternate way to draw

    Thanks for reading,
    im relatively new to game devpmt, i am making a board game similar to pool.
    the board background is a JPanel on which a fixed image is drawn .i want to make a ball moving on it.The ball's image is loaded from a file .since the image is rectangular in boundary,ball when drawn on the board,displays the rectangular boundaries around it.
    is there any way to overcome this problem,
    all the drawings of board_backround_image and ball_image takesplace when the paintComponent() of the boardpanel is called.
    Any suggestions would b great helpful.....

    If you are reading from gif or png, make the background of the source image transparent. Otherwise, color the background with some unused palette color, search through the pixels after loading, and replace those pixels with transparent ones.
    If using jpg or some other lossy compression scheme, you'll not only need to have a transparency marker, but it will not always have the same RGB to compare with. Here's a quick snippet that will covert a particular color in an image to transparent pixels. The fuzziness variable is how far the red, green, and blue channels may be to still be considered marked as transparent.
    public BufferedImage transparify(Image sourceImage, Color replaceColor, int fuzziness)
       int imageWidth = sourceImage.getWidth(null);
       int imageHeight = sourceImage.getHeight(null);
       // ensure we are using a ARGB BufferedImage
       BufferedImage returnImage = new BufferedImage(imageWidth,imageHeight, BufferedImage.TYPE_INT_ARGB);
       Graphics imageG = returnImage.getGraphics();
       imageG.drawImage(sourceImage, 0, 0, null);
       imageG.dispose();
       // extract pixel data
       int[] pixels = new int[imageWidth * imageHeight];
       returnImage.getRGB(0, 0, imageWidth, imageHeight, pixels, 0, imageWidth);
       int transRed   = replaceColor.getRed();
       int transGreen = replaceColor.getGreen();
       int transBlue  = replaceColor.getBlue();
       for (int pixIndex = 0; pixIndex < pixels.length; pixIndex++) {
          // sum the difference of this pixel with the transparency marker
          int diffRed   = transRed   - ((pixels[pixIndex] >> 16) & 0xFF);
          int diffGreen = transGreen - ((pixels[pixIndex] >> 8) & 0xFF);
          int diffBlue  = transBlue -  (pixels[pixIndex] & 0xFF);
          // if close to the marker, set pixel to transparent
          boolean closeEnough = (diffRed >= 0 ? diffRed : -diffRed) <= fuzziness &&     
                          (diffGreen >= 0 ? diffGreen : -diffGreen) <= fuzziness &&  
                          (diffBlue >= 0 ? diffBlue : -diffBlue) <= fuzziness;
          if (closeEnough) {
             pixels[pixIndex] = 0; // 0 alpha makes transparent
       returnImage.setRGB(0, 0, imageWidth, imageHeight, pixels, 0, imageWidth);
       return returnImage;
    }

  • Designing a board game

    Is there anychance anyone out there can help me with the design of a risk board game in java - obviously. I am a complete rookie so if you can keep it as simple as possible I will be very greatful.
    Cheers!

    I'm designing a board game called othello. The thing
    is,
    i'm using something minimax, where the computer thinks
    ahead
    in the number of moves. Now, i'm having problems doing
    this,
    as I am using an array of weighted board values
    indicating
    which part of the board are more advantageous than
    others.
    The problem i'm having is to decide how to use this
    function.
    I am designing the game, so that it looks like 3 moves
    ahead.
    Do i call the weighted board values, once it's at the
    3rd move,
    so it then calls the minimax function and decides what
    move is best?
    Basically, does anyone know how to use these weighed
    values, and
    exactly when to call them. If someone could explain
    this in simple
    terms, it would be great.
    thank you so muchone way of handling this is adding up the weights of the possible moves up to the third move ahead, but do this as "branches". Meaning, if you take this first move what moves will it give you, and what moves will those moves give you. Once you have the current moves to third moves branches mapped out, then total the weights of all the moves and that will give you a branch weight. The better the weight branch will then tell your program which current move to make.
    Another thing to consider in your program is not just which spots are best (like corners are advantageous) because I can play the game, give someone a corner and still beat win, it is a simple strategy. There are plenty of other things to consider, for instance, consider mobility in your wieghts. How many moves does this give and how many moves does it take away or give to my opponent.

  • [Help] Board Game

    Hi. I've written a board game (Awale) which only allows two human players to play against each other. What I want to do now is to write an AI for the computer. The problem is I haven't got any clue how to implement the AI. Do I need to calculate every possible move for the AI and determine the best move which leads to victory. Or do I need to use nested if ... else ... to code my winning strategy (the program will be very huge then, won't it?)? I'm very new to game programming. Could someone please help me? Thanks in advance.

    Thanks guys. =)
    I guess MinMax algorithm is what I need. It's kinda similar to what Michael's suggested. As he's said, the only tricky part is assigning a "score" to each node.
    I found the following MinMax pseudocode on the web. I don't quite get what EvalGameState(game, MAX) does. Could anyone help? Thanks.
    MinMax (GamePosition game) {
      return MaxMove (game);
    MaxMove (GamePosition game) {
      if (GameEnded(game) || DepthLimitReached()) {
        return EvalGameState(game, MAX);
      else {
        best_move <- {};
        moves <- GenerateMoves(game);
        ForEach moves {
          move <- MinMove(ApplyMove(game));
          if (Value(move) > Value(best_move)) {
            best_move <- move;
        return best_move;
    MinMove (GamePosition game) {
      if (GameEnded(game) || DepthLimitReached()) {
        return EvalGameState(game, MIN);
      else {
        best_move <- {};
        moves <- GenerateMoves(game);
        ForEach moves {
          move <- MaxMove(ApplyMove(game));
          if (Value(move) > Value(best_move)) {
            best_move <- move;
        return best_move;
    }

  • Titanium Fatal1ty Pro SPDIF game problem

    (Titanium Fatalty Pro SPDIF game problem hi all,
    sorry if this issue reported in the past i but i could not get any answer on any relati've posts, the terminology was so complicated
    i buy?a new pc with a Titanium Fatalty Pro sound card, i use Vista sp2 x64, the sound card is connected to my external amplifier with SPDIF out in order to get surround sound for my movies and my games and here is my problem
    any movies format with surround sound play perfect with out any problem any kind of movie DVD, dvix, mkv?files?etc
    but non of the games i play?use the surround system, why is that? is any?kind of special settings needed to be done? how is possible to get surround to movies and not to the games?
    thanks you all for your time ?

    ,Re: Titanium Fatalty Pro SPDIF game problem? this is really coincidence - I just posted on the very same topic 5 minutes ago.
    for games just go to the Console Entertainment mode > Encoder > Dolby Digital. Although this is not documented I believe what happens is that the sound card encodes the 6 digital channels onto Dolby Digital mode and transfers this over SPDIF. Kok-Choy actually recommend using the standard analogue cables (and he has a point as you are actually upcoding an existing game signal onto Dolby so that your digital receiver can then decode this down to 6 channels - seems a pretty useless overhead)
    for video - I am curious to know what you do - I can either get 96/24 bits on the display of my z5500 with a direct signal but the z5500 receiver then tells me that this signal is only in dolby ProLogic II (and not DD or DTS). As alternati've I use again the encoder and have to select for EACH FILM WHAT IS BEST DOLBY DIGITAL OR DTS. Pls explain what settings you use.
    thanks

  • Pogo board games. What they are using?

    Hi,
    I been to Pogo.com and tested board games. All are made with JAVA.There games are 2D.
    1 - Can some one tell me what mix of techonologies they are using. Board, Poker games? .
    2 - Can we made these games with Java 2D library?
    3 - What multiplayer server they are using for multiplayer games. Any idea?
    4 - How do you find creating games with Java 2D instead of flash (any idea). Is it easy to use 2D library?
    5 - If we use 2D library than we need to know Java to work on that?
    thanks in advance.

    Pirzada wrote:
    Hi,
    I been to Pogo.com and tested board games. All are made with JAVA.There games are 2D.
    1 - Can some one tell me what mix of techonologies they are using. Board, Poker games? . Well, I would think you have answered your own question before you have even asked it--Java.
    2 - Can we made these games with Java 2D library?Yes.
    3 - What multiplayer server they are using for multiplayer games. Any idea?Are you asking if there are multiplayer gaming engines that you can incorporate into your software instead of programming it yourself?
    4 - How do you find creating games with Java 2D instead of flash (any idea). Is it easy to use 2D library?You lean Java, study the tutorials on Graphics and 2D, then write what you like.
    5 - If we use 2D library than we need to know Java to work on that?Ummm... well, yes, of course: do you have to know French to speak it?
    thanks in advance.

  • About flash Board game

    Hi all , i wanna ask a question regarding flash board game.
    i have an online flash application of chinese checkers board
    games that can be allowed up to 12 games rooms maximum.
    The question i wanted to ask is that if i got 12 game rooms ,
    do i need 12 different swf files for 2 players , another 12
    different swf files got 3 players , another 12 different swf files
    for 4 players and 6 players ?
    Please someone can enlighten me ? thank you

    I think this has more to do with the domain logic (how you
    structure your game and what you want it to do) than it does
    ActionScript.
    There is no reason you couldn't write a chinese checkers game
    with a dynamic amount of rooms all in one swf.

  • Creating a board game

    I'm making a "board game" in Flash with Actionscript 3.0.
    When the player lands on a certain space, I want a window to pop up
    & they complete a word search game. The faster they complete
    the word search, the more points they would earn. I already have it
    working so that the word search swf pops up at the right time, but
    I'm not sure how to grab the time they completed the game in &
    send it back to the main movie. I got the word search code from
    here:
    http://www.subtangent.com/flash/
    and it's written in Actionsript 2.0. Is it still possible to use
    both together? If so, how can I send the time back to my main movie
    to figure out their score?
    Thanks,

    an as2 swf will work when loaded by an as3 swf. the two can
    communicate using the localconnection class.

  • I am going to make a board game like chess using flex air

    Dear, ~~
    I am going to make a board game like chess using flex air.
    I would greatly appreciate it if you let me know if it is
    possible to make a board game as follows.
    [Environment]
    1. server : Visual C++
    2. client : Flex air
    [Client & Server Requirement]
    1. server should have capacity concurrent user over 3000
    2. client refresh game room list almost realtime
    3. client refresh waiting user list almost realtime
    4. support 1 vs 3000 chatting system ex) one teacher vs 3000
    students
    5. broadcast information of move stone to almost 1000 room
    (each room has at least 2 user)
    6. process 100 ~ 500 packets per one second.
    Thanks for reading this.

    Hi,
    This should be possible. Sounds pretty interesting. Let us
    know what happens of this.

  • Actionlistener for a board game !!

    hi,
    im busy with a board game i puted under every button of the board an actionlistener
    and my quastion is :
    how can i do it that if you clik at a button you get the button source ( or just the ImageIcon) and put it on the second mouse clik on another button ?

    public class Game {
      boolean takePic = true;
      Icon icon = null;
      public actionPerformed (ActioneEvent e) {
         //only if you KNOW only JButtons will cause event!
        JButton temp = (JButton)e.getSource();
        if (takePic) {
          icon = temp.getIcon();
          takePic = false;
        else {
          if (icon != null) {
            temp.setIcon(icon);
          takePic = true;
        repaint();
      }

  • Making a Board Game

    I wasn't really sure where to place this thread but here goes. I want to make a simple board game (Checkers or maybe Chess) in two player mode only (One player will come later). I am not sure how exactly to go about it. Are there any special methods or classes I have to implement? I would like to build it so that the pieces, when released, go to the center of the square they are held over. Does this involve any special mapping of the board image? Would it be better to create the board in a paint program and implement it that way or should I use java.awt.geom to do that? And since I don't want to copy somebody else's chess pieces (that would be cheating) is there a way, in java, to create images like that? and if not what imaging program should I use (definitely not adobe photoshop)? Should I even be attempting to do this kind of thing yet?

    Here is the code I have so far:
    import java.awt.geom.*;
    import java.awt.*;
    import javax.swing.*;
    public class JChess extends JPanel {
        BasicStroke three;
        public JChess() {
         super();
        public void paintComponent(Graphics g) {
         Graphics2D g2d = (Graphics2D) g;
         three = new BasicStroke(3);
         g2d.setColor(Color.white);
         g2d.fillRect(-100, -100, getSize().width + 100, getSize().height + 100);
         g2d.setColor(Color.black);
         g2d.setStroke(three);
         g2d.translate(75, 75);
         g2d.drawLine(0, 0, 600, 0);
         g2d.drawLine(0, 0, 0, 600);
         g2d.drawLine(0, 600, 600, 600);
         g2d.drawLine(600, 0, 600, 600);
         //first row
         g2d.fillRect(0, 75, 75, 75);
         g2d.fillRect(0, 225, 75, 75);
         g2d.fillRect(0, 375, 75, 75);
         g2d.fillRect(0, 525, 75, 75);
         //second row
         g2d.fillRect(75, 0, 75, 75);
         g2d.fillRect(75, 150, 75, 75);
         g2d.fillRect(75, 300, 75, 75);
         g2d.fillRect(75, 450, 75, 75);
         //third row
         g2d.fillRect(150, 75, 75, 75);
         g2d.fillRect(150, 225, 75, 75);
         g2d.fillRect(150, 375, 75, 75);
         g2d.fillRect(150, 525, 75, 75);
         //fourth row
         g2d.fillRect(225, 0, 75, 75);
         g2d.fillRect(225, 150, 75, 75);
         g2d.fillRect(225, 300, 75, 75);
         g2d.fillRect(225, 450, 75, 75);
         //fifth row
         g2d.fillRect(300, 75, 75, 75);
         g2d.fillRect(300, 225, 75, 75);
         g2d.fillRect(300, 375, 75, 75);
         g2d.fillRect(300, 525, 75, 75);
         //sixth row
         g2d.fillRect(375, 0, 75, 75);
         g2d.fillRect(375, 150, 75, 75);
         g2d.fillRect(375, 300, 75, 75);
         g2d.fillRect(375, 450, 75, 75);
         //seventh row
         g2d.fillRect(450, 75, 75, 75);
         g2d.fillRect(450, 225, 75, 75);
         g2d.fillRect(450, 375, 75, 75);
         g2d.fillRect(450, 525, 75, 75);
         //eighth row
         g2d.fillRect(525, 0, 75, 75);
         g2d.fillRect(525, 150, 75, 75);
         g2d.fillRect(525, 300, 75, 75);
         g2d.fillRect(525, 450, 75, 75);
    }As you can see I don't know what I am doing or what I am supposed to do LOL. = )

  • A board game

    Does anyone have some good suggestions of where to get classes to putting together a board game, free of course.  I do not want to use them actually but get the idea of how mine would incorporate into the classes.  I have a board game where I want each square on the board to know if it is occupied or not, to change its color, and to keep track of what is actually happening with it.  Any suggestions greatly appreciated.

    First off I did not say that I knew very little, I just do not want to reread so much information that I won't have the time to work on the project.  I think it rather obtuse of you to think such a thing but that is your privelege.  Thank you for not answering something that  seemed to be just a friendly question.  I gues that since you are a guru that you cannot spend your time over trivial people like me who do not have what you have.  Thank you again.  Goodbye for good this board is of no use for someone trying to learn.

Maybe you are looking for

  • How do i transfer cd's on one computer to another computer?

    i have cd's on my old computer that i imported.  i've purchased a new computer & am having trouble transferring the cd's to the new computer.  it seems itunes will only let me transfer what i purchased from the itunes store.  how do i transfer the cd

  • How do I stop iTunes from processing a podcast on my iPad?

    I have been trying to get to the next items to download in my iTunes downloads, but it has been over 24hours and this one file will not finish processing. After hooking the ipad2 to the Mac, it tells me that some videos in my iTunes library were not

  • Where can I find Binder in Acrobat?

    I am advised I can collate several documents in an app called Binder within Acrobat but I don't know how to go about this? E

  • BAdi DPR_EVENTS for user statuses

    Hi, Anyone having ideas on how to use the BAdi DPR_EVENTS when user defined statuses are triggered? Regards, Vivek?

  • Current Voltage Luminance Testing System for OLEDs

    This is going to be a message board for a OLED/LED Current-Voltage-Luminance (IVL) testing system that I am in process of developing.  The system will be capable of electrically categorizing 36 pixels(9 Devices, 4 pixels each) by performing a reverse