This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Lion4ever's profile picture

Minesweeper with Pistons

Started by Lion4ever, 10 December 2015 - 12:48 AM
Lion4ever #1
Posted 10 December 2015 - 01:48 AM
This is a very simple program which generates a minesweeper game in your wolrd. Each spot is 3*3 and 4 blocks high and can be activated with the stone plate on top. The number on blocks pushed up by the pistons indicate the number of surrounding mines.

pastebin get rg3Bx79Z minesweeper
minesweeper [cells in x-dir] [cells in z-dir] [mines] [min x corner of board] [min y] [min z]
Bomb Bloke #2
Posted 11 December 2015 - 01:57 AM
I stepped on a mine. It was glorious.

Spoiler

It would be nice if the script could be run without parameters. Trying it seems to reliably cause it build over the command computer midway, interrupting itself.

If there's anything above the play area (eg raised indicator blocks from the last play), building a minefield in that spot may bug out.

I'm also having a little trouble figuring out how the indicator blocks work. When you stomp a pad which has no mines around it, the surrounding area gets triggered, which is good; but the amount of indicators that show up around the border is wrong, meaning you have to manually stomp all the pads around the perimeter anyway in order to get them to appear correctly.

I can't help but think that the way to go would be to wire up the whole grid with bundled cables. This'd theoretically allow you to connect a 256x256 play area to one side of the command computer, which could then remain running - allowing it to eg detect when the game is won. This'd also allow you to setblock some different colours for your indicators, making the board easier to "read".

But I have to admit that feels like cheating, when compared to your piston set up. It's pretty cool as it is.
Edited on 10 February 2016 - 10:27 PM
Lion4ever #3
Posted 29 December 2015 - 03:09 PM
It would be nice if the script could be run without parameters. Trying it seems to reliably cause it build over the command computer midway, interrupting itself.

If there's anything above the play area (eg raised indicator blocks from the last play), building a minefield in that spot may bug out.
Fixed that. It is now one block above the computer.


I'm also having a little trouble figuring out how the indicator blocks work. When you stomp a pad which has no mines around it, the surrounding area gets triggered, which is good; but the amount of indicators that show up around the border is wrong, meaning you have to manually stomp all the pads around the perimeter anyway in order to get them to appear correctly.
Yeah, the wiring is a big difficult, if there is only a 3*2*3 area to work with. Because of that only the indicator blocks on the side of the next spots are activates (only redstone dust and no redstone repeaters are used)

I can't help but think that the way to go would be to wire up the whole grid with bundled cables. This'd theoretically allow you to connect a 256x256 play area to one side of the command computer, which could then remain running - allowing it to eg detect when the game is won. This'd also allow you to setblock some different colours for your indicators, making the board easier to "read".
There could be command blocks under the pressure plates which triggers the spot action like displaying a number with /title, /tellraw or /setblock sign.

But that would not be survival like and would not be able to explode at all.
The disadvantage with cables is that there can be computercraft without the cables and that the computer must not restart for the game to work…