[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ONLINE GAME] Ruby Core + Php FrontEnd (open

Flaab Mrlinux

12/9/2006 2:38:00 PM

Good afternoon everyone.

I've been thinking around this for a long time. I want to program a
Online Estrategy Game (sort of Ogame style) and I just had technical
problems. But since i learned ruby I think i might just have found the
solution and i would like to check out your opinions.

My main problem was...Fine, players will have their empire and can do
certaing things (attacking, organizing their army, creating new fuel
sources, etc) and those actions change/create lines in the game
database. That's cool by now and had no problem with it, Php would do
the trick. But the problem is that the GAME core has to be running and
executing actions when neccesary. For example; an attack takes some
hours to arrive the attacked city, and depends of distance, speed of the
army, etc. Fuel sources creates fuel and arms but also takes some time.
This is why i need a CORE to be working all the time (or almost).

So this is what i've thought; I'm gonna have a Web Based Php Front-end
for the players to comunicate with the game. And a Ruby Core program
sinchronized with Cron to be launched every 3 minutes for example. That
Core will do all these things i can't do from Php, catching MySql files
that tells it what to do, do it, and update those MySql fields which may
need updating.

Can this be done?

Thx

--
Posted via http://www.ruby-....

15 Answers

David Vallner

12/9/2006 4:17:00 PM

0

Flaab Mrlinux wrote:
> So this is what i've thought; I'm gonna have a Web Based Php Front-end
> for the players to comunicate with the game. And a Ruby Core program
> sinchronized with Cron to be launched every 3 minutes for example. That
> Core will do all these things i can't do from Php, catching MySql files
> that tells it what to do, do it, and update those MySql fields which may
> need updating.
>

Concurrency errors beware. Whatever the frontend, how do you plan to
communicate with the backend? Since this is write-mostly database work,
what architecture do you plan to use?

You might want to consider two database layers, one to store things that
happen between these three-minute cycles (to provide immediate feedback
to players), some action log (message queue) you'd sort through
depending on what the evaluation cycle is (think M:tG turn phases), and
then a second DB layer with the long-term state of the game.

Hrm, did I get taken away on an ill-informed architecture rant? Ah well ;P

David Vallner

M. Edward (Ed) Borasky

12/9/2006 5:23:00 PM

0

Flaab Mrlinux wrote:
> Good afternoon everyone.
>
[snip]
> Can this be done?
>
What's the business model? :)

--
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blo...

If God had meant for carrots to be eaten cooked, He would have given rabbits fire.


Paul Lutus

12/9/2006 5:58:00 PM

0

Flaab Mrlinux wrote:

/ ...

> So this is what i've thought; I'm gonna have a Web Based Php Front-end
> for the players to comunicate with the game. And a Ruby Core program
> sinchronized with Cron to be launched every 3 minutes for example. That
> Core will do all these things i can't do from Php, catching MySql files
> that tells it what to do, do it, and update those MySql fields which may
> need updating.
>
> Can this be done?

The question is not whether it can be done, the question is why would one
want to do it this way. In modern times a program like this is
event-driven, not clock-driven, for excellent reasons.

--
Paul Lutus
http://www.ara...

jungans

12/9/2006 9:38:00 PM

0

> So this is what i've thought; I'm gonna have a Web Based Php Front-end
> for the players to comunicate with the game. And a Ruby Core program
> sinchronized with Cron to be launched every 3 minutes for example. That
> Core will do all these things i can't do from Php, catching MySql files
> that tells it what to do, do it, and update those MySql fields which may
> need updating.

Why not just use PHP for the cron job? It doesn't seem like a good
decision to write the app in two different languages (harder to
develop, harder to maintain, etc).
Also, concurrency is not an issue as long as you use transactions to
enforce integrity at the application level (i.e.: if an attack is about
to occur, damages on both sides (attacker and victim) have to be
updated inside a single transactional block).

David Vallner

12/10/2006 3:14:00 PM

0

Paul Lutus wrote:
>
> The question is not whether it can be done, the question is why would one
> want to do it this way. In modern times a program like this is
> event-driven, not clock-driven, for excellent reasons.
>

If it's a turn-based game, why not? Besides, the architecture would be
similar anyway, you'd just evaluate the player actions in discrete
ticks, not immediately.

David Vallner

Paul Lutus

12/10/2006 5:46:00 PM

0

David Vallner wrote:

> Paul Lutus wrote:
>>
>> The question is not whether it can be done, the question is why would one
>> want to do it this way. In modern times a program like this is
>> event-driven, not clock-driven, for excellent reasons.
>>
>
> If it's a turn-based game, why not?

Responsivity? The fact that the processor would not bother with the process
unless there was a need, and the more need, the more attention. The usual
reasons for event-driven design.

> Besides, the architecture would be
> similar anyway, you'd just evaluate the player actions in discrete
> ticks, not immediately.

Yep, true. I've always though event-driven made more sense in a case where
there might not be any processing required at a particular time, or
conversely, when there were a lot of players and a lot of attention needed.

In detail, when there are no players, the timer gets the processor's
attention for no reason, but when there are a lot of players, the timer
cycles might begin to overlap, a contingency that must be handled in the
game routine.

Neither of these issues comes up with an event-driven design.

--
Paul Lutus
http://www.ara...

Flaab Mrlinux

12/12/2006 12:36:00 AM

0

Jonas Pfenniger wrote:

> If you take the example of Ogame. Imagine you send an attack to planet
> XY.
> You don't need to know the result until user A or user B access their
> profile and see that user A has destroyer all user B's sattelites.

I Jonas. This is not actually true: I'll explain myself. Supposse the
following:

1) User A sends an attack to user B, supossed to arrive within 5 hours.
2) Then none of A or B users connect again due to whatever.
3) Just after those 5 hours passed, an user C sends an attack to user B,
but user B has already received an attack that hasn't been proccessed
cause neither the atacker or himself connected again and the user B
defense forces info is deprecated.

