Perl roguelike coming along

G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Hey, remember me? I'm building a roguelike in Perl. It might end up
being more of an Engine that's re-usable for all of my future ideas and
others', but not data-driven or even script-driven. Mainly I get some of
the tougher (and most fun) tasks out of the way that mostly every
roguelike uses.

Anyway, it's coming along. Rendering and scrolling works well (It's
curses-only right now, but I've modularized the interface system for any
ideas I may or may not get in the future.) and I'm working on map
generation. That's also coming along very nicely. I have this powerful
routine called connect that takes in a figure (room, hall, anything), an
ID of an existing room on an existing map, and the walls to match up,
and it connects it, doors and all. It mostly works and where it fails,
it's not that major. I'll probably work on generation a bit more and
then slowly add in items and monsters.

The main problem right now is speed, actually. Starting up on my AMD K6
500Mhz, 128MB RAM box (My only box.) takes anywhere from 12 to 20
seconds. After that, things are OK. Now games like crawl, nethack, tome,
angband, etc barely take a second. I know that they're compiled and I'm
using Perl and I understand that I need to identify bottlenecks and all
that. I will, in time. But are there any other magic tricks anybody
knows of to help?

Unfortunately my webhost has gone down for a while and I can't really
use dialup to host anything, not because of speed (or lack thereof), but
because I can't tie up the phone line. So there's no decent way to get
the code out there. I'm currently trying to find a place to stash a
tar.gz, so I'll have that out soonish. And maps are tough to convert
into a newsgroup-friendly format.

This isn't really on-topic with the topic or anything, but I brainstorm
a lot about making standard adventure games in a roguelike format.
Imagine playing the original Adventure or Zork (I think that's been
done, actually) with a roguelike rendering. Most of everything would
remain the same, there'd still be the breathtaking descriptions and
nethack-style extended commands (normal IF commands), but with a
roguelike rendering. It may seem like there's no point to it, but it was
just an idea. But what would be wrong with a typical adventure game with
some roguelike elements? Of course combat couldn't be the main thing. I
saw several topics here on this recently, but none really gave me any
good ideas. I'm just bringing up the fact that I'll try and keep my
roguelike engine away from being tied down to one combat style.

If anybody's really interested in this project, I'd love to hear ideas
and/or code. I'm not to comfortable with CVS and all the fancy software
management stuff, but I'd love to have a partner or something.

Though I've probably brought this up previously, are there other
downsides to using Perl besides speed? And the excuses that it isn't a
neat language aren't worthy of reply. Who can say this isn't beautiful?

$original->fill
(
from => [$data->{Ewall}[0]{Y1} + 1, $data->{Ewall}[0]{X}],
to => [$data->{Ewall}[0]{Y2} - 1,
$data->{Ewall}[0]{X} + 1],
with => "."
);
# You'd have to be totally sane to call this line noise. And nobody is
# that sane.

Bye.

P.S. If there's one thing I've learned so far, it's that design
documents aren't good till later. Brainstorms help all throughout a
project, but really, the best way (for me at least) is to just code,
then go back and think about better ways.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Da-Breegster <dabreegster@gmail.com> writes:

> using Perl and I understand that I need to identify bottlenecks and all
> that. I will, in time. But are there any other magic tricks anybody
> knows of to help?

Devel::DProf will help identify the bottlnecks.

> Though I've probably brought this up previously, are there other
> downsides to using Perl besides speed?

You can't really hide your source code; at most you can obfuscate it a bit.
That can make it hard to sell your game. Of course, if you're open sourcing
your game anyway, that's not a problem.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Da-Breegster <dabreegster@gmail.com> writes:

> Hide source code!? Why would I want to do such a thing?

Who cares? The point was, *if* you wanted to do so, for whatever reason, it
would be difficult to hide Perl code.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On 2005-08-24, Sherm Pendley <sherm@dot-app.org> wrote:
> Da-Breegster <dabreegster@gmail.com> writes:
>
>> using Perl and I understand that I need to identify bottlenecks and all
>> that. I will, in time. But are there any other magic tricks anybody
>> knows of to help?
>
> Devel::DProf will help identify the bottlnecks.
>
Yeah, I think that's one of the 'easy' ones.

