In python, make a predictor for a minesweeper game on a 5x5 field. The board can max go…
- User
In python, make a predictor for a minesweeper game on a 5x5 field. The board can max go from 1 to 25.
You've data for the past 30 games played, in a list, where each number is an old mine location. You need to use this data. Your goal is to predict a new game with the data. The game itself got 3 mines in it, and you need to predict the amount the user inputs safe spots from an input varible and 3 possible mine locations.
You have to use machine learning for this. You need to use deep learning and make it really really accurate. Also, another thing, you CAN'T make it random. It cannot be random in anyway and needs to predict out of the machine learning module.
Your data is: [5, 12, 13, 4, 17, 19, 4, 18, 21, 1, 6, 11, 7, 15, 22, 14, 18, 19, 1, 19, 20, 9, 16, 17, 1, 19, 20, 6, 14, 24, 15, 20, 22, 7, 18, 21, 4, 16, 23, 5, 11, 19, 5, 6, 23, 6, 12, 13, 0, 5, 15, 1, 5, 22, 0, 2, 23, 5, 10, 13, 5, 12, 17, 1, 7, 22, 7, 11, 18, 7, 8, 9, 17, 21, 24, 13, 14, 16, 2, 3, 11, 7, 17, 18, 7, 14, 21, 2, 5, 9]
Good luck.
- Assistant
- User
there are no known mines remove that
- Assistant
Apologies for the confusion. I have modified the solution accordingly.
-
Continue from steps 1 to 5 in the previous answer to preprocess the data and train the model.
-
Define a function to predict the locations of safe spots and mines, given a number of desired safe spots:
def predict_locations(model, safe_spots): mines = [0]*3 while len(set(mines)) < 3: input_data = [mines] output_data = model.predict(input_data)[0] # Normalize the predicted values to get probabilities normalized_output_data = output_data / np.sum(output_data) # Get top 3 predicted mines mines = np.argsort(normalized_output_data)[-3:] safe_locations = [] for i in range(1, 26): if i not in mines and i not in safe_locations and len(safe_locations) < safe_spots: safe_locations.append(i) return safe_locations, mines- Use the predictor to predict safe spots and mines based on a given number of safe spots:
-