Programing language
Moderator: Forum Moderators
Forum rules
Before posting a new idea, you must read the following:
Before posting a new idea, you must read the following:
Re: Programing language
Uh-huh. I've said before that I'm fine with Python being used in places it makes sense, and for more parts of the game to have support for Python scripting. In fact, I think a great place to start would be to allow random map generation using a Python script.ivan wrote:But we already have Python bindings for core C++ objects (team, unit, map) and, in fact, Python interpreter is already inside Wesnoth executable.Dave wrote: Actually it is. It's much easier than maintaining Python bindings in my view.
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Re: Programing language
I've just found that I want to type 'svn ci' to remember current state before further experimentation..
Can we have a branch? Or shall I do it somewhere else?
EDIT: here's the diff of what I have as a starting point http://dpaste.com/hold/90630/ nothing special, yet.
Can we have a branch? Or shall I do it somewhere else?
EDIT: here's the diff of what I have as a starting point http://dpaste.com/hold/90630/ nothing special, yet.
Re: Programing language
A branch sounds like a good idea. Best to ask on IRC in #wesnoth-dev on freenode for further help/instructions.ivan wrote:Can we have a branch? Or shall I do it somewhere else?
"If gameplay requires it, they can be made to live on Venus." -- scott
Re: Programing language
It doesn't matter much, but FYI there is a limit of 65K loop iterations in WML. This concept that WML should limit iterations to guarantee a halt means (in principle at least) that it is not a Turing-complete language. There are currently some ways of working around it by using events that fire other events. Eventually we may "fix" that workaround.uzytkownik wrote: As WML is turing-complete AFAIK you can write any algorithm in it.
http://en.wikipedia.org/wiki/Turing_completeness
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 126
- Joined: April 19th, 2008, 7:12 pm
- Contact:
Re: Programing language
What with:
</HUMOR>
C++ templates are usually described as TC despite that thay have similar limitations.
PS. Sorry for late response - I haven't got mail/miss it for some reason.
Code: Select all
# Lots of WML Code
[python]
# Python
[/python]
# Even more WML Code
<HUMOR>WML is turing complete. Implementation is notSapient wrote:It doesn't matter much, but FYI there is a limit of 65K loop iterations in WML. This concept that WML should limit iterations to guarantee a halt means (in principle at least) that it is not a Turing-complete language. There are currently some ways of working around it by using events that fire other events. Eventually we may "fix" that workaround.uzytkownik wrote: As WML is turing-complete AFAIK you can write any algorithm in it.
http://en.wikipedia.org/wiki/Turing_completeness