>> Though I've probably brought this up previously, are there other
>> downsides to using Perl besides speed?
>
> You can't really hide your source code; at most you can obfuscate it a bit.
> That can make it hard to sell your game. Of course, if you're open sourcing
> your game anyway, that's not a problem.
>
> sherm--
>

Hide source code!? Why would I want to do such a thing? My project is
meant to be modified in any way anybody likes. And it's only as
obfuscated as it is naturally, which should be enough. Besides, the source
to games like crawl is available. It might not be easy to cheat by source
hacking, but it's do-able. I know Perl is much easier to modify on the spot.
But if somebody wants to cheat, that's their problem. And of course I'm
releasing it under the GPL. I don't plan on trying to make any money of
it.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

"Da-Breegster" <dabreegster@gmail.com> schrieb im Newsbeitrag
news:slrndgpmdo.44v.dabreegster@localhost.localdomain...
[snip]
> Though I've probably brought this up previously, are there other
> downsides to using Perl besides speed?

Games distributed as scripts that require a special runtime enviroment are a
nightmare from a players point-of-view.
Do you honestly expect players to install a language interpreter (+ your
favorite extension modules if you're really hardcore) just to test your RL?!
Use scripting languages the way they are supposed to be used. Writing
performance-critical engine parts in them is a bad idea. And the interpreter
should be compiled into your engine which avoids those nasty distribution
problems.

copx
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

"copx" <invalid@invalid.com> writes:

> I know that you can do that with almost every scripting language outthere.
> It's not rocket science you know.

Of course I know that. *You* said packaging was a problem, not me.

You're starting to sound a lot like Neo, bitching and moaning about everything
in sight. I'm not biting this time.

*PLONK*

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On 2005-08-24, copx <invalid@invalid.com> wrote:
>
> "Da-Breegster" <dabreegster@gmail.com> schrieb im Newsbeitrag
> news:slrndgpmdo.44v.dabreegster@localhost.localdomain...
> [snip]
>> Though I've probably brought this up previously, are there other
>> downsides to using Perl besides speed?
>
> Games distributed as scripts that require a special runtime enviroment are a
> nightmare from a players point-of-view.
> Do you honestly expect players to install a language interpreter (+ your
> favorite extension modules if you're really hardcore) just to test your RL?!
> Use scripting languages the way they are supposed to be used. Writing
> performance-critical engine parts in them is a bad idea. And the interpreter
> should be compiled into your engine which avoids those nasty distribution
> problems.
>
> copx
>
>

Distribution will be a problem, but not for now. This project is purely
for fun of course, so people who want to play might have to go a little
further. I'm not using many external modules at all so far. I dunno how
it'll work out on Windows, but on Unix, as long as the player has got
ncurses and perl going, it'll work fine. There are ways to bundle up the
interpreter and source into a binary, I think. It's an issue for later.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

"copx" <invalid@invalid.com> writes:

> Games distributed as scripts that require a special runtime enviroment are a
> nightmare from a players point-of-view.

That depends a *lot* on your target audience. If you're targeting *nix users,
it's fairly safe to assume Perl is already installed, although you'll need to
test your code thoroughly to ensure that it works against multiple versions.

Exe's can be rolled for Windows to create a standalone package that includes
the interpreter. ActiveState <http://activestate.com> makes a utility for
creating such packages. Standalone Mac OS X apps can be created using Drop-
Script, or with CamelBones.

*You* may not know how to package and distribute a Perl app, but that doesn't
mean it can't be done. Not only is it possible to do, it doesn't take a lot of
effort to learn how.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Sherm Pendley wrote:
> "copx" <invalid@invalid.com> writes:
>
>
>>I know that you can do that with almost every scripting language outthere.
>>It's not rocket science you know.
>
>
> Of course I know that. *You* said packaging was a problem, not me.
>
> You're starting to sound a lot like Neo, bitching and moaning about everything
> in sight. I'm not biting this time.
>
> *PLONK*

Out of curiousity, anyone here know what happened to Neo? I haven't
seen any sign of him here for ages. It feels weird, to have a
newsgroup as peaceful as this one is now. ;-)


--
My projects are currently on hold, but I do have
some junk at the site below.

http://www.freewebs.com/timsrl/index.htm

--
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

"Sherm Pendley" <sherm@dot-app.org> schrieb im Newsbeitrag
news:m2vf1v9d38.fsf@Sherm-Pendleys-Computer.local...
> *You* may not know how to package and distribute a Perl app, but that
> doesn't
> mean it can't be done. Not only is it possible to do, it doesn't take a
> lot of
> effort to learn how.

I know that you can do that with almost every scripting language outthere.
It's not rocket science you know.
However this doesn't solve any performance problems and most developers who
write their entire game in a scripting language can't seem to be bothered to
make binary stand-alone releases. So I assumed that he planned to toss a
bunch of scripts at us just like his colleagues.

copx
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Elethiomel <kkkk@lllllll.mmmm> writes:

> Sherm Pendley wrote:
>> Da-Breegster <dabreegster@gmail.com> writes:
>>
>>>I'm not using many external modules at all so far.
>> Curses is not a core module.
>
> Which is the distinction between "not using many external modules at
> all" and "not using any external modules at all".

The "m" that I failed to notice. :)

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

