Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Ticks in PHP Games


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Sayid Ahmed   Members   -  Reputation: 134

Like
0Likes
Like

Posted 27 March 2012 - 10:09 AM

With my current project the biggest challenge will be implementing the tick feature of my PHP + MySQL game. To briefly explain, my game is strategy based, is largely text-based (may have some javascript features later on). The following data will be stored in database tables and will need to be updated somehow:
  • one continuous 'world' with each player with their nation statistics
  • resources, units, research, production and such will all be updated on a tick basis (10 min periods, maybe?)
  • long term statistics; e.g. political party popularity for each player updates every 2 weeks
  • battles will be ticked and can last for days
Which begs the question of how to implement this tick system. The long term stuff and low bandwidth stuff can be arranged by cron job - simple solution probably. It's the resources and battles and all that stuff that I'm curious about. Most online advice says use timestamps and only update on request by the user, but is it actually that much more efficient? Anybody have any experience with it so they can benchmark?

What bothers me is that, one of the core features of the game will be trade, and with that you need a market place with lists of buy and sell orders. These will need to be kept up to date and every time the user visits the 'market.php' page it will have to do a search query and update it accordingly. I'm worried this could take very long and by the time the user chooses to buy or sell something, the data has changed and they'll get the wrong order when they submit.

I'd guess some of this data can be cached and work quickly but I have no experience with this.

Thanks

Sponsor:

#2 zoneweb   Members   -  Reputation: 92

Like
1Likes
Like

Posted 27 March 2012 - 12:48 PM

What bothers me is that, one of the core features of the game will be trade, and with that you need a market place with lists of buy and sell orders. These will need to be kept up to date and every time the user visits the 'market.php' page it will have to do a search query and update it accordingly. I'm worried this could take very long and by the time the user chooses to buy or sell something, the data has changed and they'll get the wrong order when they submit.

You need to queue the orders and process them one at a time. Read from the database only if the values have been changed. Otherwise, display it from the cache like what you've said.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS