Welcome Guest, Not a member yet? Register   Sign In
Psuedo Code Needed...
#11

[eluser]Nick Husher[/eluser]
It's probably a bad idea to have the game progress be determined by player HTTP requests. You should think about running part of your application via a cron task, or as a daemon process on your server. That way, you have the server operating in realtime while the clients get updates via the HTTP interface. The server maintains a collection of games and updates their states based on update queues generated by the HTTP front end.
#12

[eluser]troy_mccormick[/eluser]
I did think about running it via CRON, but the job would have to run like every three seconds. That's a little much, no??
#13

[eluser]troy_mccormick[/eluser]
Anyone have any ideas??

Thanks,
#14

[eluser]Nick Husher[/eluser]
It looks like there are plenty of sources on how to run PHP scripts as demon processes. I would look into that.

The code that handles communicating with the players (call it the face) might handle input/output concerns, while the demon manages game logic (call it the brain). The face puts any player actions it receives into a FIFO queue, probably in a database table and responds with the updated game state. You might also want to check any received actions to see if they're valid actions within the game rules before adding them to the queue. If an action is invalid or inappropriate, you can pass back an appropriate error message. The brain checks the FIFO queue every so often (100ms, perhaps?) and performs any tasks stored in the queue in order and updates the stored game state.

I would guess and say that CodeIgniter would be an inappropriate platform for designing the brain aspect, but ideal for the face. The advantage of developing the two with separate codebases is that you can, if you find you're running into scaling concerns, replace one or the other for a faster alternative. You could move the face to a distributed cluster solution, or reimplement the brain in a compiled language like C.




Theme © iAndrew 2016 - Forum software by © MyBB