Building an alternative to ActionWML
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: Building an alternative to ActionWML
While this sounds convenient at first glance, I don't think that supporting multiple scripting languages is a good idea because it places a bigger maintenance burden on the development team:shevegen wrote: ↑October 6th, 2018, 10:46 amIn my opinion, alternatives are good if they can be equivalent. I'd also love to use ruby rather than
lua; and I am sure python folks love to use python rather than lua too. But I think all of this could
happen in the long run. What may be useful is to document all of WML even better, perhaps work
on towards an "agnostic" specification, improve lua too (since it can serve as "bootstrap" language,
as the first alternative to WML, which may be useful lateron) and, well - people would be able to
decide what they'd like to use. (Specification could ensure consistency among implementations;
I noticed some error messages in lua-based scenarios that seem different from WML-centric
errors, e. g. suddenly lua-based errors that appear on the main map interface, which I do not
remember from any WML-centric scenario ... at the least not in this form. May perhaps be
because WML is more tested than lua and more campaigns written with it, I can not say.)
- Any new feature will need to be implemented multiple times
- Multiple code paths means more chances for bugs to creep in
- Multiple code paths to test for the same functionality, so bugs will be missed. And who will do all that testing?
- Tech support and documentation for campaign authors will become harder, because all variants need to be documented
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Building an alternative to ActionWML
There was also Python support for certain things at one point, but it was removed due to it not being possible to lock down enough to be safe.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: Building an alternative to ActionWML
during my work on the lua map generator https://github.com/wesnoth/wesnoth/pull/3611 i also added a custom lua filter syntax that is usable by the lua map generator, It is currently used like
where 'and' basicially means 'all of the contained subfilters', im consiering renaming f_and to f_all and f_or to f_any, Its also very easy to write a lua code that converts classical filterwml to this format (since it was specialyl designed for mapgeneration its less poweful though and of course does not support all types of filter that standard locations filters do liek filterign the villageowner or the unit on it). I think it has some advantage of the classical standardterrainfilters:
1) It's much fasts, even though i'll admit that that is more a property of the implementation and not of the language syntax (still, in paticular in map generation this in an important point)
2) Its more clear when it comes to how certain tags interact, in wmlfilers newcomers are often surpirsed to find out how exactly stuff like [or] or radius= interact with other tags.
I wonder whether such a syntax is good outside of mapgeneration aswell, it could probably easily be extended with more functionlity of full stnadard location filters/unit filters , and as i said before compatability could be conserved by automatic conversion to the new format.
Code: Select all
--@a1: terrain to change to, @a2: filter table, more optional named parameters can be given.
set_terrain { "Chw",
f_and (
f_terrain("Ww"),
f_adjacent(f_terrain("C*,K*"), nil, "0"),
f_adjacent(f_terrain("W*^*"), nil, "2-6"),
f_adjacent(f_and(
f_terrain("Ww"),
f_adjacent(f_terrain("Ch,Kh"))
)),
f_not(f_radius(7, f_terrain("*^Vl")))
),
--optional: change 80% of the matching tiles
percentage=83,
--optional: change only the base layer
layer="base",
}
1) It's much fasts, even though i'll admit that that is more a property of the implementation and not of the language syntax (still, in paticular in map generation this in an important point)
2) Its more clear when it comes to how certain tags interact, in wmlfilers newcomers are often surpirsed to find out how exactly stuff like [or] or radius= interact with other tags.
I wonder whether such a syntax is good outside of mapgeneration aswell, it could probably easily be extended with more functionlity of full stnadard location filters/unit filters , and as i said before compatability could be conserved by automatic conversion to the new format.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Building an alternative to ActionWML
The biggest problem I can see with that is that you seem to be using all global functions. I don't think we should be polluting the global namespace with lots of functions like that. I also think the order of arguments is wrong – for the simple case where you want to transform only exactly matching terrain, it should be
set_terrain{from, to}
, which is the opposite of what you've shown here.Re: Building an alternative to ActionWML
Hmm i actually don't relly see a problem with that, we could also make it just one global namespace value f and then write f.adjacent, f.terrain, similar to wml.tag, (but note that here each tag indeeds needs a specil implementation which doesn't mean it's not possible), the main reason why i decided against that was that some of the filter keys (and, or, not) are lua keywords, but if we renaem and to all, or to any, this might not be problems anymore, we just haev to figure out what to do with, 'not'/'nand'. Maybe call it 'nany' ?Celtic_Minstrel wrote: ↑October 12th, 2018, 12:15 am The biggest problem I can see with that is that you seem to be using all global functions. I don't think we should be polluting the global namespace with lots of functions like that.
set_terrain it just a helper function anyways, the underlying functions are get_locations(filter) and set_terrain(location, terrain).Celtic_Minstrel wrote: ↑October 12th, 2018, 12:15 am I also think the order of arguments is wrong – for the simple case where you want to transform only exactly matching terrain, it should beset_terrain{from, to}
, which is the opposite of what you've shown here.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Building an alternative to ActionWML
The
To be honest, I'm not too enthusiastic about putting them in a global module either, but it'd at least be better than having them all as global functions.
And helper functions need to make sense too, by the way... at least if they're actually part of the API.
[not]
tag doesn't make sense extended to higher arities – its underlying operation is "but not", also called material nonimplication, and it's not commutative. However, I think it would make sense to have a "none" option - it's true if all its children are false. If used with only a single child inside an "any", that would be functionally equivalent to [not]
,To be honest, I'm not too enthusiastic about putting them in a global module either, but it'd at least be better than having them all as global functions.
And helper functions need to make sense too, by the way... at least if they're actually part of the API.
Re: Building an alternative to ActionWML
Hmm i wasnt taling abotu the odl [not] tags i was talkign abotu the 'tags' of the new filefilters that are currently called 'nand' 'nor' behave like the 'not any of the subfilter', 'not all of the subfilters', most often they are just used with one subfilter in which they just become logical negation.Celtic_Minstrel wrote: ↑October 12th, 2018, 2:57 am The[not]
tag doesn't make sense extended to higher arities – its underlying operation is "but not", also called material nonimplication, and it's not commutative. However, I think it would make sense to have a "none" option - it's true if all its children are false. If used with only a single child inside an "any", that would be functionally equivalent to[not]
,
Well, that heper function i currently not intended to be part of the public ap, thogh, so i don' think it make much sense to talk about it.Celtic_Minstrel wrote: ↑October 12th, 2018, 2:57 am And helper functions need to make sense too, by the way... at least if they're actually part of the API.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Building an alternative to ActionWML
Well, "nand" and "nor" are fine as long as "nand" means "not all" and "nor" means "not any", but I find these terms can actually be confusing. I'll also point out that "none" means "not any", so that could be an alternative to "nor". You could rename "nand" to "some", which is functionally similar to "not all", though it might not get the idea across as well; I think I'd recommend just "not_all".
Re: Building an alternative to ActionWML
"nand" and "nor" are well-defined terms with associated truth tables, so they make it really clear what they mean. Of course, the lay(wo)man will have to look them up on Wikipedia or something.
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Building an alternative to ActionWML
That's my point – they are well-defined, yes, but their meaning is not necessarily obvious to someone not already familiar with the math, and I'm actually not certain gfgtdf even used them correctly. I know I've gotten confused about them in the past.
I think this is a good way to think about it though. If you consider that binary "and" generalizes to higher arity as "all", then binary "nand" generalizes to higher arity as "not all"; this seems to be a correct way of thinking. Similarly, if binary "or" generalizes to higher arity as "any", then binary "nor" generalizes to higher arity as "not any" which is the same as "none".
However, if you just see "nand" and aren't familiar with the math, I think it could be reasonable to view it as a shortening of "not and" (which technically it is) and then conclude that "A nand B" is something like "~A and B" or "A and ~B" (where the tilde means "not"). I've definitely been confused about this before. A similar confusion could be possible with "nor" as well.
So yeah – "nand" and "nor" make the meaning clear to someone already familiar with the math. But "none" and "not all" make the meaning clear to anyone, even if they're not familiar with the math.
I think this is a good way to think about it though. If you consider that binary "and" generalizes to higher arity as "all", then binary "nand" generalizes to higher arity as "not all"; this seems to be a correct way of thinking. Similarly, if binary "or" generalizes to higher arity as "any", then binary "nor" generalizes to higher arity as "not any" which is the same as "none".
However, if you just see "nand" and aren't familiar with the math, I think it could be reasonable to view it as a shortening of "not and" (which technically it is) and then conclude that "A nand B" is something like "~A and B" or "A and ~B" (where the tilde means "not"). I've definitely been confused about this before. A similar confusion could be possible with "nor" as well.
So yeah – "nand" and "nor" make the meaning clear to someone already familiar with the math. But "none" and "not all" make the meaning clear to anyone, even if they're not familiar with the math.
-
- Inactive Developer
- Posts: 503
- Joined: April 24th, 2016, 4:18 pm
Re: Building an alternative to ActionWML
In WML, when we say [AND] what we're meaning is "all of".
Similarly, when we say [OR] what we mean is "any of".
So, by extension, [NAND] would be [NOT][AND] and would mean "not all of", and [NOR] would be "not any of" (which would mean "none of").
The question is: does the language provide sufficient expressiveness that, by careful application of De Morgan's law (or something similar for this system, since De Morgan's really only speaks to Boolean algebras), we can minimize the number of operations.
The answer, given just WML [NOT] [AND] and [OR], is: no, we cannot.
What you're missing is not [NAND] and [NOR]. They do simplify things, but they don't solve the deficiency.
What you're missing is the equivalence of [XOR], "some of" ... that is, at least one term is false and at least one term is true. I'm not sure how useful "some of" itself would be. I am fairly sure, however, that "one of" would be quite useful. Similarly, "<n> of", for a given n, would also be useful.
---
Specific meanings:
"not" --> invert, or negate, the input --> NOT(a) in C/C++ this is ! operator
"and" --> AND the inputs --> AND(a, b, c, ... n) in C/C++ this is && operator
"negative AND" --> negate all inputs, AND them --> AND(NOT(a), NOT(b), ... NOT(n)), by De Morgan's --> NOT(OR(a, b, c, ... n)) --> NOR(a, b, c, ... n)
"nand" --> AND the inputs, negate the output --> NOT(AND(a, b, c, ... n))
"negative NAND" --> does not exist, by De Morgan's this is "or" --> OR(a, b, c, ... n)
"or" --> OR the inputs --> OR(a, b, c, ... n) in C/C++ this is || operator
"negative OR" --> negate all inputs, OR them --> OR(NOT(a), NOT(b), NOT(c), ... NOT(n)), by De Morgan's --> NOT(AND(a, b, c, ... n)) --> NAND(a, b, c, ... n)
"nor" --> OR the inputs, negate the output --> NOT(OR(a, b, c, ... n))
"negative NOR" --> does not exist, by De Morgan's this is "and" --> AND(a, b, c, ... n)
"xor" --> Exclusive OR the TWO inputs --> XOR(a, b) in C/C++ this is != operator
"negative xor" --> does not exist, this is "xor" --> XOR (a, b)
"xnor" --> XOR the inputs, negate the output --> NOT(XOR(a, b)) in C/C++ this is == operator
"negative xnor" --> does not exist, this is "xnor" --> NOT(XOR(a, b))
---
What is interesting about NAND and NOR is that you can build any Boolean algebra using just one of them, exclusively. (Albeit, this could get pretty verbose.)
Similarly, when we say [OR] what we mean is "any of".
So, by extension, [NAND] would be [NOT][AND] and would mean "not all of", and [NOR] would be "not any of" (which would mean "none of").
The question is: does the language provide sufficient expressiveness that, by careful application of De Morgan's law (or something similar for this system, since De Morgan's really only speaks to Boolean algebras), we can minimize the number of operations.
The answer, given just WML [NOT] [AND] and [OR], is: no, we cannot.
What you're missing is not [NAND] and [NOR]. They do simplify things, but they don't solve the deficiency.
What you're missing is the equivalence of [XOR], "some of" ... that is, at least one term is false and at least one term is true. I'm not sure how useful "some of" itself would be. I am fairly sure, however, that "one of" would be quite useful. Similarly, "<n> of", for a given n, would also be useful.
---
Specific meanings:
"not" --> invert, or negate, the input --> NOT(a) in C/C++ this is ! operator
"and" --> AND the inputs --> AND(a, b, c, ... n) in C/C++ this is && operator
"negative AND" --> negate all inputs, AND them --> AND(NOT(a), NOT(b), ... NOT(n)), by De Morgan's --> NOT(OR(a, b, c, ... n)) --> NOR(a, b, c, ... n)
"nand" --> AND the inputs, negate the output --> NOT(AND(a, b, c, ... n))
"negative NAND" --> does not exist, by De Morgan's this is "or" --> OR(a, b, c, ... n)
"or" --> OR the inputs --> OR(a, b, c, ... n) in C/C++ this is || operator
"negative OR" --> negate all inputs, OR them --> OR(NOT(a), NOT(b), NOT(c), ... NOT(n)), by De Morgan's --> NOT(AND(a, b, c, ... n)) --> NAND(a, b, c, ... n)
"nor" --> OR the inputs, negate the output --> NOT(OR(a, b, c, ... n))
"negative NOR" --> does not exist, by De Morgan's this is "and" --> AND(a, b, c, ... n)
"xor" --> Exclusive OR the TWO inputs --> XOR(a, b) in C/C++ this is != operator
"negative xor" --> does not exist, this is "xor" --> XOR (a, b)
"xnor" --> XOR the inputs, negate the output --> NOT(XOR(a, b)) in C/C++ this is == operator
"negative xnor" --> does not exist, this is "xnor" --> NOT(XOR(a, b))
---
What is interesting about NAND and NOR is that you can build any Boolean algebra using just one of them, exclusively. (Albeit, this could get pretty verbose.)
I forked real life and now I'm getting merge conflicts.
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Building an alternative to ActionWML
I think "some of" is pretty similar to "not all of", though I suppose not exactly the same.
The direct generalization of "xor" to higher arity actually gives "odd number of" which would not be very useful, but I agree that "one of" could be very useful.
I don't think "xnor" or its generalization to higher arity is very useful, though. Sure, there are occasionally times when you want to test if two conditions have the same result, but I don't think that's very common. There are also two different ways of generalizing "xnor" to higher arity – is "A xnor B xnor C" equivalent to "A xnor (B xnor C)" or is it equivalent to "A == B == C", ie "(A xnor B) && (B xnor C)"? The former is more in line with the generalizations of other operators, but the latter is more intuitive and, I think, closer to what people would expect.
EDIT: Come to think of it, I think there's even a third way to generalize "xnor" to higher arities? I think
The direct generalization of "xor" to higher arity actually gives "odd number of" which would not be very useful, but I agree that "one of" could be very useful.
I don't think "xnor" or its generalization to higher arity is very useful, though. Sure, there are occasionally times when you want to test if two conditions have the same result, but I don't think that's very common. There are also two different ways of generalizing "xnor" to higher arity – is "A xnor B xnor C" equivalent to "A xnor (B xnor C)" or is it equivalent to "A == B == C", ie "(A xnor B) && (B xnor C)"? The former is more in line with the generalizations of other operators, but the latter is more intuitive and, I think, closer to what people would expect.
EDIT: Come to think of it, I think there's even a third way to generalize "xnor" to higher arities? I think
not(xor(a_1,a_2,...,a_n))
would give a different result than either of the other two definitions - it'd be "even number of", surely?Re: Building an alternative to ActionWML
ok most here people say that they like any, all, none, not_all more than or, and, nor , nand. So i'll just use those in the mapgenerator filter syntax for now. If we want to add something like "exactly_one_of" we can always do that later.
I think this discussion shodul go more toward the original topic , which is whether and how to depecate which parts of wml.
As i probably said before in lua it's rather unhandy to work with wml tables, and thus in particular with wesnoth.set/get_variable. I think we should add a lua bariable storage, that is for exampela glooba ariable name 'persistent that is saved in save/load and that does _not_ require the conjtents to be in wml table format. One the quesions then is whetehr we can use shoudl use that to store wml variables aswell (without breaking wml code that uses wml variable manipulation like [set_variable], [set_variables]) or wehtehr we should keep the two differnt variable sotages.
I think this discussion shodul go more toward the original topic , which is whether and how to depecate which parts of wml.
As i probably said before in lua it's rather unhandy to work with wml tables, and thus in particular with wesnoth.set/get_variable. I think we should add a lua bariable storage, that is for exampela glooba ariable name 'persistent that is saved in save/load and that does _not_ require the conjtents to be in wml table format. One the quesions then is whetehr we can use shoudl use that to store wml variables aswell (without breaking wml code that uses wml variable manipulation like [set_variable], [set_variables]) or wehtehr we should keep the two differnt variable sotages.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Re: Building an alternative to ActionWML
Sorry i haven't read the whole topic, just last few comments.. no idea if anyone cares about my opinion, but if there was a poll to deprecate WML or not, I would vote to keep WML as it is.. WML is great.
-
- Inactive Developer
- Posts: 503
- Joined: April 24th, 2016, 4:18 pm
Re: Building an alternative to ActionWML
Dunno where that Python comment came from. My thinking was it's a spam-bot warming up trying to bypass new-account posting requirements: we'll see.
Anyway, on the subject, since there's no reason to leave it dead ... I'm with enclave. Well, not really; I disagree. WML sucks. But it's what we have, so, almost by definition, it sucks less than the alternatives.
Anyway, on the subject, since there's no reason to leave it dead ... I'm with enclave. Well, not really; I disagree. WML sucks. But it's what we have, so, almost by definition, it sucks less than the alternatives.
I forked real life and now I'm getting merge conflicts.