Generating a DLL file?

Let’s start with:
I have no clue what a DLL is.

Let’s add:
I also do not know C or C++.

I want to write a program in Ruby, and ‘compile’ it to a DLL.

:slight_smile: Have I asked for the impossible?

It’s for Half-Life, the game…

I guess HL is a collection of DLL files that communicate,
and any Artificial Intelligence (bot) that has been written for
HL or CS has to be a DLL.

I figure there isn’t anything out there that’s easy to use…
http://raa.ruby-lang.org/search.rhtml?search=DLL doesn’t
really return what I’m looking for… (unless I’m looking in the
wrong spot)

… and since DLLs (I assume) are normally
done with C or C++, and since Ruby is written in C…

… I’m hoping it’s not too much to ask for. :slight_smile:

Where can I start?

-Rich

Let’s start with:

I have no clue what a DLL is.
[snip]
I want to write a program in Ruby, and ‘compile’ it to a DLL.

Well… if you don’t know what a DLL is, how do you you want one? :slight_smile:
A DLL is a “Dynamic Link Library”. Their purpose is to be called by
other programs. For instance, the Gtk grahics toolkit is a DLL (windows
version).

:-) Have I asked for the impossible?

What you are asking is not “impossible”, but it stretches the limits of
current feasibility I think. DLLs are generally made with C or C++.
I don’t know of any Ruby compiler that will give you a DLL, only of one
that will give you an executable.

It’s for Half-Life, the game…
I guess HL is a collection of DLL files that communicate,
and any Artificial Intelligence (bot) that has been written for
HL or CS has to be a DLL.

Any program, including HL, consists of an executable which possibly calls
one or more DLLs for certain tasks. I expect that something as large as
HL has a very large number of DLLs.

I’m confused. Why do you want to make a DLL out of a Ruby program again?

In Ruby you’d generally make a library, and ‘require’ it in the Ruby
program that you are actually interested in.

… and since DLLs (I assume) are normally
done with C or C++, and since Ruby is written in C…

… I’m hoping it’s not too much to ask for. :slight_smile:

Where can I start?

First, I need to understand better what it is you intend to do.
What makes you think that you want to make a DLL? How does that relate
Half-Life?

Best,

···

On Mon, Apr 28, 2003 at 08:45:19AM +0900, Rich wrote:

Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

Arg! HTML E-mail! :frowning:

Response inline …

···

-----Original Message-----
From: Rich [mailto:rich@lithinos.com]
Sent: Sunday, April 27, 2003 4:45 PM
To: ruby-talk ML
Subject: Generating a DLL file?

I guess HL is a collection of DLL files that communicate,
and any Artificial Intelligence (bot) that has been written for
HL or CS has to be a DLL.

As Danel has pointed out, DLLs are dynamically loaded binary objects.
Ruby does not compile down to native code, so writting a DLL in Ruby
is unlikely. However, you might be able to go halfway with C or some
other
langauge and create a delegate DLL that exposes the HL API, but loads and
executes Ruby code out the back using RubyCOM.
http://www.geocities.com/masonralph/rubycomdoc.html

James

Well… if you don’t know what a DLL is, how do you you want one? :slight_smile:

“I felt that it should be possible to create a DLL that sits between the
Half-Life engine and the MOD and pass function calls from one to the other.”
(Quote taken from Botmans HPB_bot_src_2_1 found at:
GameSpy: PC Games, Reviews, News, Previews, Demos, Mods & Patches)
(Botman is considered one of the founding ‘bot’ creators for HL)

In the end that’s how he does it - with a DLL.

I’m confused. Why do you want to make a DLL out of a Ruby program again?

I don’t want to learn C.
I know enough of OCaml, but there isn’t great support for DLL generation.
(I might have missed what little exists)
I love Ruby.
I want to create a Bot.
I thought I’d try to bring the two together… oh well, no worries! :slight_smile:

What makes you think that you want to make a DLL? How does that relate
Half-Life?

See previous question… and add that if it were known that a bot was
written in Ruby…
… and the bot were written for HL/CS… (CS has more servers running than
all of the
other online FPS games combined … )

I’m just trying to spread the good word and have some fun at the same time!
:slight_smile:

No worries if I can’t do it - I just thought I’d ask.

Thanks anyway!

-Rich

I would probably understand your responses better if I know what a “bot”
is. Also, what is a MOD?

···

On Mon, Apr 28, 2003 at 10:31:19AM +0900, Rich wrote:

Well… if you don’t know what a DLL is, how do you you want one? :slight_smile:

“I felt that it should be possible to create a DLL that sits between the
Half-Life engine and the MOD and pass function calls from one to the other.”
(Quote taken from Botmans HPB_bot_src_2_1 found at:
GameSpy: PC Games, Reviews, News, Previews, Demos, Mods & Patches)
(Botman is considered one of the founding ‘bot’ creators for HL)

In the end that’s how he does it - with a DLL.

I’m confused. Why do you want to make a DLL out of a Ruby program again?

I don’t want to learn C.
I know enough of OCaml, but there isn’t great support for DLL generation.
(I might have missed what little exists)
I love Ruby.
I want to create a Bot.
I thought I’d try to bring the two together… oh well, no worries! :slight_smile:

What makes you think that you want to make a DLL? How does that relate
Half-Life?

See previous question… and add that if it were known that a bot was
written in Ruby…
… and the bot were written for HL/CS… (CS has more servers running than
all of the
other online FPS games combined … )

I’m just trying to spread the good word and have some fun at the same time!
:slight_smile:

No worries if I can’t do it - I just thought I’d ask.

Thanks anyway!

-Rich


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

This sounds like you want to embed the ruby interpreter into a c++
program.
I am working on at tutorial about embedding:
http://metaeditor.sf.net/embed/

This should hopefully get you started :slight_smile:

···

On Mon, 28 Apr 2003 11:31:19 +0900, Rich wrote:

Well… if you don’t know what a DLL is, how do you you want one? :slight_smile:

“I felt that it should be possible to create a DLL that sits between the
Half-Life engine and the MOD and pass function calls from one to the other.”
(Quote taken from Botmans HPB_bot_src_2_1 found at:
GameSpy: PC Games, Reviews, News, Previews, Demos, Mods & Patches)
(Botman is considered one of the founding ‘bot’ creators for HL)

In the end that’s how he does it - with a DLL.


Simon Strandgaard

I would probably understand your responses better if I know what a “bot”
is. Also, what is a MOD?

The way the game half-life works (and several other Quake derivatives) is
that there is a somewhat brainless rendering engine which makes calls out to
a separate DLL (or set of DLLs) which handle all of the game logic. The
rendering engine is essentially just a view, with the “game rules” living in
this DLL. Under the covers, it’s a client server architecture, with a good
amount of separation between these two layers.

So, all of the code for monsters, weapon logic, “AI” opponents, etc. are in
this DLL. There is generally one main exposed function in the DLL that is
used to invoke game logic.

A bot is an artificially intelligent opponent that is programmed and
compiled into this DLL. It usually would behave like a human player in a
multiplayer game.

If you wanted to write this in Ruby, you have a couple of possibilities:

  1. You could make a C wrapper for the DLL’s main entry point as well as the
    callbacks to the rendering engine. After that, you would need to port all
    of the existing essential game logic to Ruby from C.

  2. You could create a wrapper for the bare minimum you need for your
    modification, which would mean you would have to load your external ruby
    script and provide any necessary callback functions. This is probably the
    path of least resistance.

Ultimately, though, you’re going to need to learn how to program in C to do
this. It can’t be avoided.

Chad

Well… if you don’t know what a DLL is, how do you you want one? :slight_smile:

“I felt that it should be possible to create a DLL that sits between the
Half-Life engine and the MOD and pass function calls from one to the
other.”
(Quote taken from Botmans HPB_bot_src_2_1 found at:
GameSpy: PC Games, Reviews, News, Previews, Demos, Mods & Patches)
(Botman is considered one of the founding ‘bot’ creators for HL)

In the end that’s how he does it - with a DLL.

I’m confused. Why do you want to make a DLL out of a Ruby program
again?

I don’t want to learn C.
I know enough of OCaml, but there isn’t great support for DLL
generation.
(I might have missed what little exists)
I love Ruby.
I want to create a Bot.
I thought I’d try to bring the two together… oh well, no worries! :slight_smile:

