How many coordinates can a single moveto event handle?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How many coordinates can a single moveto event handle?

Post by kurt751 »

Did he? :oops:

Anyway, I'm heading away from using coordinates (too risky).
I'm exploring the possibility of using either an invisible terrain overlay, or a time zone area. In both cases the game wouldn't care if the trigger area is a single hex or covers randomly 99% of the map.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: How many coordinates can a single moveto event handle?

Post by gfgtdf »

another option coudl be to use wml attribues as map, liek habng a table [bad_locs] 12_3=yes 24_2=yes ... [/bad_locs] and then use [filter_condition] [variable] name = "bad_locs.$x1|_$y1|" equals=yes
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.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: How many coordinates can a single moveto event handle?

Post by beetlenaut »

kurt751 wrote:Store where, how?
[store_locations] works like [store_unit], and put the locations in an array. The wiki is your friend. But if invisible overlays will work, that would be easy.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How many coordinates can a single moveto event handle?

Post by kurt751 »

gfgtdf wrote:another option coudl be to use wml attribues as map, liek habng a table [bad_locs] 12_3=yes 24_2=yes ... [/bad_locs] and then use [filter_condition] [variable] name = "bad_locs.$x1|_$y1|" equals=yes
That's just another way to have the game sift through a huge list of coordinates, isn't it? Given the game will have to do it each time the player moves an unit, won't it risk bogging down the game the same way? :?:
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How many coordinates can a single moveto event handle?

Post by Ravana »

This way takes only memory, but would have constant time no matter how many locations you have.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How many coordinates can a single moveto event handle?

Post by kurt751 »

beetlenaut wrote:
kurt751 wrote:Store where, how?
[store_locations] works like [store_unit], and put the locations in an array.
I see. Given I'm not very comfortable with advanced programming stuff, I'd rather avoid the opportunity to make stupid errors. :?

beetlenaut wrote:The wiki is your friend.
Friend, friend... An acquaintance, I'd say... :lol:

beetlenaut wrote:But if invisible overlays will work, that would be easy.
It would work, I just have to find out how to do it. Do you make overlays the same way as custom terrains?

The invisible overlay is the only easy way I see, since the time zone area thing apparently won't work (I just tried): The game doesn't recognize "area=someID" as valid WML, so it triggers all the time.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How many coordinates can a single moveto event handle?

Post by kurt751 »

Ravana wrote:This way takes only memory, but would have constant time no matter how many locations you have.
I see. Even if there are hundreds of coordinate pairs? Astonishing. (But then I'm not a programmer, in case I didn't say it...)

I'd rather go for something simple nevertheless, something I can wrap my mind around. (Yes, I know, that severely limits the choices... :roll:)
First, it would help me avoid bugs and errors, second it would speed things up, preventing me from wasting days on what should normally only take an hour. I'm well past the 50% completion mark, but September is already here. :?
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: How many coordinates can a single moveto event handle?

Post by beetlenaut »

kurt751 wrote:Do you make overlays the same way as custom terrains?
Yes. You can just use a blank image. If you're clever it can be visible in the editor, but not in the game. (I have a terrain like this in Secrets of the Ancients if you want to see an example. It's code is ^Nhyr in the terrain files.) But you don't really have to do it yourself if you don't want to. The castle overlay doesn't do anything without an adjacent keep.
kurt751 wrote:Given I'm not very comfortable with advanced programming stuff...
Storing units and locations is one of the most basic functions of WML! Half the scenarios I've ever written required one or the other. There is going to be a lot you can't do if you view them as too advanced.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: How many coordinates can a single moveto event handle?

Post by gfgtdf »

Ravana wrote:This way takes only memory, but would have constant time no matter how many locations you have.
Weel variable lookup is O(log n) which is not constant but still much better than O(n) which a locatios list (as given by store_locations) would take.
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.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How many coordinates can a single moveto event handle?

Post by kurt751 »

