jonbaer Posted October 13, 2016 Report Share Posted October 13, 2016 Was trying to patch this myself but could not get much beyond the GUI bit. Essential I didn't like the way some random maps were setup initially and wanted to skip resigning/existing and just restart (or more specifically regenerate the map) - but I could not get the game to restart w/ the same attributes using this bit: Engine.StartGame(g_GameAttributes, Engine.GetPlayerID()); Engine.SwitchGuiPage("page_loading.xml", { "attribs": g_GameAttributes, "isNetworked" : g_IsNetworked, "playerAssignments": g_PlayerAssignments }); I realize MP setup would not be ideal for this but is this something that is possible on a single user game or is it just not that simple to restart programmatically like that? Could this option be added @ some point? 4 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted October 13, 2016 Report Share Posted October 13, 2016 Should be in single player for all map types, really, not just random map. 2 Quote Link to comment Share on other sites More sharing options...
gameboy Posted October 13, 2016 Report Share Posted October 13, 2016 Nice work,guys! Quote Link to comment Share on other sites More sharing options...
elexis Posted October 13, 2016 Report Share Posted October 13, 2016 Is it intended to restart the exact same match again? If you randomize the "Seed" value, you should get another generation of the same random map. (Also the "matchID" should be unique for every game.). (And you should also make sure to call EndGame() or whatever is used currently to exit the game properly (without killing the application (in case that isn't already done by the starting of a new game)). Quote Link to comment Share on other sites More sharing options...
jonbaer Posted October 13, 2016 Author Report Share Posted October 13, 2016 (edited) Ah Engine.EndGame(); got me somewhere. What it looks like happens is g_GameAttributes don't actually populate correctly (since the new game leaves me on Observer mode) + it seems that the seed is the same, so it looks like a few things do need to be handled manually. I'd rather this be done proper though (not a hack) should I put this together as a mod or submit a patch? (not 100% sure if a mod would work in this case). EDIT: OK this is exactly what worked for me, will attach patch shortly ... function restartGame() { let playerId = Engine.GetPlayerID(); let gameAttributes = g_GameAttributes; gameAttributes.settings.Seed = Math.floor(Math.random() * Math.pow(2, 32)); Engine.EndGame(); Engine.StartGame(gameAttributes, playerId); Engine.SwitchGuiPage("page_loading.xml", { "attribs": gameAttributes, "isNetworked" : g_IsNetworked, "playerAssignments": g_PlayerAssignments }); } EDIT: Patch attached (YMMV) restart-menu.diff Edited October 13, 2016 by jonbaer 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted October 14, 2016 Report Share Posted October 14, 2016 The restart patch seems to work as planned. I don't know about the code, but the behavior is correct as I can see. Quote Link to comment Share on other sites More sharing options...
jonbaer Posted October 14, 2016 Author Report Share Posted October 14, 2016 Thanks for testing, I saw an old (2+ years) post on this function ... But didn't find the Trac ticket in mention there, I realize the multiplayer scenario for a restart would be a bit more complicated, so maybe the dialog just says you can not restart an multiplayer game or something. I don't play multiplayer enough to know. Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted October 14, 2016 Report Share Posted October 14, 2016 12 hours ago, jonbaer said: Thanks for testing, I saw an old (2+ years) post on this function ... But didn't find the Trac ticket in mention there, I realize the multiplayer scenario for a restart would be a bit more complicated, so maybe the dialog just says you can not restart an multiplayer game or something. I don't play multiplayer enough to know. Is possible to just disable the button when Multiplayer? No need for dialogue then (maybe just tooltip). Quote Link to comment Share on other sites More sharing options...
jonbaer Posted October 14, 2016 Author Report Share Posted October 14, 2016 Yes. If something like this is called ... Engine.GetGUIObjectByName("menuRestartButton").enabled = !g_IsNetworked; Are you on OSX by any chance? I realize I get the following error after ~20 or so restarts so it might be that EndGame() might not clean up something properly ... ERROR: Failed to create initial buffer. OpenAL error: Invalid Value You lose entire audio output :-\ Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted October 15, 2016 Report Share Posted October 15, 2016 7 hours ago, jonbaer said: Yes. If something like this is called ... Engine.GetGUIObjectByName("menuRestartButton").enabled = !g_IsNetworked; Are you on OSX by any chance? I realize I get the following error after ~20 or so restarts so it might be that EndGame() might not clean up something properly ... ERROR: Failed to create initial buffer. OpenAL error: Invalid Value You lose entire audio output :-\ I have not try more than 1 restart. I can try and test. I am on Windows 10 (unfortunatly) Quote Link to comment Share on other sites More sharing options...
elexis Posted October 15, 2016 Report Share Posted October 15, 2016 Someone should find that ticket or make a new one if there is none. Don't forget the matchID: g_GameAttributes.matchID = Engine.GetMatchID(); If you played with AIs, you should reinit the AISeed as well gameAttributes.settings.Seed = Math.floor(Math.random() * Math.pow(2, 32)); -> That 32 might change again, it were better to unify these 3 attribute changes to a new helper function in gui/common/ and use that helper function in the gamesetup and this new place Indeed the button must be disabled for multiplayer. Multiplayer restarting would be handy, but is more involved as there would have to be new network packets telling the clients to reconnect. Quote Link to comment Share on other sites More sharing options...
FeXoR Posted October 15, 2016 Report Share Posted October 15, 2016 IMO an option in the gamesetup to chose the seed (for non rated games) would be nice to have (with a button like in Atlas to randomize the seed and a vidget to type a specific seed in/show the seed). The default should be "random seed" or something (No seed shown). Restarting a match should also have an option to keep all seeds, only that of the random maps or reroll all (default) IMO. Quote Link to comment Share on other sites More sharing options...
jonbaer Posted October 15, 2016 Author Report Share Posted October 15, 2016 What would be super ideal is if you went to Save and could actually just save the entire map setup (vs. the game) to the Skirmish menu somehow (thus "saving" the seed w/o needing to explicitly know it). I am not even sure if that is possible (to dump a .pmp/.xml like that) but some random maps create really good setups and (currently) that it is a real pain to debug the seed (via the replay file) and need to save into Atlas, etc. BTW I still don't know, are GUI related options like this best done as patches or mods? Quote Link to comment Share on other sites More sharing options...
fcxSanya Posted October 19, 2016 Report Share Posted October 19, 2016 (edited) @jonbaer apparently created a ticket after the last message in this topic: #4284 (linking it here for those unaware and for future reference). > I am not even sure if that is possible (to dump a .pmp/.xml like that) Why should you dump the entire map data if you just want to save the seed (+maybe gamesetup settings)? > BTW I still don't know, are GUI related options like this best done as patches or mods? If it's expected to be included into the game (like in this particular case) then a trac ticket + patch (or a link to github branch/compare page) is welcome and desirable. If it's something experimental, then it's better to package as a mod first to gather some feedback and see if there is an interest in the feature. On a different note, seeing this topic title (and 'Restart' menu option on the screenshot above) I'd rather expect that it will start a new match (rather than return to gamesetup) with exactly the same settings (random map seed in particular). I'd call the implemented behaviour 'Back to gamesetup' or something (but I can't came up with a better name). Don't take this as a critique, it's just a subjective opinion/expectation. Edited October 19, 2016 by fcxSanya Struckthrough the gamesetup note caused by misundestanding of the patch 1 Quote Link to comment Share on other sites More sharing options...
jonbaer Posted October 19, 2016 Author Report Share Posted October 19, 2016 I don't know if this will relate to all cases but this is just my own example, the one random map I enjoy playing the most is Archipelago (revealed/explored) for it's geostrategic nature (markets, chokepoints, islands, etc), and every now and then there is very good re-playable map it generates which I want to save. Outside of being a developer this type of option is a bit hard to do w/o having to save the entire game. Setting this up in Atlas is a bit of work as well. BTW w/ this patch you don't go back to the game setup, it will just re-seed and bring you to the loading screen w/ those game attributes. I see what you mean though - a "Restart" in theory is not a "Reset" (all attributes the same) - and might lead to confusion(?) ... someone would say "I selected Restart but it gave me a different map", etc. 1 Quote Link to comment Share on other sites More sharing options...
fcxSanya Posted October 19, 2016 Report Share Posted October 19, 2016 @jonbaer > <...> and every now and then there is very good re-playable map it generates which I want to save I agree that this might be desirable to replay the favorite random map instances, but shouldn't be saving only the seed (+map name) enough to renerate the same instance? > <...> you don't go back to the game setup Oh, I didn't try the patch itself and re-reading the topic now I'm not sure where I've got that, probably was confused by last two posts by you and FeXoR where you disussed selecting/saving RMS seeds. Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted October 19, 2016 Report Share Posted October 19, 2016 (edited) Why not generate a code for random map? Edited October 19, 2016 by Lion.Kanzen Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted October 19, 2016 Report Share Posted October 19, 2016 (edited) here a version in english, this can be great to seed in map settings. I can generate same map with a code. Even empire earth have this option. Edited October 19, 2016 by Lion.Kanzen Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted October 19, 2016 Report Share Posted October 19, 2016 this feature is missing in Aom and Aoe 3 both are partially same graphic engine and the editor is almost same. Quote Link to comment Share on other sites More sharing options...
jonbaer Posted October 19, 2016 Author Report Share Posted October 19, 2016 Interesting, yeah I think when I initially thought of this I set out on the idea that I could somehow magically generate a large preview of seeded maps to see what they looked like (under Archipelago) and then I previously asked where to find the seed ... https://wildfiregames.com/forum/index.php?/topic/21055-random-maps-question-random-seed/ What I get afraid of is people just not understanding what the seed means (it's more for programming terms). Imagine I want to share the map w/ you, I know you would know what the seed does and where to place it but in other ways it would be ideal to just people able to save the seed under a name and send a .zip that includes map info, seed, preview, etc. I don't even know if what I am thinking of applies to anything really outside of the Archipelago scripts so I am still thinking about how to handle in the UI. Based on the graphics you show from the other games it would make sense to extend a Map Type to be where you could seed. Are there any open Trac tickets for that? 2 Quote Link to comment Share on other sites More sharing options...
FeXoR Posted October 19, 2016 Report Share Posted October 19, 2016 (edited) @fcxSanya To generate a random map the seed, the player data (slot, civ, team for each player) and the map size is needed (and ofc. the random map script itself). (And I also would assume that "restart match" or something generates the same map and seed) @Lion.Kanzen Please don't call it "code", it's the seed Nothing magical going on here, it's basically just the index of the first used bit in that - quite long - (pseudo) random long raw of bits where all the random values then come from (sometimes it's given as hexidicimal rather than decimal so it may look like a code). If I'm to technical, ignore me ;p @jonbaer While this is possible in theory generating a map needs several seconds (like 1-80, I'd guess about 10-20 on an average system, normal or medium map size) and to loading it in the engine to render and then take a screenshot again takes several seconds (I'd say about 10?). So it might take quite some time to take screenshots of, say, the first 100 seeds of a random map ... like 2 hours CPU lock. I'm not against adding such a feature but don't use it as an argument "those random maps generate to slow"... (And I'm quite sure if we implement an actual generation for the given player settings as preview I will point back to this post ;p) Edited October 30, 2016 by FeXoR Fixed a typo Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted October 19, 2016 Report Share Posted October 19, 2016 Sorry hehehe, I didn't remember the concept name, for me is similar to color code in Photoshop. Quote Link to comment Share on other sites More sharing options...
GunChleoc Posted October 20, 2016 Report Share Posted October 20, 2016 We could call it "ID" or something similar instead of "seed". Quote Link to comment Share on other sites More sharing options...
elexis Posted October 20, 2016 Report Share Posted October 20, 2016 To generate the same map again, one needs to have the same number of players, their civs, their team numbers, mapsize, mapname and seed. Hence I don't see players profiting from specifying the seed in the gamesetup. 1 Quote Link to comment Share on other sites More sharing options...
jonbaer Posted October 20, 2016 Author Report Share Posted October 20, 2016 I agree, right now I am trying to add a little checkbox to the restart dialog to specify if you want to reseed. This seems to be the best (of both worlds) options. I started thinking it might not even be in the best interest to propose game (map previews) in cases where players don't want an explored/revealed map, in which case my "research" into this might just be one-case hack in cases where I just want to see the variation of the maps I enjoy playing. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.