-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cells on the edge of the grid causes a crash #13
Comments
I mentionned that in my issue #11 the assumptions the program is making about the cell arrangements is unclear and makes experimenting with it 1000% harder. |
If this helps, I'm pretty sure this happens when running the "pushOut" function in Cell.pde, which ejects particles from inside the cell to outside, and is only ran when the cell runs the "REMOVE WASTE" or "REMOVE FOOD" codons. The cell checks if there are any obstacles in it's way before ejecting waste. These obstacles would be other cells or walls, and it checks them by looking in [x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1] indexes, which is the equivalent to right, left, up, and down. However, when a cell is against the wall and tries to eject a particle, it will check if a cell is in a position which is out of bounds of the cells array. This causes a ArrayIndexOutOfBoundsException error. A solution is to check if the x and y the cell is checking is bigger than the dimensions of the cells array, or the world size (or is negitive). Hopes this gets fixed! |
Just fixed it! Let me know if it doesn't work, thanks! Replace pushOut function in Cell.pde with this,
|
- fixed pushOut function - cells can now be placed anywere - the game won't crash anymore if a cell is surrounded by other cells bugfix by [c00lum](carykh#13 (comment)) Co-Authored-By: c00lum <69761240+c00lum@users.noreply.github.com>
credit for bug fix: carykh#13 (comment)
I was able to fix by setting all cells on the edge to empty (type 0) in
getTypeFromXY
The text was updated successfully, but these errors were encountered: