Python scripting

Discussion among members of the development team.

Moderator: Forum Moderators

Python scripting is a good idea?

WML is enough
12
57%
Not sure
6
29%
Python would be great
3
14%
 
Total votes: 21

freecraft
Posts: 94
Joined: April 28th, 2005, 12:49 am
Location: Serbia
Contact:

Python scripting

Post by freecraft »

I think (sry if I'm wrong) that python scripting could bring <revolution> to wesnoth scenarios...

Python is very popular language today, and it is easy implemented in C++. It would be nice to have such a powerfull scripting language beside WML ...

I don't know how much hard it is for implementing, but as I said, once it is done, it could trigger a <golden age> of campaigns, scenarios etc :)

Comments ?
Jkun
Posts: 33
Joined: April 25th, 2005, 12:44 pm
Location: West Warwick, Rhode Island

Post by Jkun »

If I knew anything about coding, I'd be glad to contribute to the poll.

How many people do you honestly think could make an educated decission?
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

It has been suggested before. Conclusion: python isn't necessarily that great a language, WML is fine-tuned for use in wesnoth, so it is probably better than a generic language, support for python would never be added at the expense of support for WML, and it would be too much work to add support for an additional scripting language.

Also, IMO we are already in a 'golden age of scenario/campaigns'. What we don't need is to have a bunch of stupid campaigns flooding us, which we don't have, but we still have a lot of really good campaigns.
Jkun wrote:How many people do you honestly think could make an educated decission?
The coders, and the WML writers (who would be the ones actually switching languages).
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

If the end result would be about the same, it doesn't seem worth the effort and vice-versa. So what does python add that we don't get with WML?
Hope springs eternal.
Wesnoth acronym guide.
freecraft
Posts: 94
Joined: April 28th, 2005, 12:49 am
Location: Serbia
Contact:

Post by freecraft »

Well, you see, I don't know exactly what WML cannot do I do know what python can do - anything. Python is one of the most used scripting language in the world beside language LUA and somewhere TCL. For example, the oncoming Sid Meiers Civilisation4 will be using python ... then, Freedom Force already used it (not very sure, but I think so) and so on ...

The biggest difference between using WML and Python scripts would be that python is more natural to work with ... and it is easier, extensible etc ... With python scripting, wesnoth could have scenarios like, omg, like warcraft3 !!! Yes I thnk it is possible! All those "trigger" stuff etc, executer *very* dinamicaly ... I agree with you E.Pillager about everything you said, still, my idea remains and I hope that python will be implemented one day :)

And about WML... WML is doing it's job... Thats what all of you think. Because you haven't imagined nothing that couldn't be done with WML... And just try to think about scenarios in which you can play something like "footman wars" in warcraft, or something like civ etc ...

Well, still, whatever is my opinion, the problem of big job to implement that stuff remains ... unsolved ... however, I would like to help if I can :)
So developers, please accept my offer unless you think I have low skils yet :(

Bye!!! Happy wesing :)
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

freecraft wrote:I agree with you E.Pillager about everything you said,
What? I don't see any posts by me in this thread...

Although, as the local "person who does the craziest things with WML!!!" I'd like to say that it's a very effective scripting language for the game.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

A few questions:

- do you understand what WML can already do? Because from your posts it doesn't sound like it. It can already handle events, and so forth. In fact, there is a scenario called 'Wesbowl' which uses WML to make a football-like game in Wesnoth, complete with passing the ball between units, touchdowns, and injuries.
- is there any Open Source game which uses Python and has as many or more custom scenarios/campaigns/levels/etc than Wesnoth has?
- do you really think more people would make scenarios and campaigns for us if we used Python? Seriously, we have over 20 good scenarios/campaigns, while e.g. Adonthell which is a generic RPG engine which uses Python has....how many custom scenarios written? Does it have any at all?

Also, Python can't do 'everything'. It can only do what the interface you give it allows. Which is pretty much the same as WML. :)

The one area I think Python might be useful is the AI: it would allow designers to make a custom AI for their scenario. However I suspect most designers wouldn't be capable of making an effective one anyhow.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

WML is perfectly adapted to describe a game situation/history. Not surprising, since it exactly matches the "config" structure used internally to serialize the game. No generic programing language will ever be able to be that adapted, so there is no real point to use it instead of WML.

However, generic programing languages offer some facilities with respect to expressiveness. I will try a bold and a bit stretched analogy to explain my point more precisely. In computer science, there is a hierarchy: some problems can be seen as P, or as NP, or as worst. P problems can be solved in polynomial time. Solutions of NP problems can be verified in polynomial time, hence there are possibly some problems that are in NP but not in P. And the worst problems are outside of the polynomial sphere.

Now about WML. There are scenarios that can be directly expressed as WML. In this first category, we have all the scenarios that currently exist. There are scenarios with results/behaviors that could be expressed as WML. And there are scenarios outside of the WML sphere (and hence outside of Wesnoth). In this last category, we have "scenarios like, omg, like warcraft3".

