# I need help with this code

**URL:** <https://forum.makecode.com/t/i-need-help-with-this-code/29694>\
**Category:** Help\
**Tags:** graphics-and-math\
**Created:** [July 15, 2024, 12:36am UTC](https://forum.makecode.com/t/i-need-help-with-this-code/29694 "2024-07-15T00:36:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLADEr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blader/32/16422_2.png) [@BLADEr](https://forum.makecode.com/u/BLADEr)\
**Post date:** [July 15, 2024, 12:36am UTC](https://forum.makecode.com/t/i-need-help-with-this-code/29694/1 "2024-07-15T00:36:32Z")

</div>

I am working on a game that uses Cellular Automata to make cave interiors. I’m having trouble with updating the tiles so they flow like liquids. The update goes one step into the algorithm and then stops. I think the problem is happening somewhere in the function “update dungeon (previousImage).” Can someone help? Here is the game: [https://makecode.com/\_g0yAzu0c1447](https://makecode.com/_g0yAzu0c1447)

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [July 15, 2024, 3:13pm UTC](https://forum.makecode.com/t/i-need-help-with-this-code/29694/2 "2024-07-15T15:13:50Z")

</div>

this is really impressive, well done

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/5/e/5ed1e2bb0bc1218bf34d947ff6c20afc09157ca9.png)  
in the debug screen it seems that the update function runs fine so the problem lies somwhere in the function itself  
btw there is a bug with this  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/e/b/eb0a59b4652b4892c0f000f0200949115ea25f90.png)  
when selcting thick caves as i don’t think you’ve defined whichSprite

---

<div class="post-metadata">

**Author:** ![BLADEr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blader/32/16422_2.png) [@BLADEr](https://forum.makecode.com/u/BLADEr)\
**Post date:** [July 15, 2024, 9:03pm UTC](https://forum.makecode.com/t/i-need-help-with-this-code/29694/3 "2024-07-15T21:03:44Z")

</div>

Hey, thanks for pointing that out. I went back and fixed that bug. thank you!

---

<div class="post-metadata">

**Author:** ![BLADEr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blader/32/16422_2.png) [@BLADEr](https://forum.makecode.com/u/BLADEr)\
**Post date:** [July 15, 2024, 9:32pm UTC](https://forum.makecode.com/t/i-need-help-with-this-code/29694/4 "2024-07-15T21:32:27Z")

</div>

I figured out the problem

 ![solved](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/e/de6a62f3b20030f9446c5de36a5c2bea2be793ca.jpeg)

I forgot to reset X and Y, and so the code was inputting pixels after 100.
