* Red and blue players take turns adding bombs to squares. * When a square has the same number of bombs as the number of adjacent squares then it explodes throwing bombs into neighbouring squares. * The square belongs to the player that last put a bomb in it by clicking or by explosion. * Players can't click on squares owned by their opponent. * The winner is the player that eliminates all their opponent's colour.
v2 Update 19/2/2017: So the race conditions were making this game too unreliable. A race condition is where two scripts are running at the same time and one manages to stop the other working right. All the timers I had in there were designed to avoid letting that happen but it still did sometimes and it meant that sometimes a square would explode and not throw bombs into adjacent squares like it should. So I've done an almost complete re-write and now I control the explosion process through a series of ticks issued from the stage. It runs through every square setting global x and y variables then sending broadcasts to make sure each square gets its own turn to explode before resetting all the costumes and then moving onto the next square. It's much more rigidly controlled and it doesn't rely on timers to avoid race conditions. Pretty hard to understand, though, even for me and I wrote it. v1: This is really hard to do right without a 2 dimensional array. I wanted to make each square a cloned object with its own logic that responds to what happens around it. It's almost a life simulation type of concept. The wait timers are crucial to making this work without race conditions causing massive problems. Also key is to not have too many clones so there aren't too many concurrent threads. It's sort of an experiment that mostly works. Occasionally you'll see a square explode and the neighbours won't get bombs added. But for the most part it works pretty well. Still need to add some code to count the number of squares of each colour. But first I need to figure out a way to know when the explosions have stopped.