Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 416509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:29:15+00:00 2026-05-12T18:29:15+00:00

I want to make a simple Go board to design an Computer Go game.

  • 0

I want to make a simple Go board to design an Computer Go game.

In a go game, you lie a “stone” (white or black) on a position where horizontal and vertical lines intersect.

What are some simple ways to restrict users from placing their stones in other locations?
Maybe I’m just not seeing a simple solution.

EDIT
I guess I should rephrase my question better:
I want to know how to do the background image of Go board, so that I can lie my stones on the intersection of the horizontal and the vertical lines. I was thinking about getting a just regular Go board image, and when I’m actually rendering stones, I find right position of pixels to lie stones. However, that solution did not seem to be the best solution, since I need to worry about size of stone images and think about proportionality when I either expand or shrink the board window.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:29:15+00:00Added an answer on May 12, 2026 at 6:29 pm

    I’d use enums here:

    enum Stone {BLAC, WHITE, NONE}
    
    class Board {
        static final int dimension = 19;
        private Stone[][] board = new Stone[dimension][dimension];
        // ...
    }
    

    Edit:

    Here’s a small demo (no resizing of the board and no images, just good old Graphics!):

    import java.awt.*;
    import java.awt.event.*;
    import java.util.Random;
    import javax.swing.*;
    
    public class GoBoardDemo {
        public static void main(String[] args) {
            JFrame frame = new JFrame();
            frame.setLayout(new BorderLayout());
            frame.add(new GoPanel(19), BorderLayout.CENTER);
            frame.setSize(600, 625);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setResizable(false);
            frame.setVisible(true);
        }
    }
    
    
    @SuppressWarnings("serial")
    class GoPanel extends JPanel {
    
        Square[][] board;
        boolean whiteToMove;
    
        GoPanel(int dimension) {
            board = new Square[dimension][dimension];
            whiteToMove = true;
            initBoard(dimension);
        }
    
        private void initBoard(int dimension) {
            super.setLayout(new GridLayout(dimension, dimension));
            for(int row = 0; row < dimension; row++) {
                for(int col = 0; col < dimension; col++) {
                    board[row][col] = new Square(row, col);
                    super.add(board[row][col]);
                }
            }
            repaint();
        }
    
        private class Square extends JPanel {
    
            Stone stone;
            final int row;
            final int col;
    
            Square(int r, int c) {
                stone = Stone.NONE;
                row = r;
                col = c;
                super.addMouseListener(new MouseAdapter(){
                    @Override
                    public void mouseClicked(MouseEvent me) {
                        if(stone != Stone.NONE) return;
                        stone = whiteToMove ? Stone.WHITE : Stone.BLACK;
                        whiteToMove = !whiteToMove;
                        repaint();
                    }
                });
            }
    
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                int w = super.getWidth();
                int h = super.getHeight();
                g.setColor(new Color(0xB78600));
                g.fillRect(0, 0, w, h);
                g.setColor(Color.BLACK);   
                if(row == 0 || row == board.length-1 || col == 0 || col == board.length-1) {
                    if(col == 0) {
                        g.drawLine(w/2, h/2, w, h/2);
                        if(row == 0) g.drawLine(w/2, h/2, w/2, h);
                        else if(row == 18) g.drawLine(w/2, h/2, w/2, 0);
                        else g.drawLine(w/2, 0, w/2, h);
                    }
                    else if(col == 18) {
                        g.drawLine(0, h/2, w/2, h/2);
                        if(row == 0) g.drawLine(w/2, h/2, w/2, h);
                        else if(row == 18) g.drawLine(w/2, h/2, w/2, 0);
                        else g.drawLine(w/2, 0, w/2, h);
                    }
                    else if(row == 0) {
                        g.drawLine(0, h/2, w, h/2);
                        g.drawLine(w/2, h/2, w/2, h);
                    }
                    else {
                        g.drawLine(0, h/2, w, h/2);
                        g.drawLine(w/2, h/2, w/2, 0);
                    }
                } else {
                    g.drawLine(0, h/2, w, h/2);
                    g.drawLine(w/2, 0, w/2, h);
                }
                stone.paint(g, w);
            }
        }
    }
    
    enum Stone { 
    
        BLACK(Color.BLACK), WHITE(Color.WHITE), NONE(null);
    
        final Color color;
        private final static Random rand = new Random();
    
        private Stone(Color c) {
            color = c;
        }
    
        public void paint(Graphics g, int dimension) {
            if(this == NONE) return;
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
                    RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setColor(color);
            int x = 5;
            g2d.fillOval(rand.nextInt(x), rand.nextInt(x), dimension-x, dimension-x);
        }
    }
    

    The Random stuff in there is an implementation the organic feel CPerkins was talking about. Well, I tried to do it anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a simple game: 2d, single-player, without tons of animations and
I want to make a simple game so that I can play against my
So here's the situation. I want to make a simple game for android. It's
i want to make a simple chess program. So far i've made the board
another quick question, I want to make simple console based game, nothing too fancy,
I want to make a simple highscore system for my game. No posting online,
I m begginer in cocos2d I want to make simple game in cocos2d. I
I'm starting to code my first game and I want to make simple 2D
I want to make a simple game on python, all text based. Sort of
Basically I want to make simple toggle program (that will be mapped to some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.