"Timothy Pruett" <drakalor.tourist@gmail.com> schrieb im Newsbeitrag
news:D_8Pe.11680$1g2.6212@fe05.lga...
[snip]
> Out of curiousity, anyone here know what happened to Neo?

If you mention his name too often he might come back so please be quiet!
I think he married Volourn (
http://www.rpgcodex.com/phpBB/viewforum.php?f=17 ) and they moved to
Montana.

copx
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

copx wrote:
> "Timothy Pruett" <drakalor.tourist@gmail.com> schrieb im Newsbeitrag
> news:D_8Pe.11680$1g2.6212@fe05.lga...
> [snip]
>
>>Out of curiousity, anyone here know what happened to Neo?
>
>
> If you mention his name too often he might come back so please be quiet!
> I think he married Volourn (
> http://www.rpgcodex.com/phpBB/viewforum.php?f=17 ) and they moved to
> Montana.

They must make a cute couple.


--
My projects are currently on hold, but I do have
some junk at the site below.

http://www.freewebs.com/timsrl/index.htm

--
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Sherm Pendley wrote:
> Da-Breegster <dabreegster@gmail.com> writes:
>
>
>>I'm not using many external modules at all so far.
>
>
> Curses is not a core module.

Which is the distinction between "not using many external modules at
all" and "not using any external modules at all". One can not *at all*
be said to be "many". Two might.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

At Wed, 24 Aug 2005 20:28:00 GMT,
Da-Breegster wrote:

> Though I've probably brought this up previously, are there other
> downsides to using Perl besides speed? And the excuses that it isn't a
> neat language aren't worthy of reply. Who can say this isn't beautiful?

I guess it's too late to back up out of this for you, so what good can
such a question bring besides a flame war?

> $original->fill
> (
> from => [$data->{Ewall}[0]{Y1} + 1, $data->{Ewall}[0]{X}],
> to => [$data->{Ewall}[0]{Y2} - 1,
> $data->{Ewall}[0]{X} + 1],
> with => "."
> );
> # You'd have to be totally sane to call this line noise. And nobody is
> # that sane.

I really don't like the way you use complicated data structures in Perl,
but that's probably fine for an awk replacement ;)

--
Radomir `The Sheep' Dopieralski @**@_
(Xx) 3 ...
. . . ..v.vVvVVvVvv.v.. .
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

"Filip Dreger" <fdreger@amiga.pl> writes:

> I would not be so sure, you seem to have forgotten that Perl is
> interpreted rather than compiled :)

Sort of. It's compiled into bytecode, which is then run in a VM.

> "CreatureName" is a string

Not at runtime. Perl has real constants; their value is calculated at
compile time and used just like a literal value would be.

In other words, these two code snippets both compile down to the same
bytecode:

use constant CreatureName => 0;
my $name = $foo[CreatureName];

my $name = $foo[0];

> BTW: hash look-ups are not so costly, actually in many interpreted
> languages they are usually faster than any complex syntax that could
> be used to avoid them.

That's usually the case with Perl. You spend more cycles avoiding the
hash lookups that you would have by simply doing them.

In this particular instance though, based on the small bit of code I've
seen here, I don't think using an array and constant indexes would make
a substantial difference in syntax, just []s instead of {}s.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On 2005-08-25, Radomir 'The Sheep' Dopieralski <thesheep@sheep.prv.pl> wrote:
> At Wed, 24 Aug 2005 20:28:00 GMT,
> Da-Breegster wrote:
>
>> Though I've probably brought this up previously, are there other
>> downsides to using Perl besides speed? And the excuses that it isn't a
>> neat language aren't worthy of reply. Who can say this isn't beautiful?
>
> I guess it's too late to back up out of this for you, so what good can
> such a question bring besides a flame war?
>
Absolutely none. Even if I hadn't written a line of code, I'd still end
up using Perl. It's my language of choice.
>> $original->fill
>> (
>> from => [$data->{Ewall}[0]{Y1} + 1, $data->{Ewall}[0]{X}],
>> to => [$data->{Ewall}[0]{Y2} - 1,
>> $data->{Ewall}[0]{X} + 1],
>> with => "."
>> );
>> # You'd have to be totally sane to call this line noise. And nobody is
>> # that sane.
>
> I really don't like the way you use complicated data structures in Perl,
> but that's probably fine for an awk replacement ;)
>
Complex data structures? $data just contains info on a structure in a
cave, such as a hallway or room. Every wall's coordinates are stored.
I'm also going to have a {Wexit} key with the ID of the structure that
the western wall is connected to, if any. Smart pathfinding made easy.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

At Thu, 25 Aug 2005 20:43:05 GMT,
Da-Breegster wrote:

> On 2005-08-25, Radomir 'The Sheep' Dopieralski <thesheep@sheep.prv.pl> wrote:
>> At Wed, 24 Aug 2005 20:28:00 GMT,
>> Da-Breegster wrote:

>> I really don't like the way you use complicated data structures in Perl,
>> but that's probably fine for an awk replacement ;)

> Complex data structures? $data just contains info on a structure in a
> cave, such as a hallway or room. Every wall's coordinates are stored.
> I'm also going to have a {Wexit} key with the ID of the structure that
> the western wall is connected to, if any. Smart pathfinding made easy.

They are complex in Perl.
Note also, that key lookup in hash tables is pretty slow -- you can
probably gain some speed by doing lookups outside the loops whenever
possible ans using local variables instead.
For the structures that need lookups often (like the map), you'd
probably get better results using arrays and constants for the field
names:

CreatureName = 1;
CreatureMaxHP = 2;
CreatureHitDice = 3;

creature[CreatureName]="kobold";

--
Radomir `The Sheep' Dopieralski @**@_
(--) 3 ..zzZZ
. . . ..v.vVvVVvVvv.v.. .
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Uzytkownik "Sherm Pendley" <sherm@dot-app.org> napisal w wiadomosci
news:m2slwxoc0g.fsf@Sherm-Pendleys-Computer.local...
> Not at runtime. Perl has real constants; their value is calculated
> at
> compile time and used just like a literal value would be.

So Perl surprises me again :)
PHP and Python also have virtual machines and none of them (AFAIK) has
real constants, burned into bytecode at the time of its creation.

> In this particular instance though, based on the small bit of code
> I've
> seen here, I don't think using an array and constant indexes would
> make
> a substantial difference in syntax, just []s instead of {}s.

Right. It was more of a general remark.

--
regards,
Filip Dreger
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Filip Dreger wrote:

> Uzytkownik "Sherm Pendley" <sherm@dot-app.org> napisal w wiadomosci
> news:m2slwxoc0g.fsf@Sherm-Pendleys-Computer.local...
>> Not at runtime. Perl has real constants; their value is calculated
>> at
>> compile time and used just like a literal value would be.
>
> So Perl surprises me again :)
> PHP and Python also have virtual machines and none of them (AFAIK) has
> real constants, burned into bytecode at the time of its creation.
>
>> In this particular instance though, based on the small bit of code
>> I've
>> seen here, I don't think using an array and constant indexes would
>> make
>> a substantial difference in syntax, just []s instead of {}s.
>
> Right. It was more of a general remark.
>