beetlenaut wrote:Yes. You can just use a blank image. If you're clever it can be visible in the editor, but not in the game.
Yes, I already made my terrain.cfg and terrain-graphics.cfg (containing{EDITOR_OVERLAY *^TCtrigg unwalkable-editor}). What I'm wondering is how the game knows where to look for them. Does it check all the known folders? I've put mine in /add-ons/MyCampaign/utils.

beetlenaut wrote:The castle overlay doesn't do anything without an adjacent keep.
Except I'm already using them (for an invisible castle)... :mrgreen:

No problem, I made my own terrain, it's not like it's difficult to make since it doesn't have any graphics... Took me 10 minutes trying to guess the syntax from the core files and 20 seconds to make.

beetlenaut wrote:Storing units and locations is one of the most basic functions of WML!
Yes, it's basic, but until somebody gives me the secret password of how to use it I'll avoid. The problem is I never know what the game expects to be fed with, and the WML Reference guide is just a sterile list of options, with no examples and minimalistic explanations.
I guess BfW programmers know instinctively how to formulate stuff ("it's just like C" or some such), but common people are really fighting to understand. Everything obvious to a programmer is for us a riddle we have to guess the solution of. It gets tedious.
My goal here is to make a nice campaign, and WML is a means, not a purpose; I don't want to spend a day each time I want to do something which normally should take 15 minutes.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How many coordinates can a single moveto event handle?

Post by kurt751 »

gfgtdf wrote:Weel variable lookup is O(log n) which is not constant but still much better than O(n) which a locatios list (as given by store_locations) would take.
Hm. This phrase looks like english, uses apparently english words, yet I didn't understand a single one... :roll:
I hope you were talking to Ravana. :mrgreen:



Anyway, I'll use a custom overlay for my triggers. Thank you everybody for your time and effort!
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How many coordinates can a single moveto event handle?

Post by Ravana »

Yes, I understood it.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How many coordinates can a single moveto event handle?

Post by kurt751 »

I didn't have any doubts about it... :mrgreen:
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: How many coordinates can a single moveto event handle?

Post by Tad_Carlucci »

kurt751 wrote:Anyway, I'm heading away from using coordinates (too risky).
To be clear: coordinates are not the issue: WML is the issue.

My point was that if you're looking at processing just a few "things" (in this case, coordinates) WML is fine. This is why processing the entire map in HttT S12 is not an issue .. it processes a fraction of the map each turn until, at turn 40, it has processed the entire map.

But if you're looking at processing a lot, WML will be the issue and Lua the solution. This is why processing the entire map in HttT S13 was an issue .. and why I re-wrote the WML in LUA.

If the use is to load, basically, the entire map into a variable and, for an event, search that list once or twice (maybe even 30 or 40 times) for something, I would expect WML to perform "good enough". That is: the performance hit would be less than 1/20th of a second or so (basically not noticeable by a normal human).

But if the idea is to change the entire map to hills if a dwarf hits, and forest if an elf hits, you're going to want Lua.
I forked real life and now I'm getting merge conflicts.
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: How many coordinates can a single moveto event handle?

Post by Tad_Carlucci »

Gak. Big-O is so misleading. To begin, read it as "time on the Order of (X)" For those who don't know, here are some common notations:

O(1) means something take a constant amount of time.

O(log n) means something takes a bit longer for every added item, but the rate of increase tapers off toward zero as we add more items.

O(n) means something takes a bit longer for every added item, and the rate of increase remains about the same.

But it's all misleading.

O(1) taking a year is acceptable Big-O notation, just so it takes a year no matter if we have 1 or 1 billion items, even though it's terrible response time for a computer.

And if I can write an O(n) which is faster than your O(log n) or O(1) for all reasonable values of n, that does not make it worse than yours simply because it's O(n). Sure, your method may outperform mine if maps are allowed to be 8192-by-4096, but if maps are limited to 1024-by-512 and mine beats your there, which would you choose?
I forked real life and now I'm getting merge conflicts.
Post Reply