Author Topic: rl oriented scripting language features.  (Read 39864 times)

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
rl oriented scripting language features.
« on: June 17, 2011, 01:22:14 PM »
What features in the scripting language can make development easier?
Beside all the basic stuff that most of scripting languages have.

Something that can't be done on a library level.

Probably some kind of high level rules matching for advanced AI?
Some advanced algo that would be much easier to use when it is built in into engine
rather than when it is exists as external lib?

All ideas are welcome :)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: rl oriented scripting language features.
« Reply #1 on: June 19, 2011, 01:12:04 PM »
All ideas are welcome :)

In that case I think it should be worth thinking if scripting is needed at all. I have found it confusing so I'm not using it. I guess compile speed has been an explanation for using scripting, but these days compiling is really fast, takes no time at all when you change only couple of source files and then run.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: rl oriented scripting language features.
« Reply #2 on: June 20, 2011, 02:23:19 PM »
All ideas are welcome :)

In that case I think it should be worth thinking if scripting is needed at all. I have found it confusing so I'm not using it. I guess compile speed has been an explanation for using scripting, but these days compiling is really fast, takes no time at all when you change only couple of source files and then run.
Scripting is not about compilation or execution speed. It's about development speed.
Scripting languages have RAD features not available in c/c++ and, to a lesser extent, C# and Java.
Scripting languages (usually) have rich abilities for data presentation as well as data parsing.
Not to mention almost free data de/serialization.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: rl oriented scripting language features.
« Reply #3 on: June 20, 2011, 03:27:59 PM »
Scripting languages have RAD features not available in c/c++ and, to a lesser extent, C# and Java.
Scripting languages (usually) have rich abilities for data presentation as well as data parsing.
Not to mention almost free data de/serialization.

RAD features?

daver64

  • Newcomer
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • Indigo
    • Email
Re: rl oriented scripting language features.
« Reply #4 on: June 21, 2011, 01:17:12 AM »
Hi,

All of those features you mention are also available to the c++ programmer through the use of libraries. For example, serialisation is very easy and very unobtrusive  to implement with a decent serialising library ( boost , for example ). If by RAD you mean Rapid Application Development, then that has been available for a lot of languages, both compiled and interpreted, for many years.

That is not to say scripting doesn't have its place, for example if you want things easily modded and programmed by people not familiar with the core language of your engine, then it can allow others to modify aspects of the host application.

That being said, for a roguelike being written by a C/C++ developer, its just not worth the mental gear change in my opinion :).

Cheers
Dave.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: rl oriented scripting language features.
« Reply #5 on: June 21, 2011, 02:34:58 PM »
Yes, RAD is rapid application development.
C++ has closures, coroutines, continuations, delegates?
Effort required to make boot::serialization to work is still effort and can't be compared to zero effort.
I wrote several 7drls and one full fledged roguelike in C++.
I have a feeling that significant amount of routine work could be avoided.

daver64

  • Newcomer
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • Indigo
    • Email
Re: rl oriented scripting language features.
« Reply #6 on: June 21, 2011, 03:12:56 PM »
Hi,

No, c++ as a language doesn't have those , but you didn't mention them in your post either. Although quite how coroutines , for example, will help roguelike development I'm not sure, but since I've only written one roguelike ( not released as its simply not polished enough ) perhaps you could elaborate on how those particular features help :).

For my own endeavors I've quite often considered integrating a Scheme ( its another language I occasionally dabble with ) for scripting purposes, but it always comes back to what I mentioned in my previous post in that it doesn't seem to buy me anything in terms of roguelike dev. I think its the mental gear change when switching from c++ I find too much, especially given how expressive c++ is anyway :).

Cheers
Dave


Z

  • Rogueliker
  • ***
  • Posts: 905
  • Karma: +0/-0
    • View Profile
    • Z's Roguelike Stuff
Re: rl oriented scripting language features.
« Reply #7 on: June 21, 2011, 04:44:51 PM »
I have looked at Boost's serialization, and it still looked cumbersome. But I have not really tried. A real life comparison of a roguelike using Boost serialization, or just doing saving by itself, would be helpful.

Coroutines are useful for game development, but I am also not sure whether they are so helpful for roguelikes.

After writing a big roguelike (one that I have not released, not Hydra Slayer) in a heavily scripted way I see lots of situations where using C++ would be cumbersome. Creating a new type or monster, or a new interaction, seems much more straightforward. But it depends on the developer and what kind of interactions frequently appear in a given design.

As for the original question, see my posts in the "Handling deaths/corpses" thread. They describe properties of the script language I am using.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: rl oriented scripting language features.
« Reply #8 on: June 21, 2011, 04:49:39 PM »
Hi,