Python has exactly 1 builtin constant : None :)

Appart from that, the C runtime does an optimisation on local variable usage
inside a function. A local variable in Python doesn't cost any lookup time
no matter how big the name is. That's why it's really worth it to store in
a local variable an often use value ( or function )
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On 2005-08-25, Radomir 'The Sheep' Dopieralski <thesheep@sheep.prv.pl> wrote:
> At Thu, 25 Aug 2005 20:43:05 GMT,
> Da-Breegster wrote:
>
>> On 2005-08-25, Radomir 'The Sheep' Dopieralski <thesheep@sheep.prv.pl> wrote:
>>> At Wed, 24 Aug 2005 20:28:00 GMT,
>>> Da-Breegster wrote:
>
>>> I really don't like the way you use complicated data structures in Perl,
>>> but that's probably fine for an awk replacement ;)
>
>> Complex data structures? $data just contains info on a structure in a
>> cave, such as a hallway or room. Every wall's coordinates are stored.
>> I'm also going to have a {Wexit} key with the ID of the structure that
>> the western wall is connected to, if any. Smart pathfinding made easy.
>
> They are complex in Perl.
> Note also, that key lookup in hash tables is pretty slow -- you can
> probably gain some speed by doing lookups outside the loops whenever
> possible ans using local variables instead.
> For the structures that need lookups often (like the map), you'd
> probably get better results using arrays and constants for the field
> names:
>
> CreatureName = 1;
> CreatureMaxHP = 2;
> CreatureHitDice = 3;
>
> creature[CreatureName]="kobold";
>

