Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Haha, I have never encountered a case where the other side was not accessible either, so I think that's pretty unlikely to happen given the number of mines and size of the playfield. If you'd really like to prevent this you could solve this via a graph search algorithm. Easiest way to do that besides implementing the search yourself is to take some existing pathfinding implementation (super common in game development for enemy AI etc., so there's probably one for Pulp out there) and make it check if there's a path from entry to exit, where mines are impassible obstacles. If the algorithm can't find any path, then simply regenerate the mines and check again.

When I did briefly think about it, I thought it sounded tricky to check every possible path from say, bottom left upwards, then move one along and repeat it - 1)  I had no idea how to code that and 2) I thought it sounded quite intensive for the Playdate, though there's not that many squares so I guess it would be fine. 

Thanks for the link, that's going to be an interesting read.

Come to think of it, the Wikipedia page I linked to is a bit dry and used a lot of computer science and graph theory jargon. The concepts behind it are not very difficult at all though: they boil down to traversing your grid in a particular way while keeping track of which spaces you've already visited. I would instead recommend to Google for "game pathfinding" or "depth-first search" and look for a more straightforward explanation.

Besides graph search there are also "shortest path" algorithms (like Dijkstra's or A*) that give you the shorter path from A to B that doesn't go through obstacles. You don't really need those because you just want to check if the path exists at all. But if you happen to find a library that does shortest path that will also work, because those algorithms will return an error or report that the "shortest path is infinity long" if no path can be found at all. 

All these algorithms are actually very efficient (execution time "scales linearly" depending on the size of your grid). I recently implemented one in Commodore 64 Basic and that worked fine, so for the Playdate it should definitely not be a problem!