No, c++ as a language doesn't have those , but you didn't mention them in your post either.
I said 'beside all the features ...' :)

Although quite how coroutines , for example, will help roguelike development I'm not sure, but since I've only written one roguelike ( not released as its simply not polished enough ) perhaps you could elaborate on how those particular features help :).
Coroutines can make implementation of complex AI features and multiturn abilities easy and transparent.
Coroutines allow straight logic where in C++ you have to break it into several (many?) pieces.

It's hard to estimate before you try :)
I've made some prototyping in falcon and I love results very much.
Actually I already have rich perl experience, and I know how convenient and fast script development could be.
But perl is too heavy and hard to embed.
I tried many different scipting languages, I liked some features of ones and other features of others.
Falcon is the best so far featurewise, but it's too far from release version,
but I took part in development in case I fail with my project :)

For my own endeavors I've quite often considered integrating a Scheme ( its another language I occasionally dabble with ) for scripting purposes, but it always comes back to what I mentioned in my previous post in that it doesn't seem to buy me anything in terms of roguelike dev. I think its the mental gear change when switching from c++ I find too much, especially given how expressive c++ is anyway :).
Well. I have around 16 years of C++ development behind. I know what C++ can and what it can't.
C++0x will make things much better, but it's not yet here. I'm tired of waiting (it was supposed to be C++2008).

But I'm somewhat afraid of many features of boost. boost::spirit example compiles more than 3 minutes in release configuration, that's not even fun.

daver64

  • Newcomer
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • Indigo
    • Email
Re: rl oriented scripting language features.
« Reply #9 on: June 21, 2011, 05:07:23 PM »
Hi,

 I'd mention I don't mean to put the case to actually use boost serialize for an actual roguelike, I mentioned it more to point out serialising can be pretty much considered a "solved problem" for c++ ( not just boost, of course, there are others , but boost is the one I am most familiar with ). For my current project I am actually using plain old .ini files, which seem to work just grand, although my thoughts do wander from time to time to using sqlite ( but I guess that is a whole other discussion! :)  ).

Xecutor : mea culpa with the c++ features, seems I had a problem between my eyes and my brain :D.


Currently I'm using VC2010, and enjoying the c++00x features it provides, but it would be nice for it to be more fully fledged. Given time I'm sure things will improve.

Cheers
Dave.
ps: yes, template compilation times can suck somewhat, but I have a reasonably fast box, so most projects I don't really notice, and for big projects it is a good excuse to go have a cup of tea :).
« Last Edit: June 21, 2011, 05:09:11 PM by daver64 »

linux_junkie

  • Newcomer
  • Posts: 28
  • Karma: +0/-0
    • View Profile
    • Email
Re: rl oriented scripting language features.
« Reply #10 on: June 21, 2011, 11:08:55 PM »
Well, I myself am a big fan of the Lua scripting language, and for some time now have integrated it into every project of mine, and even wrote a couple little games exclusively in Lua, although speed issues kept this from becoming really workable.

In my opinion, embedding a language like Lua presents several clear benefits for roguelikes.  Firstly, it allows for more intuitive, flexible data files to contain various types of game data.  Many RLs use data files for storing things like monsters, items, etc, and the benefit of this is *almost* universally agreed upon, so I won't waste time arguing *why* you would want to do this, but how scripting can make it better.

First of all, with traditional data files, you have to write a parser to read and load all the game data.  This presents its own set of problems, including many potential bugs, caused by either the parser, or a typo in the data file.  By using a script instead, you can more intuitively load this data, and any error will be easy to trace, down to the exact line.  Also, by scripting data files, you can take advantage of conditional statements and other programming constructs that are impractical to implement with a traditional data file.

One example of how conditional statements in a data file might be useful could be in the case of revising content in a future update of your game.  Let's say that in v1.0, a kobold has an attack rating of 5.  You soon realize this makes them underpowered, so for v1.1, you decide to increase it to 8.  Now, normally, you can just overwrite the old value and forget about it.  But what if the player updates your game to v1.1, but is still playing a savefile from v1.0?  Now, suddenly, all the kobolds magically become stronger, which may break game balance for that version.  Using a scripted data file, you can conditionally load different versions of the same data by checking for the version of the player's savefile.  Problem solved.  Obviously, there are many other useful things that can be done with scripted savefiles.

And, on the note of savefiles, using a script for savefiles also makes things easier.  You can simply write the savefile as a script that automatically loads the game data.  This makes the savefile human readable by default, which can be *immensely* helpful for debugging and balancing your game.  And, if using a language like Lua, you can compile the script to bytecode if you want to, to prevent the player from reading or altering the data.

I've also found scripting to be useful for higher level AI implementation.  Since developing any reasonably decent AI involves a lot of trial and error, and constant minor tweaking, using a script for this makes the process much quicker.  If you do this, though, I highly recommend putting all of your lower level AI routines in your engine, for speed reasons.