Pseudohashes are not only deprecated, but more trouble than they're
worth. The only general slowdown right now is the way I handle colors
(I'll get to that in a minute) and dungeon generation. Generation I can
speed up somehow. With colors, I set the ncurses attribute to the
appropriate color only when the previous one is different from the
current color. But I'm still adding one character at a time. There a way
to put the color codes inside a string and addstr() an entire row?
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

<edward@lore.net> writes:

> Da-Breegster <dabreegster@gmail.com> wrote:
>> current color. But I'm still adding one character at a time. There a way
>> to put the color codes inside a string and addstr() an entire row?
>
> How fast is your target platform, and are you sure this is actually
> slowing things down? It looks inefficient, but I'm sure it isn't a
> significant factor in my program's speed.

Is your program in Perl? If not, you're comparing apples and camels. Calling
"down" to a C function from Perl carries some overhead that calling the same
function directly from C does not.

> I'm unaware of any color-encoded string mechanisms in Curses. Surely if
> they existed, they would just do the same colour attron/attroff, but
> internally?

That would be exactly the point - it would call them internally. Instead of
making strlen calls across the Perl/C divide, you'd make one cross-language
call for the whole string, which would result in strlen C-to-C calls.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 

Edward

Distinguished
Apr 22, 2004
115
0
18,680
Archived from groups: rec.games.roguelike.development (More info?)

Da-Breegster <dabreegster@gmail.com> wrote:
> current color. But I'm still adding one character at a time. There a way
> to put the color codes inside a string and addstr() an entire row?

How fast is your target platform, and are you sure this is actually
slowing things down? It looks inefficient, but I'm sure it isn't a
significant factor in my program's speed.
I'm unaware of any color-encoded string mechanisms in Curses. Surely if
they existed, they would just do the same colour attron/attroff, but
internally?
--
jude hungerford.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Da-Breegster <dabreegster@gmail.com> writes:
> But I'm still adding one character at a time. There a way
> to put the color codes inside a string and addstr() an entire row?

Term::ANSIColor might work, though I've never used it together with
addstr().

--
Chris