Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 3314 times)
0 Members and 1 Guest are viewing this topic.
Offline dray

Junior Newbie

« Posted 2006-11-30 04: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: 2

pixels! :x

« Reply #1 - Posted 2006-11-30 10: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 16: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 19: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  

EgonOlsen (73 views)
2018-06-10 19:43:48

EgonOlsen (54 views)
2018-06-10 19:43:44

EgonOlsen (73 views)
2018-06-10 19:43:20

DesertCoockie (253 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (153 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (807 views)
2018-03-24 14:43:53

Solater (171 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!