Now what about scenarios of second category? To use the NP analogy till its end, would we benefit from scenarios that use external "oracles" in order to act on the WML level? Let us consider the following scenario example. On a corner of the map, there is a magic pentagon. If you can get five of your mages (whatever their type) to stay idle (no enemy attack) on the vertices of the pentagon for at least three turns, then you are shown with a dialog box asking for a unit type; and upon selection, all the units on the map of this type are destroyed (an equivalent of Nethack scroll of genocide).

Please note that (unless I'm overly optimistic) such a scenario can already be expressed in WML, but it will be a bit tedious to correctly track the event condition. Now what if there was a syntax like:

Code: Select all

[event]
  name=...
  [script]
    language=...
    script="..."
  [/script]
  ...
[/event]
Another example, the WML multiplayer map generator would probably have been easier to write if some terrain placing decisions could have used another language. Same for the shop idea that has been around in the forum this week: making it in WML is possible yet tricky.

As for the interface between the external language and the game, it just has to be the similar to the one used by "store_unit" and "unstore_unit" in WML scenarios, which is nothing less than an access to the internal state through "config" structures.

Anyway, I will not involve myself any further in this discussion since I'm not really concerned, it was just to show that there are some good sides at using an external language, even in Wesnoth. I will just ask this rhetorical question: how many "please add this new [filter] type" feature-requests could have been avoided, if some external scripting facilities were available?
Sithrandel
Posts: 537
Joined: September 15th, 2003, 2:54 pm
Location: Sheffield (UK)
Contact:

Post by Sithrandel »

I would be against adding Python Scripting.

From the Human Engineering point of view the game should be designed for players, not programmers. Wherever possible we should produce something which can run out-of-the-binary without requiring users to clutter up their systems unnecessarily.

Python is installed on Mac 10.3 by default, but I am not sure about 10.2.8. I do recall having some difficulty with the Python Map Generator at one point. I am also concerned that we might have some trouble with expected paths, etc.

Of course it might be that all systems (including Windows) already have python installed and that local path names are not a problem.

Still, there I can't see a need which Python plugs that would make the gamble worthwhile.
freecraft
Posts: 94
Joined: April 28th, 2005, 12:49 am
Location: Serbia
Contact:

Post by freecraft »

EP I read some of your posts before about this subject and I agree with you, but now I have actually thought on turin's posts :) Sorry because of that :)

Obviousely I don't know enough WML as Dave said, so thats the reason I proposed python. Ok, lets say I give up :) About adonthell games I haven't played them a lot :) And maybe there are no games because of bad community? Don't know ...

Still, even I am convinced that python won't be implemented, here are some my points of view:

Sithrandel: when using python i C++, all you need is to keep python dll file in the same directorium where game exe is installed. Probably it can be the same thing with the linux *.so files. Even wesnoth is opensource, the distributed python lib doesn't have to be opensource, nor it has to be newest version or whatever, it can be any binnary python version. So, once downloaded, that python *thingy* should be enough for all releases of wesnoth, so it wouldn't be one more dependency ...

silene: nice post

everybody else: well, don't be angry at me, and everything will be fine :)

dave: about python can't do everything ... well, here is my question:
- can wml have expressions like unit.health = unit.health + sin(unit.x)*5 ?
- can wml have functions
- can wml run threads? - this is useless in TBS but imagine this: while you move your army - the colour of water is changing or animals are walking over field :) - well, that was stupid, but I have to mention it :)
- dave, let's make a compromise : i will first learn the WML and THEN i will talk about python, because, this way of disscussion is bad, because you know them both and i know only python :(

/me going to learn wml, till then, i will stfu ;)
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

freecraft wrote:dave: about python can't do everything ... well, here is my question:
- can wml have expressions like unit.health = unit.health + sin(unit.x)*5 ?
Why the heck would you want to do such a thing?!?!
freecraft wrote:- can wml have functions
Yes. (I will expand on this if anyone is wondering...)
freecraft wrote:- can wml run threads? - this is useless in TBS but imagine this: while you move your army - the colour of water is changing or animals are walking over field :) - well, that was stupid, but I have to mention it :)
That's a Wesnoth weakness, not a WML weakness.
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

freecraft wrote:About adonthell games I haven't played them a lot Smile And maybe there are no games because of bad community? Don't know ...
I mentioned Adonthell because it's one of the few Python-using games that is anywhere near 'successful'.

And perhaps there are no games because writing a game using a hybrid of C++ (or just C) and Python actually isn't as effective as Python advocates claim?

Seriously, Wesnoth development practice rejects some of the 'common wisdom' of the Open Source community, and yet we have been one of the most successful Open Source games. Do you think that perhaps we are successful because of our development methodology rather than in spite of it?
freecraft wrote: dave: about python can't do everything ... well, here is my question:
- can wml have expressions like unit.health = unit.health + sin(unit.x)*5 ?
Yes...except there is no 'sin' function in WML, because we have had no need for one (you could write one in WML though).
freecraft wrote: - can wml have functions
Well, yes....we use macros.
freecraft wrote: - can wml run threads? - this is useless in TBS but imagine this: while you move your army - the colour of water is changing or animals are walking over field :) - well, that was stupid, but I have to mention it :)
Using a scripting language to do that kind of thing is a bad idea: it should be built into the engine if you want it. Otherwise you might as well write the entire game in Python.
freecraft wrote: - dave, let's make a compromise : i will first learn the WML and THEN i will talk about python, because, this way of disscussion is bad, because you know them both and i know only python :(
Something I have learnt is that if you discover an Open Source project you like, you should always learn all about it and become respected as a contributor before suggesting "let's use technology XYZ!"

