aspose file tools*
The moose likes Game Development and the fly likes help me create Go! game please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "help me create Go! game please" Watch "help me create Go! game please" New topic
Author

help me create Go! game please

Phone Myat Kyaw
Ranch Hand

Joined: Dec 26, 2008
Posts: 31
can someone help me provide links or give useful instructions about how to create Go! game Chinese version with 4x4 or 9x9 board ?

even some useful sample educational games and instruction links would be greatly appreciate !!!

thanks in advance
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11498
    
  16

what do you know how to do? what level are you at? do you know how to write a 'hello world' java program? do you know how to do everything but the AI for the computer opponent?

posting a generic "i need help with this project" doesn't really work very well here. It's like saying "i need help with a building" - do you need help drawing the blueprints, painting it, putting in the plumbing or finding the building?

specific, focused questions will draw better responses.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Phone Myat Kyaw
Ranch Hand

Joined: Dec 26, 2008
Posts: 31
thank you for pointing me out and sorry as I were on urgent case at that time. Okay, the main problem part is, implementing actionPerformed() function. I don't get idea its logic to build and determine which cell is chosen.

Here is my code (please accept my apologies for my bad written long codes).



My GO! game rule is simple, once whatever amount is surrounded and captured, the match is finished. But the problem is, how to decide which cell is chosen and how to calculate to know it's surrounded or not.

I'm using JButton [][]cell for inserting cells onto board like A1,B2,B3,... and the board will be 9x9.


but when it comes to actionPerformed(ActionEvent e) part, I completely lost my way to determine which cell is pressed as you see, cell[8][8] is last element and really have no idea how to loop back in the ActionListener method. As a result, I cannot decide which player has won as I cannot track the movements and so cannot calculate which cells are chained.


please, someone help me get out of this because I took several hours on this to finish but still
If there something you want me to change, can you also explain a bit for me to avoid such case in future ?

ps. sorry for my English and forgive me if there some word sounds rude or unclear.
colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

This is what I would do, but I am no expert

I would make my own class to be the cells, and I would have that class extend JButton

I would then add a boolean variable to say if it has or was chosen, then you could just loop through them and find out what ones have been selected and what ones haven't

so it would go something like:



and just out of curiosity, what's your native language?


www.mormon.org
Phone Myat Kyaw
Ranch Hand

Joined: Dec 26, 2008
Posts: 31
hmm creating separate class ? it looks possibility++

I'll try and will let you know when I've done or give up again

I'm from Myanmar(US and Western accept only as "Burma") and my mother tongue is Burmese (no Myanmese here).
Phone Myat Kyaw
Ranch Hand

Joined: Dec 26, 2008
Posts: 31
hmm creating separate class ? it looks possibility++

I'll try and will let you know when I've done or give up again

I'm from Myanmar(US and Western accept only as "Burma") and my mother tongue is Burmese (no Myanmese here).

thanks so much for your advice !
Phone Myat Kyaw
Ranch Hand

Joined: Dec 26, 2008
Posts: 31
thanks colton peterson, your advice help me one part Design GUI.

I've done the design part but still left Gameplay
Implementing Gameplay and Adding AI make me crazy and still trying to figure it out.

Can someone give some advice please ? Like, some useful info in similar to pseudocode for me to get easier ?

thanks in advance
colton peterson
Ranch Hand

Joined: Nov 18, 2007
Posts: 97

Is that all the code you have? I could not find where playerTurn is used. Why don't you post all of the code you have as of now
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11498
    
  16

Go is an EXTREMELY complicated game to try and write the AI for. To date, the BEST Go computers games are not as good the average casual player (ok, that may not be 100% true, but it's close).

so are you trying to simply come up with logic that can make a valid play, or logic that will play a good game? The former shouldn't be too hard, the latter next to impossible.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
Ah, a topic near and dear to my heart.

What Fred said is absolutely true. I would say that if you decided to learn Go, and studied diligently for 6 months, you would probably be able to beat the best Go program in the world. It's a devilishly hard problem. Just as a bit of background, for years there was a $10 million prize for the first program that could play at an amateur "expert" level, and that prize went unclaimed. (It's widely believed that the first program that can play at that level will earn a lot more than $10 million anyway )

That said, we ARE in an OO world, so go ahead and build the framework, and just make a call to the "callAItoMakeAGreatMove()" method. You can work on that method later.


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Marky Vasconcellos
Ranch Hand

Joined: Jan 28, 2009
Posts: 36
I dont read all.
But about the problem..

I never like use ImageIcons on games.. Use a BufferedImage and paint it on the paintComponent(Graphics g) of a Component like JPanel.

And to the ActionPerformed you can make some easy calcs to now what Cell the player clicked.

a ideia

pseudo-code

(Horinzontaly)
the Panel who have the Board has 100 pixels.. and has 4 cells
So if the player click on pixel 76 he is clicking on the 4th cell

100 / 4 = 25
(100 = board size, 4 cells in board, 25 = cell size in pixels)
76 / 25 = 3.04
(76 = user click pixel, 25 cell size, 3,04 the cell clicked)
so the clicked cell was:
int cell = 3.04;
if ((76 % 25) != 0)//In case the value are a floating point the result are the next cell
cell++;

In this case the cell is 4.


It's only a draft.. it can be improved.

My suggestions:
Learn Java2D for drawing
Learn about action listeners
Learn some Mathematics and Physics.


Each of their nuggets of wisdom contracted to a sound bite: Joshua Bloch: Write Lots of Code; Chet Haase: Don't Put Your Entire Application in One Method; Masood Mortazavi: Start Simple and Keep Learning; Cay Horstmann: First, Don't Panic
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
They are right, Go would be very very difficult to program a decent strategy

You might want to try your hand at programming a Reversi game first, Reversi has similarities to Go, and it would be much easier to implement a decent strategy.

http://www.learnplaywin.net/reversi/

There are a number of ways to display pieces. Myself, I'd just use a fillOval() command on the graphics context. And I wouldn't bother with any kind of offscreen drawing or buffering in a situation like this. My board representation would probably a simple int[][] with 1 for black, -1 for white, and 0 for empty square, or something like that.

edit: I see people with experience have recommended using bufferedImage. Perhaps there is a reason that I don't know about, but I can't see it, since no fast drawing or animation or fancy designs would be required.
Johnbear Johnbear
Greenhorn

Joined: Jul 28, 2009
Posts: 1
I never like use ImageIcons on games.. Use a BufferedImage and paint it on the paintComponent(Graphics g) of a Component like JPanel.

[ UD: Please refrain from posting spam signatures. ]
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Johnbear Johnbear wrote:I never like use ImageIcons on games.. Use a BufferedImage and paint it on the paintComponent(Graphics g) of a Component like JPanel.

[ UD: Please refrain from posting spam signatures. ]


I'm interested to know why you choose BufferedImage. Perhaps I misunderstand the concept, but I always thought that bufferingthing only added value when you had animation, perhaps with more complex designs. Just curious.

regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me create Go! game please