[#401849] If statement — Masoud Ahmadi <lists@...>

Will anyone be able to point out what I am doing wrong.

15 messages 2012/12/02

[#401987] Trying to get "translator" to work — JD KF <lists@...>

So, basically, I'm trying to get the below code to work properly for

12 messages 2012/12/06

[#402012] Need help to select some listbox item in different listbox together — Jonathan Masato <lists@...>

Hello,

10 messages 2012/12/07

[#402045] if n belongs to set a and m belongs to set b repeat some steps, How? — "zubair a." <lists@...>

We can do so in java and similar languages like:

11 messages 2012/12/08

[#402078] Time.new(2001, 12, 3).to_i returns wrong value — Robert Buck <lists@...>

I am doing something that not many do, I am writing a database driver

9 messages 2012/12/09

[#402145] How I can create/extract a variable/hash into the current binding in Ruby? — Ramon de C Valle <rcvalle@...>

Hi,

12 messages 2012/12/12

[#402205] Wondering About Flatiron School — "Kevin Y." <lists@...>

Hi everyone!,

35 messages 2012/12/15
[#402207] Re: Wondering About Flatiron School — Chad Perrin <code@...> 2012/12/15

On Sat, Dec 15, 2012 at 11:51:08AM +0900, Kevin Y. wrote:

[#402214] Ruby quick reference arranged in ASCII sequence? — Old Grantonian <lists@...>

As a ruby beginner, I would be grateful for any links to a ruby

17 messages 2012/12/15

[#402226] print - and strip text between tags using Nokogiri — Paul Mena <lists@...>

I'm a Ruby Newbie trying to write a program to process thousands of HTML

13 messages 2012/12/15

[#402332] Perl to Ruby: regex captures to assignment. — "Derrick B." <lists@...>

Hello all,

37 messages 2012/12/19
[#402342] Re: Perl to Ruby: regex captures to assignment. — "Derrick B." <lists@...> 2012/12/20

First of all, thanks for the fast responses!

[#402352] Re: Perl to Ruby: regex captures to assignment. — Robert Klemme <shortcutter@...> 2012/12/20

On Thu, Dec 20, 2012 at 1:38 AM, Derrick B. <lists@ruby-forum.com> wrote:

[#402357] Re: Perl to Ruby: regex captures to assignment. — "Derrick B." <lists@...> 2012/12/20

Robert Klemme wrote in post #1089733:

[#402359] trying to strip characters from a line — Paul Mena <lists@...>

I'm reading a table from a MySQL database and then processing it row by

18 messages 2012/12/20

[#402394] simple division: -9 / 5 = -2 what? — "Derrick B." <lists@...>

$ irb

13 messages 2012/12/22

[#402412] POLS and string-handling — Paul Magnussen <lists@...>

Hi,

14 messages 2012/12/22

[#402460] "Open" dialog of Windows — "Damián M. González" <lists@...>

Hi guys, been researching about pop up the "open" file dialog of

11 messages 2012/12/24

[#402466] How do I install Ruby on my Ubuntu 12.10 partition. — Kaye Ng <lists@...>

I already have Ruby installed on my Windows 7 partition.

23 messages 2012/12/25

[#402510] Ruby Association Certified Ruby Programmer — Sean Westfall <lists@...>

How well respected is this certification in the industry: Ruby

27 messages 2012/12/27
[#402528] Re: Ruby Association Certified Ruby Programmer — Peter Hickman <peterhickman386@...> 2012/12/27

On 27 December 2012 01:28, Sean Westfall <lists@ruby-forum.com> wrote:

[#402555] numeric? — Brandon Weaver <keystonelemur@...>

I've found a bit of an annoyance trying to find out if a number is numeric

20 messages 2012/12/27

[#402580] Ruby Koans regarding Hashes. — "Derrick B." <lists@...>

I am trying to understand this, so let me know how I do. :) I know

18 messages 2012/12/28

[#402609] can't open new ruby program under "new" context menu — "Lee V." <lists@...>

I'm stuck on the new version at trying to do something very simple.

10 messages 2012/12/28

[#402642] require "test/unit" — "Mattias A." <lists@...>

Hi,

17 messages 2012/12/29
[#402667] Re: require "test/unit" — "Mattias A." <lists@...> 2012/12/31

Hi Dami=C3=A1n M. Gonz=C3=A1lez!

[#402747] Re: require "test/unit" — "Derrick B." <lists@...> 2013/01/04

Mattias A. wrote in post #1090700:

[#402749] Re: require "test/unit" — sto.mar@... 2013/01/04

Am 04.01.2013 19:48, schrieb Derrick B.:

Ruby game server woes

From: Na Na <lists@...>
Date: 2012-12-23 23:45:33 UTC
List: ruby-talk #402440
Hi,

The following is a bit of a brain dump, as I'm thinking about things I
just don't have enough knowledge to think about clearly.  I'm hoping in
the mess someone might have some insights that will help me.  I've been
reading and thinking and researching for the last couple of days to work
out what I should do.  I had an idea to make a game (client/server
model, small number of players at a time - 4 usually, 20 at most), and I
thought I would use ruby for the game server.  My thinking was, I can
develop quickly with ruby, and where I need speed I can write a c
extension.  Best of both worlds, and I'll be able to make something in a
much shorter amount of time!

To make matters slower, I'm using javascript+html5's canvas for the
client.  It's a bit slow, but there's plenty of optimisations I have not
yet made that will ease the burden, so I'm not stressed there.

To communicate between server and client I'm using websockets.  To
implement that on the ruby side, I'm using eventmachine (em) with
em-websocket.  That has been working fine, until recently - now, I need
more control over how cpu time is allocated between server game loop and
network.  As I understand it, em loops itself repeatedly to check for
new messages, and then act on those messages.  To get a game loop
running, I put in a periodic timer so that it would call the main game
loop repeatedly.  However, this design is inefficient.  I am noticing
wasted cpu cycles that I want to make use of.  Network traffic is low,
so it would suit me much better if I were to have the main game loop
occasionally check for new network packets, rather than the other way.
So that's fine, I expect with more work I can ditch em and implement
something myself.

The problem is, I'm now having second thoughts about ruby.  I thought
I'd come here to get some second thoughts, and maybe to help me with
information I don't have.  Grouped, my thoughts are (in no particular
order):

* Javascript - Looking at this chart
(http://benchmarksgame.alioth.debian.org/u32/benchmark.php) javascript
v8 runs a lot faster.  That leaves me wondering if I should have gone
with nodejs in the end.  I am not at all eager on the idea of using
javascript where I don't need to.  However, one advantage is I could put
some server code into the client for predictive behaviour to reduce
network traffic.  That would be a nice advantage, but not critical for
my project.  I know benchmarks should be taken with a grain of salt, but
the speed different is quite large.  And then it leaves me wondering,
should I just bite the bullet and rewrite the server in c/c++?  And then
I think, why not just use c extensions in ruby?  And then I wonder if c
extensions in ruby will be much slower than a raw c app, and then I'm
left at the limits of my experience and knowledge!

* fibers - Doing some experimenting, I haven't found a way to put the EM
loop into a fiber.  I had thought perhaps I could have the game loop as
the main part of the program, and have it occasionally resume the EM
fiber, which would then yield back to the main game loop after checking
for new messages.  Trouble is, this didn't quite work - that is, I'd
create the fiber enclosing the em loop and assign it to a variable, but
the variable would be nil, leaving me to suspect some code in EM itself
was destroying the fiber.  Maybe I need to look back into this.

* processes - is there a way to create a new process of a separate ruby
app, and communicate via those processes in an efficient way (ie, not
just through writing to disk and reading from disk, or a shared sql
database)?  If so, I could run EM in one process, and have it
communicate back information to the main ruby app.  I'm not aware of a
way to do this, though.  Threads are an obvious choice, but I'm using
MRI ruby, and it seems that the game ends up with the same speed issues
using threads.  If there's a way to launch a unique process and have
them communicate, then I can also take advantage of multiple cores.

So essentially, my question is this - given all these streams of
thoughts, are there any insights you can give me on how to approach
this?  I lack enough knowledge to make an informed choice.

Thanks for your time!

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

In This Thread

Prev Next