Electronic circuit simulator four-way flood-filling issues

Posted by AJ Weeks on Game Development See other posts from Game Development or by AJ Weeks
Published on 2014-06-06T23:35:35Z Indexed on 2014/06/07 3:49 UTC
Read the original article Hit count: 365

Filed under:
|
|
|
|

I've made an electronic circuit board simulator which has simply 3 types of tiles: wires, power sources, and inverters. Wires connect to anything they touch, other than the sides of inverters; inverters have one input side and one output side; and finally power tiles connect in a similar manner as wires. In the case of an infinite loop, caused by the output of the inverter feeding into its input, I want inverters to oscillate (quickly turn on/off).

I've attempted to implement a FloodFill algorithm to spread the power throughout the grid, but seem to have gotten something wrong, as only the tiles above the power source get powered (as seen below)

half-updating grid

I've attempted to debug the program, but have had no luck thus far. My code concerning the updating of power can be seen here.

© Game Development or respective owner

Related posts about java

Related posts about 2d