What makes you think that you want to make a DLL? How does that
relate
Half-Life?

See previous question… and add that if it were known that a bot was
written in Ruby…
… and the bot were written for HL/CS… (CS has more servers running
than
all of the
other online FPS games combined … )

I’m just trying to spread the good word and have some fun at the same
time!

···

----- Original Message -----
From: “Daniel Carrera” dcarrera@math.umd.edu
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, April 28, 2003 7:05 AM
Subject: Re: Generating a DLL file?

On Mon, Apr 28, 2003 at 10:31:19AM +0900, Rich wrote:

:slight_smile:

No worries if I can’t do it - I just thought I’d ask.

Thanks anyway!

-Rich


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

I don’t know C - or C++… and I’d rather not learn.

-Rich

···

----- Original Message -----
From: “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com

This sounds like you want to embed the ruby interpreter into a c++
program.
I am working on at tutorial about embedding:
ruby embedded into c++

This should hopefully get you started :slight_smile:


Simon Strandgaard

Perfect response. Thanks Chad!

If it can’t be done - it can’t be done. Oh well. Next…

Though I still wish it could all be done in Ruby… :slight_smile:

-Rich

···

----- Original Message -----
From: “Chad Fowler” chadfowler@chadfowler.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Sunday, April 27, 2003 8:01 PM
Subject: Re: Generating a DLL file?

----- Original Message -----
From: “Daniel Carrera” dcarrera@math.umd.edu
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, April 28, 2003 7:05 AM
Subject: Re: Generating a DLL file?

I would probably understand your responses better if I know what a “bot”
is. Also, what is a MOD?

The way the game half-life works (and several other Quake derivatives) is
that there is a somewhat brainless rendering engine which makes calls out
to
a separate DLL (or set of DLLs) which handle all of the game logic. The
rendering engine is essentially just a view, with the “game rules” living
in
this DLL. Under the covers, it’s a client server architecture, with a
good
amount of separation between these two layers.

So, all of the code for monsters, weapon logic, “AI” opponents, etc. are
in
this DLL. There is generally one main exposed function in the DLL that is
used to invoke game logic.

A bot is an artificially intelligent opponent that is programmed and
compiled into this DLL. It usually would behave like a human player in a
multiplayer game.

If you wanted to write this in Ruby, you have a couple of possibilities:

  1. You could make a C wrapper for the DLL’s main entry point as well as
    the
    callbacks to the rendering engine. After that, you would need to port all
    of the existing essential game logic to Ruby from C.

  2. You could create a wrapper for the bare minimum you need for your
    modification, which would mean you would have to load your external ruby
    script and provide any necessary callback functions. This is probably the
    path of least resistance.

Ultimately, though, you’re going to need to learn how to program in C to
do
this. It can’t be avoided.

Chad

So, the bottom line is that you’re not going to be able to do what you want.

Chad

···

----- Original Message -----
From: “Rich” rich@lithinos.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, April 28, 2003 8:01 AM
Subject: Re: Generating a DLL file?

I don’t know C - or C++… and I’d rather not learn.

-Rich

----- Original Message -----
From: “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com

This sounds like you want to embed the ruby interpreter into a c++
program.
I am working on at tutorial about embedding:
ruby embedded into c++

This should hopefully get you started :slight_smile:


Simon Strandgaard

As a professional programmer, I’ll never understand this sort of
sentiment, but I realize everyone isn’t me.

···

— Rich rich@lithinos.com wrote:

I don’t know C - or C++… and I’d rather not learn.


Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

Yes C/C++ is a bastard language, but unfortunatly unavoidable :slight_smile:

···

On Mon, 28 Apr 2003 12:31:14 +0900, Rich wrote:

I don’t know C - or C++… and I’d rather not learn.


Simon Strandgaard

:slight_smile: I see both sides. I’m always eager to learn
new things (though there’s only so much time
for that).

But C isn’t a new thing, if you know what I mean.
It’s almost an investment in the past.

If I hadn’t learned it twenty years ago, I would
probably still learn it today. But I would
hesitate.

Reminds me of when Y2K was (thought to be) looming
and everyone was polishing their COBOL.

I think the main use of C today (besides legacy
code) is as a “universal assembly language.”

Ruby spoils us, doesn’t it? But in a good way.

Hal

···

----- Original Message -----
From: “Michael Campbell” michael_s_campbell@yahoo.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Sunday, April 27, 2003 9:48 PM
Subject: Re: Generating a DLL file?

— Rich rich@lithinos.com wrote:

I don’t know C - or C++… and I’d rather not learn.

As a professional programmer, I’ll never understand this sort of
sentiment, but I realize everyone isn’t me.

Rich wrote:

Though I still wish it could all be done in Ruby… :slight_smile:

Even if you could get it all to hang together with a Ruby interface (as
Chad outlined in his response), there’s a good chance that the overhead
of going through the Ruby interpreter (i.e. to process your bot’s logic)
would make it too slow to keep up. Don’t know how frequently the game
engine makes calls out to the bot(s), but I’m assuming it’s done almost
continuously and you need the kind of speed that only straight C/C++
would provide.

It’s easy to understand…

I started as a professional web programmer.

Perl, PHP, CF, SQL, JS, AS, Ruby, XSL…

I’ve been able to do everything I’ve needed (read ‘make money’) without
C/Java - so why suffer needlessly? :slight_smile:

The only ‘hard’ language I’ve bothered investing time in was/is OCaml.
It has the best of everything - but a painfully steep learning curve.
(javascript → lambda calculus == 3 months of just re-reading the
explanations)

-Rich

···

----- Original Message -----
From: “Michael Campbell” michael_s_campbell@yahoo.com

— Rich rich@lithinos.com wrote:

I don’t know C - or C++… and I’d rather not learn.

As a professional programmer, I’ll never understand this sort of
sentiment, but I realize everyone isn’t me.

C is a perfectly good assembly language, and moderately portable. In fact if
you miss machine code that much, you can write

register int a;
#define CLRA (a=0)
#define LDAA(x) (a=(x))
#define STAA(x) (
(x)=a)
#define HALT (exit(0))
/* etc */

But I agree that C++ is a bastard language :slight_smile:

Regards,

Brian.

···

On Mon, Apr 28, 2003 at 12:18:19PM +0900, Simon Strandgaard wrote:

On Mon, 28 Apr 2003 12:31:14 +0900, Rich wrote:

I don’t know C - or C++… and I’d rather not learn.

Yes C/C++ is a bastard language, but unfortunatly unavoidable :slight_smile:

I don’t know C - or C++… and I’d rather not learn.

As a professional programmer, I’ll never understand this sort of
sentiment, but I realize everyone isn’t me.

It’s easy to understand…

For you. =)

I’ve been able to do everything I’ve needed (read ‘make money’) without
C/Java - so why suffer needlessly? :slight_smile:

maybe that’s where we differ; I don’t consider learning different languages
“suffering”. As Hal pointed out, learning C now might be an investment in the
past, and yet, people still do, and want to, learn lisp! Why? Certainly not
for its commercial value. No, it’s because learning it can teach you things
about your current language; new paradigms, etc.

Can C do that? Dunno, I learned it almost 20 years ago and C++ just over 10 and
use neither today. Would I take it up today? Probably; I learned a lot about
compilers doing so, how to debug, how the computer “thinks” about things, etc.

I’ve been able to do everything I’ve needed (read ‘make money’) without
C/Java - so why suffer needlessly? :slight_smile:

Weird to lump C and Java together.

C is a good counterpart to Ruby, for all those things Ruby can’t yet do, or do fast
enough.

James

C and Java are statically typed languages. That’s all.

I don’t know a single statically typed language.

I better say - manually statically typed language, since OCaml is typed
inferred.

-Rich

···

----- Original Message -----
From: james_b@neurogami.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, April 28, 2003 8:45 AM
Subject: Re: Why I haven’t learned (and don’t really want to learn) C/C++
(was: Re: Generating a DLL file?)

I’ve been able to do everything I’ve needed (read ‘make money’) without
C/Java - so why suffer needlessly? :slight_smile:

Weird to lump C and Java together.

C is a good counterpart to Ruby, for all those things Ruby can’t yet do,
or do fast
enough.

James

james_b@neurogami.com wrote:

C is a good counterpart to Ruby, for all those things Ruby can’t yet do, or do fast
enough.

For example - running Ruby programs. :slight_smile:

Stephan