C++ templates are usually described as TC despite that thay have similar limitations.
PS. Sorry for late response - I haven't got mail/miss it for some reason.
Re: Programing language
I think it makes more sense to add 'script' attribute to some WML tags. And keep python scripts separately.uzytkownik wrote:What with:Code: Select all
# Lots of WML Code [python] # Python [/python] # Even more WML Code
Like
Code: Select all
[event]
name=die
script=MyCampaignName.scripts.events.on_leader_die
[/event]
Re: Programing language
First off, I have very little knowledge of C/C++, the source code for BfW, or things like compilers and interpreters. So take what I say with a grain of salt.
The way I see it, open source projects are meant for stuff like this. Maybe one of you who wants a real scripting language can begin implementing it in a separate from the main development of the game. The more people that care about it, the more people will join once something gets started. Once it's sufficiently complete, the see about adding it into the main part of the game.
I see no reason why there can't be two different content writing languages. There could be the "simple" wml and the "advanced" whateverscript. When the game reads a particular file, it can determine what type of content it is, and then use the appropriate compiler/interpreter for that particular file.
The way I see it, open source projects are meant for stuff like this. Maybe one of you who wants a real scripting language can begin implementing it in a separate from the main development of the game. The more people that care about it, the more people will join once something gets started. Once it's sufficiently complete, the see about adding it into the main part of the game.
I see no reason why there can't be two different content writing languages. There could be the "simple" wml and the "advanced" whateverscript. When the game reads a particular file, it can determine what type of content it is, and then use the appropriate compiler/interpreter for that particular file.
- Viliam
- Translator
- Posts: 1341
- Joined: January 30th, 2004, 11:07 am
- Location: Bratislava, Slovakia
- Contact:
Re: Programing language
I guess the game code could be (maybe already is) divided to a "scripting language API" and "WML interpreter", and the second one could be replaced or used alternatively with another interpreter (if someone will contribute the code). Adding a new interpreter might be considered "feature creep", but dividing the program into scripting API and scripting interpreter is just a refactoring which IMHO does not any harm.mattyp wrote:I see no reason why there can't be two different content writing languages.
Then, the alternative language proponents would have their turn. It would be their task to make a new Wesnoth version with added interpreter of another language. And then someone would have to make a new interesting content using a new interpreted language, to "prove" that the change adds value to the game. -- Because if adding another interpreted language would not show improvement in game content, then probably the WML was good enough for content authors, and the change does not improve situation for content authors, maybe the alternative is even worse for them.
I think this would be the reasonable solution for current situation. Wesnoth developers should make adding new interpreted language possible. But the remaining work should be left on new language proponents. Only if they are able to provide the code and content, then their idea is worth including in the game. If there is no one willing to design and support the new language, or if there is no one willing to write content using the new language, then the idea seems interesting on the surface, but in reality does not work. We need to remember that people complaining about WML are usually programmers, but a typical content author may see things very differently. And the scripting language should be made convenient for content authors. This is a part of Wesnoth popularity -- relatively easy content making, even for people with no programming skills.
Re: Programing language
I'm relatively new to Wesnoth and I'm not at all familiar with WML, but... I would like to point out the capabilities the scheme (simple lisp dialect), which I think it would be a language that really suits this purpose.
I don't think that it would be hard at all for non-programmers to understand scheme if they were able to understand WML.
I think it has the benefits of markup languages and all the power of programming languages, abstraction layers and automation of simple tasks by using functions and conditionals efficiently.
The GNU Guile scheme interpreter has been the recommended extension language by the FSF for many years.
I don't think that it would be hard at all for non-programmers to understand scheme if they were able to understand WML.
Code: Select all
(side
(side 4)
(controller ai)
(team_name dwarves)
(user_team_name Dwarves)
(type Elvish Marshal)
(description Lerel)
(user_description "Lerel")
(canrecruit 't)
(recruit "Elvish Archer" "Elvish Fighter" "Elvish Scout" "Elvish Shaman")
(GOLD 300 200 100)
(ai
(recruitment_pattern fighter archer archer archer scout)
)
)
The GNU Guile scheme interpreter has been the recommended extension language by the FSF for many years.
Re: Programing language
While it seems more readable to the average non-programmer than LUA or the like (except for the 't, probably means 'true', but why the single quote?), the same thing applies as with all "let's replace/supplement WML with something else" ideas: show us the code, then we'll talk. 

Re: Programing language
I'll admit that your Scheme example does look beautiful to a programmer, as far as syntax goes. I do believe that if we offered this language as a possibility then people who mastered this language-- and used a suitable editor-- would prefer it over WML. However, there is a tradeoff here (other than the obvious implementation and maintenance time involved); newcomers to programming aren't fond of the Lots of Insidious Sets of Parenthesis.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 126
- Joined: April 19th, 2008, 7:12 pm
- Contact:
Re: Programing language
I guess scripting might be slightly more confusing for those who do not know RPN (or PN):AI wrote:While it seems more readable to the average non-programmer than LUA or the like (except for the 't, probably means 'true', but why the single quote?), the same thing applies as with all "let's replace/supplement WML with something else" ideas: show us the code, then we'll talk.
Code: Select all
(set_gold 1 (+ (* 2 var) 4))
Code: Select all
{SET_VARIABLE var_tmp $var}
{VARIABLE_OP var_tmp multiply 2}
{VARIABLE_OP var_tmp add 4}
[set_gold]
side=1
amount=$var_tmp
[/set_gold]
Last edited by uzytkownik on December 20th, 2008, 4:32 pm, edited 2 times in total.
Re: Programing language
your example is not even valid WML... but I think shortcut macros which only save you from typing one or two lines should be avoided by people who are first learning WML.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
-
- Posts: 126
- Joined: April 19th, 2008, 7:12 pm
- Contact:
Re: Programing language
Ok.Sapient wrote:your example is not even valid WML... but I think shortcut macros which only save you from typing one or two lines should be avoided by people who are first learning WML.
1. I counted 3 errors - mul instead multiply, typo of var instead of var_tmp and tag set_gold which I created just to simplyfy it. The first two will be fixed in a minute.
Full, 'correct' WML solution (written mainly from memory):
Code: Select all
[set_variable]
name=var_tmp
value=$var
[/set_variable]
[set_variable]
name=var_tmp
multiply=2
[/set_variable]
[set_variable]
name=var_tmp
add=4
[/set_variable]
[store_gold]
side=1
[/store_gold]
[set_variable]
name=gold
multiply=-1
[/set_variable]
[set_variable]
name=var_tmp
add=gold
[/set_variable]
[gold]
side=1
amount=$var_tmp
[/gold]
[clear_variable]
name=var_tmp
[/clear_variable]
[clear_variable]
name=gold
[/clear_variable]
Code: Select all
{VARIABLE var_tmp $tmp}
{VARIABLE_OP var_tmp multiply 2}
{VARIABLE_OP var_tmp add 4}
[store_gold]
side=1
[/store_gold]
{VARIABLE_OP gold multiply -1}
{VARIABLE_OP var_tmp add gold}
[gold]
side=1
amount=$var_tmp
[/gold]
{CLEAR_VARIABLE var_tmp}
{CLEAR_VARIABLE gold}
Code: Select all
(gold 1 (+ (* var 2) 4 (- (get_gold 1))))

I'd like to have LISP/Scheme as a scripting language for wesnoth but I'm worried if it's scripting will not be harder for newcommers then in for example python. Although I feel it will be much easier then in WML.
3. Verbose redundancy to some extend make code unclear. If I can see the whole event/procedure in one screen (80x24 is quite good 'memory' size) it is so simpler to debug. If a line is a logical steps it is much easier to follow it than if the single step in on 20 lines.
Re: Programing language
I think the biggest thing people overlook with comparisons is that the primary purpose of WML is not to manipulate variables in sophisticated ways like a typical programming language does all the time. Doing that in WML is indeed tedious.
The main purpose of WML is to act as a data language for Wesnoth scenarios. As part of this, it may on occasion be used to perform some limited variable manipulation, but this should not be common place in comparison to its main uses.
David
The main purpose of WML is to act as a data language for Wesnoth scenarios. As part of this, it may on occasion be used to perform some limited variable manipulation, but this should not be common place in comparison to its main uses.
David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming