tureptor / terraoptifind

Finds optimal NPC housing combinations for Terraria
MIT License
3 stars 4 forks source link

Truffle not restricted to Mushroom biome only + Suggestion #2

Closed bryanclst closed 2 years ago

bryanclst commented 2 years ago

Actual issue this time: The Truffle can appear in biomes aside from the (surface) Mushroom biome on the calculator. Easiest way to see this happen is to increase Clothier's priority.

Unrelated suggestion: It would be good to add an option to require certain biomes to have a town in them (specifically, the biomes which have pylons). Optimally, there could be a checkbox for each individual biome, as well as one to force every pylon biome to appear.

tureptor commented 2 years ago

Nice spot. I'll have a fix for that out in the next couple of hours.

The suggestion is a good/useful idea, but my initial guess is that it will be tricky (but possible) to implement it in a way that keeps the fast computation times.
I'll start trying to implement it today, but it will likely take me a week or so to have a faster version.

tureptor commented 2 years ago

A fix is out for the Truffle problem (7184ba23fccf35f793cf349b2745d45678c2672e)

tureptor commented 2 years ago

Had a look at your update to the wiki guide, it was an interesting read.

I've released a new version which implements your suggestion, and it helped me compute an all-pylons-covered/tinkerer-prioritising variant which narrowly beats your recommended layout.

biome npcs
Forest Zoologist(0.84), Golfer(0.84)
Forest Merchant(0.89)
Desert Nurse(0.84), Arms Dealer(0.79)
Underground Hallow Tavernkeep(0.79), Demolitionist(0.79)
Hallow Party Girl(0.79), Wizard(0.89)
Underground Snow Goblin Tinkerer(0.75), Dye Trader(0.95), Mechanic(0.79)
Jungle Dryad(0.84), Painter(0.79), Witch Doctor(0.84)
Ocean Stylist(0.84), Angler(0.89), Pirate(0.83)
Snow Santa Claus(0.84)
Snow Steampunker(0.84), Tax Collector(0.89), Cyborg(0.84)
Mushroom Guide(0.89), Clothier(0.84), Truffle(0.83)

It has a pricing modifier sum (excluding the guide) of 20.06, beating the current recommended by 0.01 (lmao)

It moves the Nurse/Arms Dealer from the forest to the desert, moves the Clothier from the snow to the mushroom biome, and moves the Steampunker/Cyborg from the desert to the snow.

The pricing modifier changes are

Merchant +0.05 Steampunker +0.05 Truffle +0.04 Arms Dealer -0.05 Cyborg -0.05 Clothier -0.05

Back to the calculator update, one change you may notice is that previously, if a group could be placed in multiple biomes, but all the groups were otherwise the same, this counted as a single solution. Now, each biome placement of that group is considered to be a different solution.
For example, one row in a solution from the former calculator could be "Hallow, Caverns Tavernkeep(0.79, 0.84), Demolitionist(0.84, 0.79)". In the new version, this becomes two separate solutions: one in which the pair is in the Hallow, and another in which they're in the Caverns.
This was necessary for correctly implementing the pylon coverage requirement, but it's kinda annoying to lose the compactness. I'll change this back soon™, and I'll also make it show the individual pricing modifier changes between adjacent solutions (stealing this idea from your wiki write-up). Let me know if you have any other ideas/requests.

bryanclst commented 2 years ago

Nice! I'm surprised I missed some of these changes. The pylon update is great, this will make it more useful to people discovering the calculator outside of the happiness guide.

It's finals week for me right now, but soon™ I'll finish the wiki guide and incorporate this solution. Also, I believe you missed one change due to combinational biomes: Clothier can be moved the Underground Snow/Ice biome with the Tax Collector (in a new town). Clothier's price modifier stays the same, but Truffle's will go down by 0.04. So, in fact, your layout beats mine by 0.05 with this tweak!

I will definitely prioritize the Arms Dealer over the Merchant by moving him and the Nurse to the Desert (and add a tradeoff note), but I believe Steampunker should be moved to the Desert since she is a far larger money-sink than the Cyborg, even for rocket launcher users. Solutions are much more expensive than rockets, not to mention the Clentaminator itself (Teleporters and Conveyor Belts too for wiring users). Prioritizing Steampunker unfortunately has the effect of forcing Clothier and Tax Collector to be the Surface Snow residents again, which is fine unless you are a vanity collectionist, probably. I'll include this Steampunker/Cyborg+Clothier tradeoff as a note as well.

