itch.io is community of indie game creators and players

Devlogs

Circuit Puzzle Issue

Shutdown
A downloadable game

Author - Cameron Euston


The Issue: 

While I was working on the circuit puzzle, I was running into many issues. In the puzzle, the goal is to link the wires together to connect the power to the end. I was having issues with the check to see if a wire is connected or not. I was having an issue where the connection would not travel past a certain point and also there were a few cases where the program would crash from an infinite loop.

The Solution:

I went through many iterations of solutions. I tried many different methods of searching through the wires and checking the power but none were seeming to work. I eventually noticed after breakpointing through the algorithm that noticing that the wires that randomly cut off had no right neighbors. This caused me to investigate the grid panel and discovered that even though there was not visual gap in the grid, there was no column 4 on the grid. I then moved over all of the columns to the right of column 3 to the left by 1. This fixed the cut off issue but I still had the infinite loop. I break pointed through the algorithm again and discovered that wires that were already marked as powered where getting checked again. This is were I discovered I needed to add a check at the start of the algorithm to see if the wire was already powered. After I added this change, the puzzle worked as intended and didn't crash.

The image below shows the puzzle working as intended.

Leave a comment