<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hmmm... interesting.<br><br></div>I wouldn't want to rule out zones just yet.<br><br></div>What if each zone had an optional "cost" attached to it?<br><br></div>Using zones is a pretty easy way to define costs.<br><br></div>I could easily see using this as a nice easy way to mark harm tiles as ones that we don't want to path across unless there is no other choice.<br><br></div>As for multiple different costmaps for scripting, what if there was just a scripting command to change zone "cost"<br><br></div>So suppose I am scripting a tactics games.<br><br></div>- Before pathing a land unit, set default costs for grass, forest, river, mountain<br></div>- Before pathing a forest unit, set low cost for forest, default for others<br></div>- Before pathing a water unit, set low cost for river, higher than default for others<br></div>- Before pathing a mountain unit...etc..<br><br></div>I feel like that would be an easy and intuitive interface for scripters, which would result in effectively unlimited costmaps.<br><br></div>The downside is that method isn't helpful if you want to use regular NPC pathfinding, but you want different NPCs to path with different costs.<br><br></div>What if there was a list of per-NPC-definition per-zone cost overrides?<br><br></div>That would be a pretty simple and clear interface-- but it might be more work to implement, and I am not sure if there are bad performance consequences that I have not thought of yet.<br><br>---<br></div>James<br><br><div><div><div><div><div><div><div><div><div><br><br><div><div><div><div><div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 11, 2018 at 7:56 PM Ralph Versteegen <<a href="mailto:teeemcee@gmail.com">teeemcee@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>(Long train of thought leading to some conclusions, included only to indicate my reasoning)<br></div><div dir="ltr"><br>What our A* implementation is missing is some way to customise the cost of moving to a tile. It's just a matter of deciding how to specify the costs. Call that a "costmap". I was discussing this with kylekrack, who wanted to use them.<br><br>I would like to have the ability to have multiple costmaps - that's quite important for tactical games, and for flying/swimming NPCs or vehicles.<br>We don't necessarily need to support an unlimited number - e.g. 3 would probably be enough for almost anyone.<br><br>If we had multidimensional arrays in HS, clearly we should have a way to pass a 2D array of costs to a pathfinding function, but that doesn't cover pathfinding for normal movement by NPCs unless you're going to script it.<br>(For efficiency it would be best if these were "typed arrays", like FB arrays, numpy ndarrays or javascript typed arrays - meaning they can only store numbers, not objects. We would want these anyway, for accessing tilemaps/passmaps/etc and sprite pixels.)<br><br>An obvious way to specify costs would be zones... but you would need a different zone for each different cost value, and how do you support multiple costmaps? Lower zone IDs override higher ones? Plus reading zones is relatively slow, especially if you need to check every zone on a tile; it would probably slow down pathing a lot unless caching is used and the cache isn't recreated every tick.<br><br>Another obvious solution is to use a tilemap. But just using the tile IDs as costs? Then they aren't tiles; this would be a costmap, basically the same thing as a foemap, with a different purpose. With its own map editor mode? You could use the Paint tool to set the same cost on each tile, but that would be unnecessarily laborious. I can't see the need for a costmap editor.<br><br>Assigning a cost to each tile in a tileset and using a tilemap to specify costs is a more obvious and far easier to use solution.<br>But... which map layer to use? That has to be a setting somewhere. And how to support multiple cost maps? You could use different map layers, but that's going to be a problem if you want cavalry units and soldier units which have different costs for the same terrain, hence they should inspect the same map layer. Sounds like you'd want multiple cost lookup tables for the same tileset.<br>And if you use a single map layer for costs, that places heavy constraints on how you split your tiles across map layers.<br><br>Maybe this is silly, and there's little desire to have cost maps for normal NPC or hero movement as they'll only be used for scripted movement?<br>What are the uses of costmaps for normal NPC/hero pathing movement? Having the hero avoid walking on grass. Chase NPCs which follow something other than the shortest path, for a puzzle...  There don't seem to be many.<br><br>Hence we can just add some script commands to read/write costmaps? Just like reading/writing map layers - multiple costmaps can be treated the same as multiple map layers. No "create costmap" and "delete costmap" commands, only maybe "set number of costmaps".<br>And there's always the option to add an editing mode to the map editor for costmaps later. Since cost maps and foe maps are practically the same, they could even be merged.<br><br></div></div>
_______________________________________________<br>
Ohrrpgce mailing list<br>
<a href="mailto:ohrrpgce@lists.motherhamster.org" target="_blank">ohrrpgce@lists.motherhamster.org</a><br>
<a href="http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org" rel="noreferrer" target="_blank">http://lists.motherhamster.org/listinfo.cgi/ohrrpgce-motherhamster.org</a><br>
</blockquote></div>