Hello! In my digital electronics class, I am working on creating Minesweeper in Multisim version 14.0 as a side project. I have run into an issue on how to count the number of adjacent mines to a certain tile. (I number the places where the adjacent mines should be like the number pad; 5 being the tile you are going to click and every number around the 5 being a position for a mine)
At the start, for a prototype of a corner tile where only three mines max could be adjacent, I just used lots AND gates. For checking if two mines were adjacent, I used 3 input AND gates .One input for clicking the tile, and the other two were signals from adjacent tiles about whether there was a mine there or not. I used three of those as well as three 2 input AND gates for checking if one bomb was adjacent and one 4 input AND gate if all 3 tiles had a mine. Quickly I realized that for a tile that could have eight adjacent bombs that this is clearly the most inefficient solution.
Also, I have tried cascading half adders, but if the mines that are active aren't all one after the other in numerical order, the number given back is wrong. For example, let's say the mines where 1, 2, and 4 are on the numpad were on. Rather than getting back 00000100, I would get back a 00001010. (These numbers do not represent a binary number, rather just the number of mines that are adjacent).
So essentially what I think is the best solution is a circuit that can count the number of 1s in an 8 bit number ( a bit representing each adjacent tile). I'd prefer to use just full adders and half adders since I know them well. If I have to though, I will try other components/circuits. The answer can be a binary number showing how many mines are adjacent or an 8 bit number where only one bit is a 1, with each bit representing 1, 2, 3... through 8 mines adjacent (like my attempt with cascading half adders). Any help is appreciated. Thanks!
At the start, for a prototype of a corner tile where only three mines max could be adjacent, I just used lots AND gates. For checking if two mines were adjacent, I used 3 input AND gates .One input for clicking the tile, and the other two were signals from adjacent tiles about whether there was a mine there or not. I used three of those as well as three 2 input AND gates for checking if one bomb was adjacent and one 4 input AND gate if all 3 tiles had a mine. Quickly I realized that for a tile that could have eight adjacent bombs that this is clearly the most inefficient solution.
Also, I have tried cascading half adders, but if the mines that are active aren't all one after the other in numerical order, the number given back is wrong. For example, let's say the mines where 1, 2, and 4 are on the numpad were on. Rather than getting back 00000100, I would get back a 00001010. (These numbers do not represent a binary number, rather just the number of mines that are adjacent).
So essentially what I think is the best solution is a circuit that can count the number of 1s in an 8 bit number ( a bit representing each adjacent tile). I'd prefer to use just full adders and half adders since I know them well. If I have to though, I will try other components/circuits. The answer can be a binary number showing how many mines are adjacent or an 8 bit number where only one bit is a 1, with each bit representing 1, 2, 3... through 8 mines adjacent (like my attempt with cascading half adders). Any help is appreciated. Thanks!