As far as other ideas, you've probably already thought of this one: combinational biomes. This seems to be the last element missing from the calculator that requires post-calculation tweaking to get an optimal setup. This probably isn't feasible to implement completely, though. For example, a combination of Underground, Hallow, Desert, and Ocean is valid (I tested), so interactions can get pretty ugly. Just figuring out a list of every allowed combination would be time-consuming, not to mention how this would impact calculation time. A less complete form might be more reasonable, one that only includes the more important ones like Underground Snow/Hallow.

While writing this I also realized the Hallow Desert can be used to optimize the Nurse/Arms Dealer, which I think I'll include as an extra optimization in the notes (I'll move the Tavernkeep/Demolitionist Hallow optimization there as well), since Hallow combinations can only be done in Hardmode, and usually take some extra work with converting/containing biomes. More casual players probably don't need to see these minor optimizations, so I think they're better as notes.

One more thing about the happiness system: Sets of three neighbors can be placed so that the 2 outer NPCs do not recognize each other, but the middle NPC recognizes both. This has scary implications for the complexity of a truly optimal setup, so I've simply ignored it. The most obvious application of this is where NPC A and C dislike each other, but both like NPC B. It could be set up so that NPC A and C are 25+ blocks away from each other, but NPC B in the middle will be close to both. Additionally, chains of towns could be made, with each NPC only having 2 neighbors, but 4-6 NPCs being interconnected (6 is the max for the 120 tile limit). I can't even imagine calculating optimal setups while taking this into account, but I thought I'd mention it.

Sorry for rambling. There's so much more to consider for this guide than I bargained for! Thanks again for your work on the calculator.

Edit: It would be nice if the Princess could be added as well. At first, I thought it didn't matter since including her is easy: just put her with a set of 2 NPCs with the highest numbers. However, I realized that replacing the Dye Trader with the Princess keeps Tinkerer's price to minimum, lowers Mechanic's a bit more, and allows the Dye Trader to be in the Desert with Nurse/Arms Dealer. This feels as if it may actually be the most optimal way to use the Princess (with Tinkerer prioritization, at least), but you never know what the calculator might uncover.

tureptor commented 2 years ago

Nice! I'm surprised I missed some of these changes. The pylon update is great, this will make it more useful to people discovering the calculator outside of the happiness guide.

Glad to hear it. It was easier to implement than I thought.

It's finals week for me right now, but soon™ I'll finish the wiki guide and incorporate this solution. Also, I believe you missed one change due to combinational biomes: Clothier can be moved the Underground Snow/Ice biome with the Tax Collector (in a new town). Clothier's price modifier stays the same, but Truffle's will go down by 0.04. So, in fact, your layout beats mine by 0.05 with this tweak!

Good luck with your finals, I have uni exams next month too. Looking forward to the finished wiki guide.
Yep, that change would be better - a cool 4 gold discount on the autohammer.

I will definitely prioritize the Arms Dealer over the Merchant by moving him and the Nurse to the Desert (and add a tradeoff note), but I believe Steampunker should be moved to the Desert since she is a far larger money-sink than the Cyborg, even for rocket launcher users. Solutions are much more expensive than rockets, not to mention the Clentaminator itself (Teleporters and Conveyor Belts too for wiring users). Prioritizing Steampunker unfortunately has the effect of forcing Clothier and Tax Collector to be the Surface Snow residents again, which is fine unless you are a vanity collectionist, probably. I'll include this Steampunker/Cyborg+Clothier tradeoff as a note as well.

I agree with this, the solutions always leave a hole in my wallet. For the vanity collectionist, they could always just have the (Clothier,Tax Collector)+snow pylon a little underground.

As far as other ideas, you've probably already thought of this one: combinational biomes. This seems to be the last element missing from the calculator that requires post-calculation tweaking to get an optimal setup. This probably isn't feasible to implement completely, though. For example, a combination of Underground, Hallow, Desert, and Ocean is valid (I tested), so interactions can get pretty ugly. Just figuring out a list of every allowed combination would be time-consuming, not to mention how this would impact calculation time. A less complete form might be more reasonable, one that only includes the more important ones like Underground Snow/Hallow.

I've been planning on implementing this ever since I saw the recommended layout's use of hybrid biomes, but I've been a little busy over the past couple of days. I've figured out the mental groundwork of how to make the changes, so I'll be able to start implementing it very soon (whenever I have a nice chunk of free time, which will probably be on Thursday). It would increase calculation time in two ways:

  1. By increasing the "generating cache". This is normally pretty short (<0.2 seconds on my machine), so even in the worse case where I consider EVERY possible biome combination (i.e. a hybrid of all 8 biomes), this would still be around 6.4 seconds in the very worst case (this is assuming 2^8 biome combinations - it is likely a lot smaller due to the combination restrictions). Also, I can probably find a way to speed up that phase - I've spent most of my effort on the "find best solution" time since that is pretty much always way slower.
  2. By making the "pylon coverage" part in the "find best solution" section slower. If it does slow down significantly here, I'll need to put some thought into the algorithm here. The naive (easiest to code) solution would be exponential in terms of the number of hybrid biomes, so it will probably be too slow. I will definitely add a feature which lets people cap the number of biomes in a hybrid, since I doubt most people will want to deal with combinations containing more than 3 biomes. The main 3-biome combination I can think of that is easy to build around is the underground Hallow Desert.

While writing this I also realized the Hallow Desert can be used to optimize the Nurse/Arms Dealer, which I think I'll include as an extra optimization in the notes (I'll move the Tavernkeep/Demolitionist Hallow optimization there as well), since Hallow combinations can only be done in Hardmode, and usually take some extra work with converting/containing biomes. More casual players probably don't need to see these minor optimizations, so I think they're better as notes.

I agree, a simple note like "sprinkle some holy water in their home after hardmode" would suffice.

One more thing about the happiness system: Sets of three neighbors can be placed so that the 2 outer NPCs do not recognize each other, but the middle NPC recognizes both. This has scary implications for the complexity of a truly optimal setup, so I've simply ignored it. The most obvious application of this is where NPC A and C dislike each other, but both like NPC B. It could be set up so that NPC A and C are 25+ blocks away from each other, but NPC B in the middle will be close to both. Additionally, chains of towns could be made, with each NPC only having 2 neighbors, but 4-6 NPCs being interconnected (6 is the max for the 120 tile limit). I can't even imagine calculating optimal setups while taking this into account, but I thought I'd mention it.

To implement this, I would have to switch the structure from a list of groups of neighbours to a gridlike structure (since vertical chains would be possible as well). This wouldn't be infeasible alone, but the harder part would be verifying if biome selections are feasible (i.e. would need a bunch of rules like we can't have forest beneath other biomes, or desert - ocean - desert horizontally). I might (15% chance?) implement this for fun in the summer without the biome verification rules, since players probably wouldn't bother with the stringent distance requirements, and in theory we could always e.g. construct artificial biomes in the sky to work around the rules.

Sorry for rambling. There's so much more to consider for this guide than I bargained for! Thanks again for your work on the calculator.

Not at all, your comments are fun to read through, and your bug reports are useful (especially the reproduction steps). I'm sure the final guide will be awesome.

Edit: It would be nice if the Princess could be added as well. At first, I thought it didn't matter since including her is easy: just put her with a set of 2 NPCs with the highest numbers. However, I realized that replacing the Dye Trader with the Princess keeps Tinkerer's price to minimum, lowers Mechanic's a bit more, and allows the Dye Trader to be in the Desert with Nurse/Arms Dealer. This feels as if it may actually be the most optimal way to use the Princess (with Tinkerer prioritization, at least), but you never know what the calculator might uncover.

I'll implement her soon, probably tomorrow since I think it will be a pretty easy addition.

Also, RE: the GUI change in my previous comment, I have a better idea in the works, but it will take longer. Look forward to stuff like icons in all tables, a way of comparing any two solutions, and few more things.

bryanclst commented 2 years ago

Thanks for all your feedback on the guide choices, and I'm looking forward to the new implementations. I'll go ahead and close this since you made those new, more specific issues.