I keep on thinking it's important to have a CORE running and
event-oriented design would not work, cause users produces events indeed
but they don't have to became processes inmediatly; they might have to
wait a lot. I've a lot to learn if somebody thinks otherwise i'll be
pleased to be tought.

Concurrency problems have indeed to be taken care of, two databases it's
a good idea like i've been told here.

I was thinking about doing it with Php cause it's my "mother languaje"
for dynamic web programming, I knew about ruby on rails but i thought it
was more like a "PhpNuke" or "Mambo" CMS programmed in ruby, or close to
it.

I've read that Rails is much more fast to program dinamic web sites
but...as far as I know, Php is pretty effective and Rails was something
fast to do standard web applications but i didn't thought it could do
the trick for a complicated game web-based interface. Can it really be
usefull to do this?

PD: I'm from Spain sorry for my lame english xD



--
Posted via http://www.ruby-....

Giles Bowkett

12/12/2006 1:48:00 AM

0

Rethink your design. The proposed architecture is a recipe for failure
at best and a recipe for insanity at worst.

To answer your question, can it be done, God, I don't know and I don't
want to find out. Probably not without significant brain damage.

On 12/9/06, Flaab Mrlinux <flaab_mrlinux@hotmail.com> wrote:
> Good afternoon everyone.
>
> I've been thinking around this for a long time. I want to program a
> Online Estrategy Game (sort of Ogame style) and I just had technical
> problems. But since i learned ruby I think i might just have found the
> solution and i would like to check out your opinions.
>
> My main problem was...Fine, players will have their empire and can do
> certaing things (attacking, organizing their army, creating new fuel
> sources, etc) and those actions change/create lines in the game
> database. That's cool by now and had no problem with it, Php would do
> the trick. But the problem is that the GAME core has to be running and
> executing actions when neccesary. For example; an attack takes some
> hours to arrive the attacked city, and depends of distance, speed of the
> army, etc. Fuel sources creates fuel and arms but also takes some time.
> This is why i need a CORE to be working all the time (or almost).
>
> So this is what i've thought; I'm gonna have a Web Based Php Front-end
> for the players to comunicate with the game. And a Ruby Core program
> sinchronized with Cron to be launched every 3 minutes for example. That
> Core will do all these things i can't do from Php, catching MySql files
> that tells it what to do, do it, and update those MySql fields which may
> need updating.
>
> Can this be done?
>
> Thx
>
> --
> Posted via http://www.ruby-....
>
>


