If not, the event flips another self-switch that moves onto the "flagged" event page. If "flagged bombs" and "total bombs" are equal, the player wins. If it does, it adds 1 to a "flagged bombs" variable and checks to see if "flagged bombs" equals "total bombs". The bomb page is an action button event that gives the player a choice to "flag" the tile or sweep it.įlagging the tile removes a flag and checks to see if the flagged tile matches a recorded bomb coordinate. The other branch activates a separate self-switch that moves onto the "sweeper" page of the event. It gives the player a flag, adds 1 to a "total bombs" variable, pushes the event's coordinates to an array or variable, and activates a self-switch that moves onto the "bomb" page of the event. The first page of the event is a parallel process that generates a random number and a conditional branch based on that number. However, having the grid means if you need to use it for other things later on, you have it around and don't need to recompute it every time.The bomb randomization and flag management is relatively easy, although it may not scale well depending on how many bomb tiles you'll need. This way, you don't need to have the counter grid and don't need to increment it each time. HiddenGrid = "\033\033Ī different way you could do it is just add this block to the very end after the bomb skip check: count = 0 Next, each time you add a bomb, increment the counter for each grid space that touches it: for a in range(y - 1, y + 2): So, at the top of your function, you could first create a number grid: grid = for x in range(gSize)]. However, to answer your question directly, what I would recommend doing is each time you place down a bomb, you increment a counter for every cell adjacent to it. I would personally recomment storing the bomb array as a numerical array and having a way to process it into the output afterwards.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |