Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Game Architectural Question

Thread view: 
Jack Burton - 23 Oct 2006 21:55 GMT
Hi,
I'm new to this group and I'm writing because my java knowledge lack of
pattern and standard solutions for common (or less) problems. Hope you
can help me better than I did :-)

I'm trying to build an online web game: you command a fleet in space,
so you can move the fleet between planets and combat other fleets. I
need a sort of background task that, perhaps reading from a DB various
scheduled travels and fleet positions, could "move the fleets" and
"manage battles". I thought of a task that wake up every X minutes (let
say 5) and check all this (move a bit a fleet, delegate a battle
between two fleets to another task, and so on).

Do you have any suggestions using java language/pattern/common
solutions?

Thank you,
Jack Burton
Oliver Wong - 24 Oct 2006 15:16 GMT
> Hi,
> I'm new to this group and I'm writing because my java knowledge lack of
[quoted text clipped - 11 lines]
> Do you have any suggestions using java language/pattern/common
> solutions?

   What I usually do for stuff like this is, instead of running a
background thread or whatever, I have a DB table which basically schedules
when events should occur. For example, if the player says "Move this ship
from its homeplanet of Quartz to planet Nebulon", I'd immediately change the
ship's location from "Quartz" to "space", and then add a scheduled event of
"At stardate 499283, move ship from 'space' to 'Nebulon'".

   Then, the next time a player (ANY player in the game) does something, I
run a quick process to calculate the in-game stardate based on the real-life
time, and then look at schedule-table to see which events are in the pass,
according to this stardate, and then trigger all the events in order.

   The only problem with this is that if players decide to abandon your
game for a while (e.g. days or months), the events won't actually trigger
until the next time a player logs into the game to check the state. And this
is only a problem if your game also features e-mail notification of events;
the other players won't get the e-mail notification until SOMEBODY logs in.
If this is a problem for you (it won't be, if you don't have e-mail
notification feature), then you can just create a dummy robot account, and
write a small application (in any language, not nescessarily Java) which
just logs into the robot account every 5 minutes, and immediately logs out.

   - Oliver
Jack Burton - 25 Oct 2006 20:46 GMT
This is an interesting point of view, Oliver!
I was thinking about other issues that it can produce (other than the
email notification), but I was only able to argue about performance.

It's true that if at every action a user does I have to check "an event
queue", perhaps it's better to check on a regular basis (thinkin' of
dozens of users). You can argue that the checks could have a minimum
delay, but for every action you have to do a little amount of code (at
least to check if this minimum delay has passed).

Your solution, however, is very clever and coming with not too much
coding effort.

Thanks!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.