Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Battleship (multiple quesions)
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
evogre3n




PostPosted: Sun Dec 25, 2005 7:43 pm   Post subject: Battleship (multiple quesions)

Hey all,

I am in the process of creating battleship, and for the actual playing field, I was thinking of the following two options:

1) create a 2d (10x10) array and draw squares using painComponent onto a given panel

or

2) create a 2d array (10x10) of JButtons, that way I dont have to worry about writing paint methods for everything etc.

What do you guys think? What would be better?

Also, I need to write an algorithm for the AI, should I make 2 level of difficulties where easy is random guesses and difficult is a random guess, then if you get a hit, try the spots around it and continue to destroy the ship.

Or is there a more advanced algorithm I can consider?

Thanks a lot Smile
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sun Dec 25, 2005 9:37 pm   Post subject: (No subject)

It's up to you, if you are comfortable with JButtons then probably use those, but drawing them yourself would likely give more flexibility.

As for an ai, you could do what computers almost always do in games. Cheat. It has the position of your ships, so it can randomly choose a box somewhere in that area to improve the chances of hitting your ship. Higher difficulty = a smaller area to choose from.
evogre3n




PostPosted: Sun Dec 25, 2005 11:58 pm   Post subject: (No subject)

Hmm, alright I guess if become short on time, that is what I will do. (the cheating method)

if I find i have the time, Ill probably explore creating a mathematical AI, I figure that will give me some more experience and allow me to feel more comfortable with future things.

As to drawing it... i find it a bit tedious to keep track of multiple normal panes and then a graphical pane that is wacky to update, if i use JButtons, i can update their colors etc in real time, they already have double buffering, so its really convenient, I think I will use them.

But you mentioned more flexibility.. in what way would I gain more flexibility by using drawn grids etc.?
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: