[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: learning the "Ruby way"

Chad Fowler

11/20/2003 6:29:00 PM

8 Answers

Matthew Berg

11/20/2003 7:26:00 PM

0

On Thu, 2003-11-20 at 13:28, Chad Fowler wrote:
> On Thu, 20 Nov 2003, Mark Wirdnam wrote:
>
> # **Hobby-programmer alarm**
> #
>
> May excellent suggestions have been made, so I won't bore you with my
> attempt. But, I wanted to say, "Welcome Hobby Programmer!"
>
> I'm paid to do IT work, but I have increasingly moved my programming
> activities into the land of hobby-dom, where I tend to enjoy them more. I
> find Ruby to be an *excellent* language for hobbyists (as well as
> enterprise users).
>
> Are there other strict hobbyists on the list?

I'm an administrator rather than a programmer by trade, although as with
any admin job that also entails a fair amount of scripting, and my own
position also includes some C debugging and packaging.

On the other hand I learned Ruby scritly for hobby use, since at work
we're stuck pretty firmly with Perl and POSIX shell. Now I'm spending
what hours I can spare working on Ruby-GNOME2 (mostly docs and bugfixes)
and a little media player which may actually be worth regular end users
looking at some day. ;)

--
Matthew Berg <galt@gothpoodle.com>



Greg McIntyre

11/20/2003 10:05:00 PM

0

Chad Fowler <chad@chadfowler.com> wrote:
> Are there other strict hobbyists on the list?

"Hobbyist"? What happened to "hacker"?

Hopefully I'll graduate in March with a Bachelor of Software
Engineering, however until then you can call me a hobbyist if you must
but I prefer the term hacker because I'm one of those snooty people who
insists on "real" definitions even when the mainstream ones get changed.
:-)

In Ruby I've only written small programs which transform data and
interesting little toy scripts. But I skim this list every day and I
have a vapourware Ruby roguelike game in the works which is fun to
design and code random small bits when I have time away from
assignments, thesis and (hopefully soon) work.

--
Greg McIntyre ======[ greg@puyo.cjb.net ]===[ http://pu... ]===

Zachary P. Landau

11/21/2003 12:57:00 AM

0

> In Ruby I've only written small programs which transform data and
> interesting little toy scripts. But I skim this list every day and I
> have a vapourware Ruby roguelike game in the works which is fun to
> design and code random small bits when I have time away from
> assignments, thesis and (hopefully soon) work.

A roguelike game written in Ruby would be very interesting to see.
Especially if it was easy to add new elements to the game in ruby. If
you ever get something releasable, be sure to let us know.

--
Zachary P. Landau <kapheine@hypa.net>
GPG: gpg --recv-key 0x24E5AD99 | http://kapheine.hypa.net/ka...

Greg McIntyre

11/21/2003 1:33:00 AM

0

"Zachary P. Landau" <kapheine@hypa.net> wrote:
> > In Ruby I've only written small programs which transform data and
> > interesting little toy scripts. But I skim this list every day and I
> > have a vapourware Ruby roguelike game in the works which is fun to
> > design and code random small bits when I have time away from
> > assignments, thesis and (hopefully soon) work.
>
> A roguelike game written in Ruby would be very interesting to see.
> Especially if it was easy to add new elements to the game in ruby. If
> you ever get something releasable, be sure to let us know.

I think Ruby's a great language for it. I chose it because I wanted
others, possibly non-professional programmers, to be able to "write"
for it (create levels, dialogue, etc.). Ruby's so intuitive and
easy that I thought it would be good.

That's why I find the long raging discussion on interfaces interesting
-- novice programmers are going to get things wrong so it'd be nice if I
could make their code adhere to an interface, or at least warn them when
it doesn't. I mucked about with doing this in Ruby 1.8 and ended up with
modules which assert certain methods exist in the classes in which they
are included, at the point of their inclusion. It's a simple and
not-perfect check but it is transparent check from the point of the
"writer" but it does combat forgetfulness.

Here's a taste...

This is a map definition. Do I store it in XML? No. Do I store it as my
own special file format? No. It's in Ruby! Yey! :) Doing this makes map
definitions very flexible (e.g. it could be fully or partially randomly
generated upon definition).

The map definition is a class with a constant for layout and a constant
for a "key" (in the cartography sense). Each tile on the map contains a
bunch of stuff with no certain arrangement (I'm currently unsure if
that's desirable... still thinking about it). Map::inherited is defined
to collect map definitions into a list. I have a demo in which you can
walk around this map, bump into things and set off the trap. Very
simple, but I'm still thinking about the design of the fundamentals, so
I didn't want to get carried away (and because I'm a hobbyist/hacker).

Anyway, I'm posting it because it's a nice example of Ruby's power and
flexibility being used. :)

-------------

class DemoMap < Map

class SpecialTrap
def triggered_by(actor)
end

include Triggerable # asserts triggered_by is defined
end

LAYOUT =<<END_LAYOUT
###########
0...=...t.#
#.........1
#.........####
#............#
####.........#
#.........#
#.........#
###########
END_LAYOUT

KEY = {
'.' => Ground,
'#' => BorderWall,
'=' => [
Ground,
Table,
],
'0' => [
Ground,
Marker.new(0),
Teleport.new(DemoMap, 1),
Door.new(open=true),
],
't' => [
Ground,
SpecialTrap,
],
'1' => [
Ground,
Marker.new(1),
Teleport.new(DemoMap, 0),
Door.new(open=false),
],
}
end

--
Greg McIntyre ======[ greg@puyo.cjb.net ]===[ http://pu... ]===

Tom Copeland

11/21/2003 3:19:00 PM

0

On Thu, 2003-11-20 at 20:37, Greg McIntyre wrote:
<lots of nifty stuff snipped>
> LAYOUT =<<END_LAYOUT
> ###########
> 0...=...t.#
> #.........1
> #.........####
> #............#
> ####.........#
> #.........#
> #.........#
> ###########
> END_LAYOUT

Very cool! I've been poking around the Doom WAD spec a bit, try to see
how feasible it would be to generate new levels with something like:

l = Level.new(10,10)
l.add(Wall.new(0,0,5,5))
l.set_spawn_point(5,0)

and so forth. But this looks like a much nicer way to do it.

Yours,

Tom


Dossy

11/21/2003 5:01:00 PM

0

> On Thu, 2003-11-20 at 20:37, Greg McIntyre wrote:
> <lots of nifty stuff snipped>
> > LAYOUT =<<END_LAYOUT
> > ###########
> > 0...=...t.#
> > #.........1
> > #.........####
> > #............#
> > ####.........#
> > #.........#
> > #.........#
> > ###########
> > END_LAYOUT

Wow, Nethack is being reinvented, again.

-- Dossy

--
Dossy Shiobara mail: dossy@panoptic.com
Panoptic Computer Network web: http://www.pan...
"He realized the fastest way to change is to laugh at your own
folly -- then you can let go and quickly move on." (p. 70)


Greg McIntyre

11/21/2003 10:35:00 PM

0

Dossy <dossy@panoptic.com> wrote:
> Wow, Nethack is being reinvented, again.

Heaven forbid! I hate that game. :-)

--
Greg McIntyre ======[ greg@puyo.cjb.net ]===[ http://pu... ]===

Martin DeMello

11/22/2003 7:34:00 AM

0

Dossy <dossy@panoptic.com> wrote:
>> On Thu, 2003-11-20 at 20:37, Greg McIntyre wrote:
>> <lots of nifty stuff snipped>
>> > LAYOUT =<<END_LAYOUT
>> > ###########
>> > 0...=...t.#
>> > #.........1
>> > #.........####
>> > #............#
>> > ####.........#
>> > #.........#
>> > #.........#
>> > ###########
>> > END_LAYOUT
>
> Wow, Nethack is being reinvented, again.

He did say it was a roguelike.

martin