Map Database  •  FAQ  •  RSS  •  Login

Random Map Generator

<<

Rey

User avatar

KaM Remake Developer

Posts: 217

Joined: 12 Oct 2016, 07:41

KaM Skill Level: Fair

Location: Moscow

Post 02 Mar 2017, 05:30

Re: Random Map Generator

What was your FPS during that clip? Did the script have an impact or was it about the normal FPS?
It was about 25-30 FPS on my pretty good PC. Not so much ofc, but there was full map update on every tick (~0.1 sec) for 80*80 map.
When I changed it to update on every second tick - it become about 45-50 FPS, but much less smother. Normal FPS on that is about 60 for myPC.

It was a test to show how fast this operation can be. And for map generator purposes or changeing map once its fast more then enougth even for slow PCs.

Or some scripters can use it on some crazy maps, such as Magic Arena, but better for only part of the map, considering FPS :)
<<

thibmo

User avatar

Council Member

Posts: 124

Joined: 03 Aug 2015, 09:12

KaM Skill Level: Skilled

Website: https://kp-wiki.org/

Location: the Netherlands

Post 02 Mar 2017, 08:34

Re: Random Map Generator

It was about 25-30 FPS for a full map update on every tick (~0.1 sec) for 80*80 map.
Not bad, I also highly doubt that scripters will generate sine-waves for actual maps, though. :P
Or some scripters can use it on some crazy maps, such as Magic Arena, but better for only part of the map, considering FPS :)
That's what I meant, but with some added logic you could even make a full RTS-RPG with this, changing lands from grass to desert, from mountains to a shore, etc. and that all with nice random or static seeds. :)
~~ The magic wizard of PascalScriptus. ~~

KP-Wiki :
  • Information about Knights Province scripting ( unofficial )
  • Information about several hosting/server maintenance basics
  • Other random stuff
<<

thunder

User avatar

Moorbach's Guard

Posts: 1044

Joined: 15 Apr 2012, 12:11

KaM Skill Level: Fair

Location: In the Market

Post 02 Mar 2017, 14:39

Re: Random Map Generator

https://youtu.be/UJ30WRNXBZ8?t=116
AS like an earthquake :mrgreen:
<<

Toxic

Rogue

Posts: 50

Joined: 22 Feb 2017, 19:04

Post 02 Mar 2017, 17:55

Re: Random Map Generator

With new function I easily make sine wave on terrain from script, it took just a few milliseconds.
Good job!
So all other time it was script execution. I believe problem is that execution in pascal script is significally (may be 100 times) slower then in main game code.
How do you measure the script functions' time? Have KaM implemented this feature? When I run DiamondSquare in Matlab it will take cca 45 milisecond (including declaration of arrays, calculation with double precision and drawing plot - none of this is implemented in the function DiamondSquare()). Even though we have different PCs, dynamic scripting must be significantly slower.
<<

Rey

User avatar

KaM Remake Developer

Posts: 217

Joined: 12 Oct 2016, 07:41

KaM Skill Level: Fair

Location: Moscow

Post 02 Mar 2017, 19:11

Re: Random Map Generator

How do you measure the script functions' time? Have KaM implemented this feature?
For testing purposes I added TimeGet function, it returns unix time in milliseconds.
There are some restrictions why we did not add this function to scripts. But we could add this (and some other usefull functions, f.e. smth like OnUnitSelected/OnHouseSelected) for single player games. For MP games these functions could make game inconsistency if used unproperly.
But still there are few things that could be done with them even in MP, without any problems (f.e. Actions.ShowMsg and Log), but we are not sure can we rely on script maker's awareness or not, because it can make unpredictable script errors (which depends on some local info - time/when user selected house etc - which is not synchronised between players). Not sure if I described this problem clear, but I tried :)
<<

Toxic

Rogue

Posts: 50

Joined: 22 Feb 2017, 19:04

Post 02 Mar 2017, 20:19

Re: Random Map Generator

