• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

My Java Risk Game

Joined
Jun 19, 2005
Messages
2,445
http://download289.mediafire.com/ngzymgdjrzig/a2xxmqozljb/Risk.zip
(JAR file, you must have Java installed on your computer)

So yeah, my college project for one of my CS classes was to program the game of Risk in Java. Wasn't so bad but was A LOT of work for someone who hasn't done any GUI programming before (which was a majority of the class). We went straight from console programming to this! :p

It was fun though, I learned a lot in the process and I'm overall satisfied with the end product even though I still consider it to be in "alpha" state.

So yeah I just wanted to share my ghetto little program, get some feedback, comments, flames, whatever! ;)

If you do try it, the following is VERY IMPORTANT:

- Add exactly 3 players. No more!
- Change ClassicRisk.board and ClassicRisk.png to PirateRisk.board and PirateRisk.png. This is my custom plugin that I made in MSPaint and it is a much smaller version of Risk (much easier for testing). If you want an even smaller version, try FishyRisk.board and FishyRisk.png.
- Humans only! My AI works for the most part but I'm having some rare exception issues, so please try an all human game at first. If you care to you can try an all AI game (again, please add exactly 3) and watch the computer play against itself, though it will probably only continue for so long before throwing an exception.

You should be set then. Note the CPU usage when moving the mouse over the map image. Most inefficient highlighting algorithm ever? I think so. But that's because it's traversing through arraylists for each pixel you move the mouse over. :p

P.S. If you go to Stony Brook and were in this class with me (wouldn't be the first time I met another Stony Brook student on here), post your version as well! :D
 
offtopic: are they teaching u purely java in your CS courses or are you getting a taste of .NET as well?

sidenote: Some of the things that i've seen with WPF are impossible in java...
 
offtopic: are they teaching u purely java in your CS courses or are you getting a taste of .NET as well?

sidenote: Some of the things that i've seen with WPF are impossible in java...

hmm, in this school I'm seeing mostly Java. My previous school seemed to be all C++.

In this school particularly, I've programmed in the following languages:

Java
C
MIPS/SPIM Assembly

In my previous school:

C++
Visual Basic
Assembly

But I have about 10 more CS courses to take before I graduate, so we'll see.
 
fun game, i am master of the pirate territories now yar

got some wierd behavior on the standard map though (started with negative armies, and could add what seemed like an unlimited number, so i never got out of the "add armies" stage. would've been interesting if i did though :p
 
fun game, i am master of the pirate territories now yar

got some wierd behavior on the standard map though (started with negative armies, and could add what seemed like an unlimited number, so i never got out of the "add armies" stage. would've been interesting if i did though :p

good job on the GUI and everything, nice and clean
 
P.S. If you go to Stony Brook and were in this class with me (wouldn't be the first time I met another Stony Brook student on here), post your version as well! :D

heh i used to live there.. my dad finish his grad school/residency there.

now i goto purdue for ece / cs minor

the program looks good..i actually started to play it lol
 
got some wierd behavior on the standard map though (started with negative armies, and could add what seemed like an unlimited number, so i never got out of the "add armies" stage. would've been interesting if i did though :p

Yeah, the problem is that with 3 players you are only initialized with 10 armies (I purposely did this for testing purposes on smaller maps) and with Classic Risk there are 42 territories, so all of those armies get diminished during initial territory claim mode (before army adding mode can even begin). And for army adding mode to function properly, each player must have at least one army.

If you add 4-6 players you will start with 20-30 armies, so the problem will be solved, but you will be there for a long time adding armies. :p

GUI is ok IMO, I would've preferred to put everything in one window but due to time constraints and my lack of experience with the layout managers, it was much easier to separate the windows.

At any rate, thanks for the comments guys. :)
 
That's pretty impressive. Did you work on this alone or as a class?
 
I found a bug in your game.

risk.png


I was attacking from the territory with 69 armies. Also the game will not allow me to retreat when it is like this.
 
^ hahaha, you actually played it for that long? All human?

But yeah, it's hasn't been tested much. As I said, alpha state at best. I only tested it with the FishyRisk plugin and I was able to win multiple times without any problems. Also note the lack of card functionality. I ran out of time to implement it. :p

And yeah, we worked on this alone, kind of a huge step up from console programming huh? But I did learn a lot from it, so it was worth it. :)
 
Thanks man, I'll probably tinker around with it a bit more before it starts to collect dust.

One thing I wanted to do was make the highlighting feature more efficient. I'm thinking it's the ArrayLists that are slowing it down... Do you think something like a linked list would work better to store all of the territories? I'm just looking for the most efficient way to store and traverse through a list of territories.
 
Good start to this, for sure. There are some things I noticed that could be worked on, but you know that already. :)

I didn't get much time to look at this as a whole, but I like the look and feel of the GUI. Maybe when I get more time later I'll play more and look through your code as well.

Definitely something that you'll want to polish, because if you don't now you probably won't even.
 
Back
Top