Dungeon generation, also being a trial and error process, can also benefit from this boost to development speed.

One of the most obvious benefits is that it allows others to modify your game, without being competent C/C++/Java/whatever programmers.  Editing monster values in a script is pretty easy for a beginner.

All in all, I'm very much so in favor of scripting, and I see ToME as being a stellar example of the potential power of a C (or C++, not sure) engine, with Lua scripting capabilities.

If you're serious about adding scripting to your game, I highly suggest you check out Lua.  It's definitely one of the fastest available, is comparatively painless to embed (at least compared to certain other languages), and has, in my opinion, awesome capabilities.  It's a very simple, easy to learn language, but extremely powerful, through the use of its rather phenomenal tables data types.

Anyways, just my two cents.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: rl oriented scripting language features.
« Reply #11 on: June 22, 2011, 07:09:00 AM »
First of all, with traditional data files, you have to write a parser to read and load all the game data.  This presents its own set of problems, including many potential bugs

This assumes that you need a data file in the first place OR that you need text based data and then convert it to numbers. But you can just place the data in C++ source code. It's easy and fun!

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: rl oriented scripting language features.
« Reply #12 on: June 22, 2011, 12:54:43 PM »
But you can just place the data in C++ source code. It's easy and fun!
It's a little bit better in c++0x with data in source, but current version of c++ is not so good at this.
You can't create dictionary data directly. You can create map from array at init time.
But you need to do this manually for every different data type.
Not to speak about data updates. If your data is in script, you can update script. Even in runtime.
If you data is in c++ source, you must recompile binary.

Serialization in C++ is easily solvable problem, but it is routine task and a little error prone, in some cases.
Every time you introduce new object, you need to write several lines of code to support serialization.
While it's easy, it takes time. If you develop you rl here and there 10 minutes each time,
extra time spents that are not directly related to game are somewhat of a waste.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: rl oriented scripting language features.
« Reply #13 on: June 22, 2011, 01:13:38 PM »
You can't create dictionary data directly. You can create map from array at init time.
But you need to do this manually for every different data type.

What are you talking about? Take a look at how I did it in Teemu:
http://koti.mbnet.fi/paulkp/teemu/teemu.htm

No maps, no bullshit.

Quote
Every time you introduce new object, you need to write several lines of code to support serialization.

I don't know what's the problem with serialization (or save/load game as we people call it). Again, look at Teemu's Tar_Ball class to see how it's done easily. You just save the dynamic, changing data of a class and then restore them from data stream. That's it. It's the easiest part of roguelike programming.

Xecutor

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 263
  • Karma: +0/-0
    • View Profile
Re: rl oriented scripting language features.
« Reply #14 on: June 22, 2011, 03:26:59 PM »
You can't create dictionary data directly. You can create map from array at init time.
But you need to do this manually for every different data type.

What are you talking about? Take a look at how I did it in Teemu:
http://koti.mbnet.fi/paulkp/teemu/teemu.htm

No maps, no bullshit.
Yeah, how true. If you don't need them than whole world don't need them too.


Quote
Every time you introduce new object, you need to write several lines of code to support serialization.

I don't know what's the problem with serialization (or save/load game as we people call it). Again, look at Teemu's Tar_Ball class to see how it's done easily. You just save the dynamic, changing data of a class and then restore them from data stream. That's it. It's the easiest part of roguelike programming.


Your thinking is bounded by complexity of your game.
In wizard's quest there are over 100 effects.
Each effect have owner and most of effects have dynamically generated value(s) and some have dynamic effect description.
There are over 50 monsters and a lot of them have unique abilties that have dynamic values.
All this stuff must be saved.

If you are so sure that scripting is not needed, just ignore this topic.

@linux_junkie :
Lua have scanning garbage collector. When a lot of data is manupulated, gc lockdowns can be visually noticable.
To my taste syntax of lua lacks syntactic sugar. Dual nature of table is somewhat confusing and sometimes can lead to bugs.
I can't get used to ':' as method call operator. In presense of '.' operator I'm constantly confusing them.
As for speed - my prelinamenary tests are comparable to lua. Don't know how it will slowdown when
I'll add all the features, I hope not too much. I designed it with optimizer in mind.
If what I planned will work as I planned, my engine might even compete with lua :)

@Dave:
I can try C++0x features with g++ and clang too. They are great.
But I can't use them in production code. Yet.

@Z:
I've read you post in that thread. IMO something like this can be solved with delegate+coroutine combo.
For most cases delegates are enough. Coroutines looks nice when you need to inject code into
multiphase event, like 'object taking damage'.
If I misunderstood what you are talking about, can you make more complete example.