Identifying connected puzzle nodes?

Galdon2004

  • *
  • Posts: 275
I am working on a puzzle mechanic as part of one of the games I am working on. An idea I have is to be able to tether nodes together to combine their values, or cut connections between nodes to separate their values again. I am thinking as far as the player interaction goes, being able to draw connections between nodes, or sever the connections between two nodes. Then for each master node to check the values of all nodes connected to it. The objective for the player would be to efficiently create webs of values that give them one or more win conditions, with as few moves as possible.

I can picture ways to allow the player to draw connections and break connections. Something I am having trouble with, however, is figuring out a way for the game to understand which nodes are connected to one of the master nodes, and for it not to mistake, for example, two isolated nodes connected by one of the master node's connection types for being a part of the network.

Does anyone have any ideas on what sort of coding technique I should look into for doing this sort of thing? I don't expect to just have the whole thing written out for me but I am not sure what exactly to look into for designing this sort of behavior. I've attached a rough drawing of what I am trying to do to this post to hopefully make it easier to understand.

Luyren

  • *
  • Posts: 1916
For reference, I handle something like node connections for pathfinding. I store each node in a list, with the following format:
Node data/Connection Index,Connection Index, (...)

So I have the relevant information for that node (in my case, X and Y positions), a forward slash, and then a list of all the indexes (in this list) of the nodes connected to this one, separated by commas. You can use the split text and the list getters to retrieve this information.

For altering the connections list, you can get the whole given index as a text, find the position you want to add or the node you want to remove, and make operations with the text.

If each of your nodes can only have one connection, then you can just do "Node Data/Connection Index." Building a path would be looping a number of times equal the number of items in your list. You start at a node, then go to its connection, and so on and so forth until you reach your target or win condition (at which point you should exit the loop).
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles and many more.
Twitter

merrak

  • *
  • Posts: 2527
You can use A* if the nodes can have multiple connections.

Galdon2004

  • *
  • Posts: 275
Can an A* algorythm be used with block code? I might have to actually learn how to do raw code if it is necessary for it... I have a rather simplistic way of doing everything. xD

Luyren

  • *
  • Posts: 1916
Can an A* algorythm be used with block code?
Yes, it's possible with blocks.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles and many more.
Twitter