Godot Version 4.5
I’m building a prototype for a puzzle game, similar to Is This Seat Taken? or A Little to the Left. I want the game to allow multiple valid solutions, but I’m not sure what the best approach is in terms of performance and overall PC resource usage.
I have slots that elements can snap into, and the elements themselves. For an element to enter a slot, I use a slot_in function. The puzzle solution would be represented by a resource of type answer_types, which contains all possible valid answers. Then, for each level, I’d configure a specific resource (for example, level_1_answer). The main problem is how to build a player_answer and compare it against the level_answer.
For example, if I have 5 elements — A, B, C, D, and E — and 4 slots, and A and E are mutually exclusive, then I have two valid solutions:
[A, B, C, D] or [B, C, D, E].
To handle this, I wouldn’t look at the elements themselves, but at their attributes. For instance, I might require attributes 1, 2, 3, and 4. Elements B, C, and D provide attributes 1, 2, and 3, while A and E both provide attribute 4. That way, I can keep both solutions valid.
The mutual exclusion rule could be handled by modifying the element’s slot_in function to check whether a mutually exclusive element is already present in the answer. But that raises a few questions: how do I actually build the player_answer, and how do I compare it with the level_answer? Am I only checking counts of each element or attribute (for example, “I need 2 elements of type A” or “I need 3 elements with attribute 2”)?
One idea I had was for each element to have a copy of answer_types with the values it can contribute, and then add those to the player_answer. But then I run into the same issue again: how do I populate and manage that resource cleanly?
Initially, I thought about using dictionaries, but I’ve read that best practice would be to use resources instead, since they’re easier to edit when defining level answers and help keep the data consistent. I feel like if I were using dictionaries, I’d already have the prototype working, but I’d probably hate myself later when creating more levels hahaha.
I’m still thinking through these options and wanted to hear your ideas for possible solutions. I’ve been looking for tutorials and posts about puzzle game design, but I haven’t found many that go into this kind of problem.