--
Giles Bowkett
http://www.gilesg...
http://gilesbowkett.bl...
http://gilesgoatboy.bl...

Giles Bowkett

12/12/2006 1:52:00 AM

0

You know, I just read my own post and it seems kind of mean, but
honestly, I'm looking out for you. Avoid this method. It is a bad
idea.

On 12/11/06, Giles Bowkett <gilesb@gmail.com> wrote:
> Rethink your design. The proposed architecture is a recipe for failure
> at best and a recipe for insanity at worst.
>
> To answer your question, can it be done, God, I don't know and I don't
> want to find out. Probably not without significant brain damage.
>
> On 12/9/06, Flaab Mrlinux <flaab_mrlinux@hotmail.com> wrote:
> > Good afternoon everyone.
> >
> > I've been thinking around this for a long time. I want to program a
> > Online Estrategy Game (sort of Ogame style) and I just had technical
> > problems. But since i learned ruby I think i might just have found the
> > solution and i would like to check out your opinions.
> >
> > My main problem was...Fine, players will have their empire and can do
> > certaing things (attacking, organizing their army, creating new fuel
> > sources, etc) and those actions change/create lines in the game
> > database. That's cool by now and had no problem with it, Php would do
> > the trick. But the problem is that the GAME core has to be running and
> > executing actions when neccesary. For example; an attack takes some
> > hours to arrive the attacked city, and depends of distance, speed of the
> > army, etc. Fuel sources creates fuel and arms but also takes some time.
> > This is why i need a CORE to be working all the time (or almost).
> >
> > So this is what i've thought; I'm gonna have a Web Based Php Front-end
> > for the players to comunicate with the game. And a Ruby Core program
> > sinchronized with Cron to be launched every 3 minutes for example. That
> > Core will do all these things i can't do from Php, catching MySql files
> > that tells it what to do, do it, and update those MySql fields which may
> > need updating.
> >
> > Can this be done?
> >
> > Thx
> >
> > --
> > Posted via http://www.ruby-....
> >
> >
>
>
> --
> Giles Bowkett
> http://www.gilesg...
> http://gilesbowkett.bl...
> http://gilesgoatboy.bl...
>
>


--
Giles Bowkett
http://www.gilesg...
http://gilesbowkett.bl...
http://gilesgoatboy.bl...

Alex Young

12/12/2006 8:44:00 AM

0

Flaab Mrlinux wrote:
> Jonas Pfenniger wrote:
>
>> If you take the example of Ogame. Imagine you send an attack to planet
>> XY.
>> You don't need to know the result until user A or user B access their
>> profile and see that user A has destroyer all user B's sattelites.
>
> I Jonas. This is not actually true: I'll explain myself. Supposse the
> following:
>
> 1) User A sends an attack to user B, supossed to arrive within 5 hours.
> 2) Then none of A or B users connect again due to whatever.
> 3) Just after those 5 hours passed, an user C sends an attack to user B,
> but user B has already received an attack that hasn't been proccessed
> cause neither the atacker or himself connected again and the user B
> defense forces info is deprecated.
Event-driven would still work here, you'd just need to have a global
event queue rather than a user-specific one. For example, User A sends
an attack to arrive 5 hours hence. This puts an event into the queue.
Then, whenever *anyone* checks their profile (which I assume will be a
regular event), *all* messages left on the queue with an effect time in
the past are processed. This means that, in your example above, User C
logging on to make the attack causes A's attack to be processed and B's
forces to be suitably depleted.

> I was thinking about doing it with Php cause it's my "mother languaje"
> for dynamic web programming, I knew about ruby on rails but i thought it
> was more like a "PhpNuke" or "Mambo" CMS programmed in ruby, or close to
> it.
It's a lower layer than that - more like CakePHP or CodeIgniter (if
you've come across them). You could write a "RailsNuke" or a "Rambo"
with it if you wanted.

> I've read that Rails is much more fast to program dinamic web sites
> but...as far as I know, Php is pretty effective and Rails was something
> fast to do standard web applications but i didn't thought it could do
> the trick for a complicated game web-based interface. Can it really be
> usefull to do this?
Yes.

--
Alex