• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

help me create Go! game please

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Phone Myat Kyaw
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 97
Python VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Phone Myat Kyaw
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 97
Python VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 686
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic