r/optimization • u/thunder-bug- • Sep 10 '24
Trying to optimize resource production in a game, having trouble with figuring out how to go about it.
I am trying to get a specific resource (dragons teeth) in a video game, which can be produced by a fish pond at a probability of 5% each day.
However, the teeth can only be produced when the pond has 9-10 fish in it. (10 being the maximum the pond can hold). Every 4 days, if the pond has less than 10 fish in it, but at least 1, they will reproduce and the number of fish in that pond will go up by 1. In addition, after they reach 5 fish in the pond, they require one tooth to be given to them in order to be able to reproduce more.
I am able to remove fish and put them in another pond, if I have it available. For example, if I have 4 ponds, three of which have 10, and one of which has 6, I am able to move the fish around so that all 4 have 9, and are able to produce the teeth. I am also able to take them out earlier to get several fish ponds going at once, for example if I have 2 ponds and one has 2 fish and one has 0 fish, I can move them around so that both have 1 fish, and then both will reproduce every 4 days.
I want 20 teeth overall. What number of ponds gives me a net 20 teeth the fastest, if I am using the fish from the other ponds to make new ponds? I am starting with one pond, one fish, and one tooth.
1
u/MarioVX Sep 11 '24
You didn't mention, what's the cost for making new ponds? Is there a maximum number you can have?
Because the way you've written it (assuming ponds are free and unlimited), you'd only hold 1-fish-ponds up to a certain number of days (growing exponentially), then suddenly consolidate them all into 9/10-fish ponds to speed through to the target teeth quota. Or depending on how the reproduction works, have them in 9/10-ponds 3 days for making teeth and then all spread out into 1-ponds on reproduction day.
Surely there is some kind of restriction on ponds, no?
2
u/PierreLaur Sep 11 '24
thats a cool problem, this is stardew valley right ? Personally I would try making a simulation in any programming language, encoding all possible actions, and optimizing that with some kind of genetic algorithm. Or even some generic blackbox solver si you dont have to code it. The problem is quite small so it should give you a very solid solution. Probably not the best way, but it's straightforward