It is inevitable that you are going to find a very defensive reaction from the developers if you are a completely new contributor and suggest introducing a completely new and substantially-sized technology.

Also you should probably consider that the developers have considered the technology before. Python has been discussed several times, in fact.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
Elvish_Pillager
Posts: 8137
Joined: May 28th, 2004, 10:21 am
Location: Everywhere you think, nowhere you can possibly imagine.
Contact:

Post by Elvish_Pillager »

Dave wrote:Well, yes....we use macros.
Also (and this was discovered by Invisible Philosopher) there is a way of calling functions, although AFAIK the call is delayed.

Code: Select all

#define FUNCTION_NAMED NAME
[event]
name=die
[filter]
description={NAME}
[/filter]
#enddef
#define /FUNCTION_NAMED
[/event]
#enddef
#define CALL_FUNCTION_NAMED NAME
[unit]
x=1
y=1
type=Walking Corpse
description={NAME}
[/unit]
[kill]
description={NAME}
fire_event=yes
[/kill]
#enddef
It's all fun and games until someone loses a lawsuit. Oh, and by the way, sending me private messages won't work. :/ If you must contact me, there's an e-mail address listed on the website in my profile.
freecraft
Posts: 94
Joined: April 28th, 2005, 12:49 am
Location: Serbia
Contact:

Post by freecraft »

Well lets say that we have all agreed python is garbage for stuff like this. Ok I must say that I agree now ... About everything. As I said, I will stfu for some time until I become more familiar with wesnoth.

but however, I want to add this:
- Dave, whatever python advocates think, python is used well in mixing with cpp
- EP, your example of function calling is evil, hack and althought it may work, I don't like stuff like that ... It is not readable?
- Wesnoth is successful because of man standing behind it I think ... ok, your method is good ... rejecting "mood" :)
- Little about functions - macros sounds bad ... imagine C using macros and not functions ;) kidding
- About my "helping" to wesnoth, I started by fixing a bug in windows binary release :) well, i found that file wesnoth_editor.ico is missing :) at least something :)

Ok, gg, have fun cya on the net!
Btw, I was reading wiki about wml, it is ok, but is there any place where i could download the manual for ofline reading? Thats all, bye!
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

freecraft: actually I'm afraid you misunderstand me. :)

Let me clarify some points:

I don't think Python is 'garbage' for things like this. I knew Python, had used it for personal projects and commercially, and even worked with one of the developers of the popular Twisted Python.

Since I have a strong preference for static type checking [1], I wouldn't call Python my favorite language, but I appreciate its usefulness, its ease-of-use, and its relatively easy accessibility from system-level languages such as C and C++.

Now the important thing to understand about Wesnoth is that, like many software projects, it wasn't designed to be a certain way from the start. It started off as a very very small simple project. What is called WML today began as a simple configuration file. It slowly grew and features were added according to demands of users, and is now what it is today, with quite a few people who are skilled in using it to make campaigns, and a fairly large feature set.

Would Python be able to do the same sort of things? Almost certainly. But Python wasn't chosen, because when Wesnoth was started, I never imagined we'd end up with something so feature-rich that it'd support a complete events system.

So the question is, do we want to switch over to Python now? My answer is probably not. There is one big reason for this: it'd be alot of work, and we might end up with something that is disastrously full of bugs. Then we'd have to choose whether we wanted to continue trying to get all the bugs out, or revert the change. If we tried to get the bugs all out, we'd probably lose alot of users/credibility in the process, and some developers would likely become exhausted with the effort and leave the project and so forth.

And what would we get for this imho rather large risk? We could script a little more elegantly. Lots of scenario designers, who are usually, afaict not highly technical, would probably leave because they'd get frustrated at having to learn a completely new language and way of doing things. But, we could script a little more elegantly. Us programmers, who probably never actually write real scenarios, would love the capability to be able to write cool scripts, but the people who actually write scenarios wouldn't care.

I think one of the reasons Wesnoth has been successful is that it uses a philosophy of always trying to move forwards. We try to add new things, make the program better with each new release. We don't run around saying "we've been using technology x, but is technology y better? Maybe we should switch!"

That is expending alot of very valuable effort just to move sideways. We want to move forwards, not sideways. We don't have anywhere near the resources to move sideways all the time.

The only way I would entertain Python is if we could add it in an evolutionary fashion: add the capacity to augment WML with some Python in one release with very low effort -- something like silene's examples. Then perhaps bit by bit add more and more Python functionality, if people are finding it useful.

The important thing to understand about our current system is that it might not be pretty, but it works, and has served us well. To get us to change you'd be best served getting campaign designers actually wanting new features that are best implemented in Python.

David

[1] and yes, I do know about PyChecker
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Post Reply