Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Feedback on simulation approach.  (Read 1895 times)
0 Members and 1 Guest are viewing this topic.
Offline dray

Junior Newbie





« Posted 2006-11-30 05:27:29 »

Ladies and Gentlespoons,hobos and tramps,
Cross-eyed mosquitoes,and bow-legged ants,
I stand before you to sit behind you
To tell you something I know nothing about.

Love that poem. Anyhow, I'm a little unsure of how to best solve the following problem and I'm welcoming all feedback from anyone who reads this post.

I have a daughter in 9th grade whose economics project / science fair project is due in February and she has decided to do a little 'tycoon' simulation. I have to code it of course. So, here's what I agreed to do for. Allow her and her classmates to run a simulation for ten to thirty days depending on when I can finish. Each 'player' will own a truck that they can ship freight with to earn an income. The only cost is fuel, but it takes time to travel from one city to the next. The truck is operated by a driver who never sleeps, so it can run for 24hrs straight. That's the bulk of it and is just that simple.

Now for the feedback as I'm still prototyping this in my mind. I've been developing Java since day 1.1 and have learned that just because this is meant for 25 or so people, it won't always be that way. I say that because issuing and tracking a few TimerTasks are fine, but would cause me a few headaches if I wanted to scale this. So, I'm thinking that I should just monitor a timestamp column for various records in the database.

1. Send freight from Jacksonville, FL to Nashville, TN
2. Calculated time is eight hours
3. Add timestamp to player_action table
4. When details related to player are queried, check the timestamp.
    a. If shipping time has passed ... drop freight ... collect pay .... top off fuel
    b. Calculate remaining time for display purposes



I played around with some MUD programming in my youth and wrote a sidescroller or two, and even implemented a few model simulations as course work in college, but  I always used Threads or Timers because nothing was multiplayer centric. Can someone suggest an alternate approach or a better way to implement what I described? Thanks in advance for your suggestions.

One more thing. This is text based or I'll implement something via the web for the players to choose which jobs they want to perform and it's at best a 'piece of a game'.
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #1 - Posted 2006-11-30 11:53:18 »

You don't need a database. And time also only exists in its abstract form. That means you don't have to deal with any real timing at all. As far as time is concerned there are only a bunch of values where the state changes. That is... if a driver reaches a goal.

The drivers are at the start position and the one who has the shortest distance to travel dictates when the next state change will be. And so on. Whenever a state change happens you capture the state of the simulation.

Thats all there is to it afaict.

弾幕 ☆ @mahonnaiseblog
Offline dray

Junior Newbie





« Reply #2 - Posted 2006-11-30 17:54:55 »

The need is to do this 'real time'. Take OGame, which everyone has played  Wink. You ship some resources from one planet to the next and that action takes two hours to complete (hour there and back). You also have the option to cancel that action within the first hour.

What I'm getting at is that the action doesn't complete until some predetermined time in the future and the outcome of that action may be dependent upon another action issued by another player. I'm looking for a way to implement this without issuing a bunch of threads or timers, simply for the sake of saving resources and the ability to recover should my box lose power.

If this still doesn't make sense, maybe someone can describe how OGame might be implementing what I described. This is actually where my daughter got the idea and wanted me to build her an 'OGame'. I don't have the time for that and I compromised with shipping freight from city to city. Again, I apologize for the lack of RTS and Strategy game programming. I may just do this turn based and give x number of turns a day, but that removes some of the fun and does not solve my curiosity on how to implement this behavior.

Ahh. I just read this thread      How does it work in a MMORPG?  and it is important to note that the player might not be logged on when it's time for the action to complete. Hope that helps.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline dray

Junior Newbie





« Reply #3 - Posted 2006-12-05 20:42:00 »

So, I learned that TimerTasks are run on the same thread as the Timer that executes it. My test was flawed in that I created a timer for each TimerTask rather than using the 'one' timer.

Dave Brackeen was kind enough to point this out to me. Many thanks.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (26 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (34 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!