But we could add this (and some other usefull functions, f.e. smth like OnUnitSelected/OnHouseSelected)...
These are actually really useful events. It should help players to understand some scripts (they don't read pdf) by uploading Overlay of specific player for example in Caravan script. I am not afraid of desynchronization - if you add note to this command it will be fine.
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 03 Mar 2017, 05:32

Re: Random Map Generator

(they don't read pdf) ... if you add note to this command it will be fine.
Sounds contradictory ;-)


Desync errors are very easy to introduce by mistake and it's very hard to detect their cause when a crash happens.

If possible, we would keep functions that could introduce them out of the scripting engine.

Many of the requested features (e.g. measuring time) could be done without exposing such functions.

E.g.
- timeGet can be easily replaced with BeginPeriod / EndPeriod, with the latter appending text into the log.
- OnHouseSelected could be possibly replaced with Action.TextOnHouseSelect(House.UID, text_to_show).
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Toxic

Rogue

Posts: 50

Joined: 22 Feb 2017, 19:04

Post 03 Mar 2017, 19:15

Re: Random Map Generator

(they don't read pdf) ... if you add note to this command it will be fine.
Sounds contradictory ;-)
I don't think so - first sentense was about players and the other loghicaly about scripters.
Action.TextOnHouseSelect(House.UID, text_to_show)
This action could return true/false if player had clicked on it since last calling of this action.
Or to add aditional parameter time when this text cannot be overwriten by Actions.OverlayTextSet.
<<

Rey

User avatar

KaM Remake Developer

Posts: 217

Joined: 12 Oct 2016, 07:41

KaM Skill Level: Fair

Location: Moscow

Post 03 Mar 2017, 20:32

Re: Random Map Generator

This action could return true/false if player had clicked on it since last calling of this action.
No it can't work this way. Because you will be able to check this on every state, and when house was selected alter game state when one player clicked on smth, f.e. add wared to house, but other players will be not notified about this event (selection) so they will not add wares to that players house. Desyncronisation will occur.

So we can just simply show some text or log smth on some event, but we can't allow to know when did it happen
<<

thibmo

User avatar

Council Member

Posts: 124

Joined: 03 Aug 2015, 09:12

KaM Skill Level: Skilled

Website: https://kp-wiki.org/

Location: the Netherlands

Post 03 Mar 2017, 22:06

Re: Random Map Generator

This action could return true/false if player had clicked on it since last calling of this action.
This could better work if you return an ID, then when it gets clicked perform an event eg: OnHouseWithEventClick(aEventID: Integer);

Like that you could perhaps include it into MP by sending the event trigger to all other players. (True, brings possible issues, though it's cleaner then the previously stated)
These events could perhaps even be callbacks? (Not sure how that will work out, might be used maliciously, which I would advise against.)
~~ The magic wizard of PascalScriptus. ~~

KP-Wiki :
  • Information about Knights Province scripting ( unofficial )
  • Information about several hosting/server maintenance basics
  • Other random stuff
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 04 Mar 2017, 07:23

Re: Random Map Generator

(they don't read pdf) ... if you add note to this command it will be fine.
Sounds contradictory ;-)
I don't think so - first sentense was about players and the other loghicaly about scripters.
What I mean, is that placing a text anywhere in the docs does not mean it gets read or taken into account. Be it by players, or by mapmakers, or by programmers (like me). It should be at least a warning in ScriptValidator to be seen.
Action.TextOnHouseSelect(House.UID, text_to_show)
This action could return true/false if player had clicked on it since last calling of this action.
Or to add aditional parameter time when this text cannot be overwriten by Actions.OverlayTextSet.
Text management could be done from within script itself.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Rey

User avatar

KaM Remake Developer

Posts: 217

Joined: 12 Oct 2016, 07:41

KaM Skill Level: Fair

Location: Moscow

Post 04 Mar 2017, 07:55

Re: Random Map Generator

Like that you could perhaps include it into MP by sending the event trigger to all other players
In that case its possible to add OnHouseSelected. But it could provide too many extra packets. Some tests should be done in that direction to be sure it will be ok.
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 04 Mar 2017, 10:20

Re: Random Map Generator

Like that you could perhaps include it into MP by sending the event trigger to all other players
In that case its possible to add OnHouseSelected. But it could provide too many extra packets. Some tests should be done in that direction to be sure it will be ok.
Also take into account, that if done through GIP, it will lag just like other commands.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 08 Mar 2017, 06:43

Re: Random Map Generator

Sometimes happens: "EAssertionFailed: UpdateWalkConnect failed due too many unconnected areas" in file KaM Remake\Trunk\src\KM_TerrainWalkConnect.pas, line 294.
This occurs when more than 255 separate "islands" are created on the map. As an optimisation the pathfinding code assumes there will never be more than 255 different islands (which is fine for normal maps). For example this would probably happen if you set the height of all tiles on the map to a random value since you will end up with lots of disconnected islands of 2-3 tiles.

Desynchronisation breaks singleplayer replays as well, so it's not just a multiplayer issue. As Krom said there are alternative ways to implement timing logs like BeginPeriod / EndPeriod. Desynchronisation bugs are extremely difficult to track down since they will usually occur a long time after the desynchronisation occurred in some other random place. I'm strongly against adding anything to the API which allows scripts to cause desynchronisation as it puts too much onus on the script authors to follow arbitrary guidelines, and desynchronisation crashes will make the game appear buggy and be misattributed to the game rather than the script. Right now it's basically impossible to crash the game from the script which is a great thing IMO.

PascalScript is executed as bytecode, it's not going to be nearly as fast as compiled code. If you implemented your random map generator in the native KaM Remake code your performance issues would stop being a problem, and you would also avoid having to reimplement your terrain painting functions (managing tile transitions) since we have those already. I'm happy to help you get it compiling on your machine if you are interested.
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 08 Mar 2017, 06:58

Re: Random Map Generator

Desynchronisation bugs are extremely difficult to track down since they will usually occur a long time after the desynchronisation occurred in some other random place. I'm strongly against adding anything to the API which allows scripts to cause desynchronisation as it puts too much onus on the script authors to follow arbitrary guidelines, and desynchronisation crashes will make the game appear buggy and be misattributed to the game rather than the script. Right now it's basically impossible to crash the game from the script which is a great thing IMO.
Well said. I fully agree.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 7 guests