-
-
Notifications
You must be signed in to change notification settings - Fork 994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements in the name and map generators #661
Conversation
name_generator.reset(new markov_generator(utils::split(markov_list), naming["markov_chain_size"], 12)); | ||
name_generator_factory* generator_factory = nullptr; | ||
name_generator *base_name_generator = nullptr, | ||
*river_name_generator = nullptr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would prefer if you repeat the type name on each line here, rather than declaring several pointers in a single statement. I'm not sure if Wesnoth has an official stance on this though.
Okay, so there's a lot of stuff here. I would have been happier if this had been split into several commits, honestly, but it may be too late to split it up now. (If you want to try, feel free, but keep in mind that splitting commits is kind of difficult in git.) Some of the changes you've made are a little dubious as well. That's not to say that they're bad, strictly speaking, but...
All things considered, it's my opinion that this cannot be merged in its present form. The 3rd point is the main blocker here. |
@CelticMinstrel I readded the |
I don't see where the pointer returned by determine_name_generator_from_config is deleted also i wonder why base_generator_factory is a pointer and just just a normal name_generator_factory object.. Also the name generator api shoudl be moved from game_lua_kernel to lua_kernel_base so that it is also avaialbe to luia random map generators. |
I think you misunderstood my second point. The suggestion was not to remove name_generator_factory.hpp – rather, I suggested that the contents of dummy_name_generator.hpp and dummy_name_generator.cpp should be merged into name_generator_factory.cpp. (Possibly defining all the functions inline, since there's little reason to define them out of line if the class and function definitions are in the same file.) |
|
||
/** | ||
* @file | ||
* Fallback for name generation (to guarantee, that name_generator_factory always returns a valid object reference) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leads to the following question: Why does name_generator_factory
always need to return a valid object reference? It could easily return a pointer or a boost::optional
instead, for example.
I made some changes:
@CelticMinstrel It is a common practise that factories produce Null objects, when they fail to produce any other object. This makes it less error prone, because you always get a valid object and you don't need to check whether it is a null pointer. It also provides a default implementation to reduce code duplication. |
How can I fix the
in the Travis build? The protoypes |
Uhh... what are you talking about? The rest of what you said kinda makes sense (even if I'm not sure I agree with it), but I can see no way in which |
// We set the metatable now, even if the generator is invalid, so that it | ||
// will be properly collected if it was invalid. | ||
luaL_getmetatable(L, "name generator"); | ||
lua_setmetatable(L, -2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhhh... why did you remove these two lines? They're crucial for this to work. (The comment should be retained too.)
I think perhaps an error should be raised in the CFG generator if you attempt to add a nonterminal beginning with $ - a simple conditional throw statement in the condition block at line 41 would suffice, I think. |
Regarding the Travis issue, it's probably because you didn't add the new file to src/SConscript. You should also add it to src/CMakeLists.txt. |
I added the
The Furthermore I removed the unused branch in I should really consider to install SCons, but it requires Python 2.7 and its kitchen sink. (At the moment I have only Python 3.4 installed.) The coding in |
if (seed_pos >= seed_size) seed_pos = 0; | ||
if (picked == got.last_) { | ||
picked = seed[seed_pos++] % got.possibilities_.size(); | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...you know, this else isn't actually needed since the if block always returns. It would make the diff clearer, as well.
Well, I don't see any problems left, though I'd prefer someone more familiar with map generation to review that part of the PR. |
Hmm what random number is used to generate the names dorign map generation? Usually the map generator has its own random generator default_map_generator_job::rng_ that could be used but note that just like with unit the number of random calls should be independent on the name generator (which might depend on trasnlations) to make random mape rproducable with a given seed. Other than that, i doubt there there is someone really familiar with the map generator code, i recently refactoeed it a bit, but i mainly moved functions around, not changing the map generators logic. It would be nice if random map generators coudl be tested before this is merged, that is, the mainline randommp maps with both scenario_generation and map_generation. |
Even if there isn't anyone familiar with the map generator, it would be nice to know that someone other than me has looked through this in some detail (as opposed to just glancing through it quickly). If you've done that, then great. |
While I'm not qualified to review the c++ code, I could take a look and test that it doesn't obviously break anything with the mainline random maps or my own random maps add-on, but that's about it. It would be sometime in the next 7 days or so. |
No i didnd't look into this in deati. It'd be nice if you'd test it in mainline and umc campaigns |
@sigurdfdragon That would be great! Perhaps not quite as great as someone scanning the code for obvious errors, but I suppose it may have to do. It'd also be great if someone tested campaign usages of the random map generator, for example in HTTT. |
httt only used teh cave map generator which doen't use the code in default_map_generator_job.cpp |
@CelticMinstrel I've got an add-on where I can test campaign usage too. |
I just noted that there is a small change in the interface which means that old add-ons may not be compatible with this PR. Because I moved the village and terrain names from |
Hmm. I think it's actually quite likely that an add-on would use I'm not sure what's the best solution, but here's one idea - add a (If anyone has any better ideas, feel free to state them.) |
The issue here is compatibility - as it currently stands, any older random map generators that do use names will no longer work as the creator intended (assuming that they don't use the It would be helpful if we could get some kind of survey of map generator uses in addons on the 1.12 addons server, as well as mainline uses. If it turns out that everyone does use the I think that if ...I also suddenly had the thought that integrating variables into the CFG generator is actually kind of redundant. You could have just as easily used the existing WML variable substitution mechanism - use the CFG generator to generate a string containing WML variable substitutions, then substitute the variables into the resulting string. Maybe it's a little late to suggest making that change, though... |
I am sorry to tell you that I have no time at the moment. Maybe I will have a look at it during the next two weeks. Regards, Spixi |
My idea is the following: I move the default implementations of the name generators back to
The user-defined name generators are merged with the system-defined ones, which means, that user-defined override system-defined name generators. If neither a user-defined, nor a system-defined name generator is found, we generate no name. Then I make Is that okay? If yes, I will do the change in the next weeks (maybe next Saturday). |
That sounds okay, but I think I'd put base_names / base_name_generator in the I'm still having second thoughts on the redundancy of your variables implementation, too. |
Please rebase this branch with master and resolve conflicts. |
you messed up the indention in some files and added some large file 'install_manifest.txt' this must be fixed before mering. |
I somehow messed up my local repository. I am working on it. |
running |
So, I think, it seems to be okay now? |
Okay, I want to merge this pull request soon. However, I am against the variable support in the CFG generator. Is there any reason why you can't do something like this?
Besides that, my only remaining problem is, why do you need the village_ prefix on all the keys in Oh, and since I went and moved the definition of the Lua API, it would be handy if you could do what vultraz said, ie rebase this against master. It's not a blocker, but it would make it more convenient for me to merge. |
Hi @CeltricMinistrel, I care about your remarks tomorrow. A small question: Should it be possible to support dynamic variables, e. g.
which would be identical too
or should the variable substitution come first, which allows things like:
Thank you for your feedback. |
Okay, so I'm glad you mentioned this, because it brought forward an issue with the idea that I suggested. The issue is quite simple, really - the For your actual question, I favour the first way - that is, the CFG could include sequences that vary which construct variable names from smaller parts. Note that your example of what it would be identical to is actually incorrect, as it uses commas instead of vertical bar as the separator. Regarding the problem of
The two obvious ways of implementing an escaping mechanism are:
Anyone have thoughts on this? |
What about a double pipe ( |
If you're talking about making || have special meaning in variable substitution in general: || is very commonly used in cases like $foo_$side_number|| and those cannot be broken. |
I totally forgot about this. The vertical bar was the main problem, that's why I used the comma instead in my comment above. For escaping I have the following suggestion: There are the predefined nonterminals:
This would change the syntax from
to
The variable substitution will be executed after the name generator. Your thoughts? |
That seems okay to me. I'd prefer (Incidentally, I don't think the vertical bar is actually required when it's followed by a single quote / apostrophe - only when followed by a letter, digit, or underscore, and possibly also when followed by a dot or square bracket.) @ln-zookeeper That's not what we were talking about, so no worries. |
Two issues I can still see:
|
I fixed the error with the @CelticMinstrel: Do you think you could do the changes with lua_kernel_base.cpp and the bugfixes mentioned in you comment? |
I suppose I could give that a try. |
Thank you |
Improvements in the name and map generators
This has now been merged. |
The crash I reported on June 7th above with this pr was NOT fixed. I have opened bug report: https://gna.org/bugs/index.php?24864 |
It seems to be fixed by 465ca49 - road names were trying to be generated even if no rules for generating names had been given. |
confirmed fixed, thanks |
This commit contains several improvements in the name generator and map generator:
is_valid()
method has been replaced by an exception, because that is more meaningful than using a shared pointer to delete the object, if it is not valid[village_naming]
has been removed/data/english.cfg
to/data/core/macros/names.cfg