# Minesweeper Wars [closed]

We've had problems to generate minesweeper games.
We've had problems to solve these minesweeper games.
Now...

It's time to battle other people on a minesweeper game!

Your program must be run in Java. Essentially, each player can do an action every turn.

1. You may move to any space touching yours including corners. The board does not wrap around.
2. You may place a mine in the spot you currently occupy, and then to any space touching yours including corners.
3. You may place a mine on any space adjacent to yours including corners.
4. You may defuse a mine on any space adjacent to yours including corners. This turn is wasted if you defuse an empty spot. (This turn does nothing if you try to defuse a spot with someone on it, but that doesn't need to be explicitly stated because there won't be a living bot on a mine...)
5. You may do nothing.

You must make your bot in a class that extends the class MineBot. MineBot looks like this:

public abstract class MineBot {
private int x, y;

public abstract int changeMines(int[][] field);

public abstract int[] proceed(int[][] field);

public final int getX() {
return x;
}

public final void setX(int x) {
this.x = x;
}

public final  int getY() {
return y;
}

public final void setY(int y) {
this.y = y;
}
}


(You must keep the final methods as they are for your submission to be valid)

MineBot#changeMines(int[][]) is asked first. The result is a single int, representing whether or not you would like to perform an action involving a mine. This could be placing a mine, or defusing a mine. 0 means no, 1 means defuse, and 2 means place a mine. (2 or anything not 0 or 1)

Then, MineBot#proceed(int[][]) is executed. The following things happen in the following ordering:

1. First, bots that are defusing mines make their move. All spots that were targeted by defusers are now safe to move onto.
2. Next, bots that are placing mines make their move. Bots may not place a bomb on a spot that was just defused.
3. Finally, all other bots move. Spaces do not have a limit on bot count, so all bots that try to move are guaranteed to move.

Then, after the configurations have been updated, all bots occupying a spot with a mine on it will be eliminated (including those who stayed put and got a mine placed under them), and it will keep iterating.

On each iteration, the number of points increases. When a bot is eliminated, the number of points on the current iteration becomes its score.

During each test run, all n bots will be placed on an n+10 by n+10 board. On each run, the score for each bot will be recorded. The total score is the sum over n test runs. The winner will be constantly updated, so after there are at least 3 submissions or it has passed March 14th (Pi Day), I will accept an answer, but this can change at any time!

# Input/Output Format

## Input

The array given is an int[][]. The rightmost four bits (k & 15) represent how many mines are adjacent to that square (including corners). The fifth bit from the right ((k & 16) >> 4) is 1 if there is a bot there and 0 if there are none. Remember, the board doesn't wrap around.

## Output

By "output" I actually mean what the functions return. Again, your bot's code will have two functions: int changeMines(int[][]), and int[] proceed(int[][]). Here's a detailed explanation for both of these:

int changeMines(int[][]) returns a single integer representing what type of move you want to perform next. Namely, return 0 if you want to move your location or idle, 1 if you want to defuse a mine, and 2 if you want to place a mine.

int[] proceed(int[][]) returns an array of length 1 or 2, depending on whether or not you want to stay idle. Let's say that the return value of this method is named int[] i. Then, i[0] represents what type of move you want to make according to the list at the top of the question. i[1] represents which on which space you want to perform the action, where applicable. This is not checked when you remain idle because it does not apply. Follow this table:

1: top-left
2: top
3: top-right
4: right
5: bottom-right
6: bottom
7: bottom-left
8: left


(You can only act within a 3x3 square centered on yourself.)

The game code can be found at my GitHub repo here. After downloading the code, it should be a valid eclipse project (run with Eclipse Neon.2). The source code is in /tree/master/MinesweeperKOTH/src. Change the source code in src/game/Game.java so that String[] botnames contains the name of all of the bots. I will be updating this every so often to save you some typing. Bots go in /src/programmed_bots, and must extend bot.MineBot. Your bot must not throw any exceptions, or it will die with score 0 (no invalid arguments will be given to your bot).

# Rules

• No using reflection of any sort!
• No using Runtime to invoke processes on the system!
• You may read other people's programs, obviously. You may also specifically target a specific AI, but please do so in a respectful manner, also leading to my next point...
• You may not attempt to invoke an instance of another bot and run its AI
• Standard Loopholes Apply

Happy KOTH-ing!

Note: This question now exists on the sandbox to get more suggestions.

## closed as unclear what you're asking by user42649, user62131, Sriotchilism O'Zaic, Nathan Merrill, Mike BufardeciMar 2 '17 at 15:05

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• This conversation has been moved to chat. – Dennis Mar 1 '17 at 17:16
• @hyperneutrino I am not sure that your mine neighbour algorithm is working as intended. e.g. For a simple 3 mine in an L shape, your algorthim yields the following rows: 1,1,1,0 - 1,2,1,1 - 1,2,2,1 - 1,1,1,1 I would expect the following rows: 1,1,1,0 - 2,2,3,1 - 2,2,1,1 - 1,2,2,1 . Currently, your algorithm allows for trivial mine location logic in the fact no number > 2 is possible and the presence of 2 will mean that cell contains a mine. – Moogie Mar 2 '17 at 5:40
• @hyperneutrino your starting positions for bot algorithm causes index out of bounds exception when more than one bot is present – Moogie Mar 2 '17 at 5:44
• I'm voting this to be closed because there are too many flaws, and I now realize that the game's concept isn't very good; it's too easy to take advantage of the ever increasing number of flaws. (VTC as Unclear) – HyperNeutrino Mar 2 '17 at 13:36
• I suggest instead of having global view, have a view of the map for each bot's surrounding areas. This should allow for more interesting AI behaviour – Moogie Mar 2 '17 at 22:30

# TestBot

This submission is to help you determine what a valid submission might look like!

import bot.MineBot;

public class TestBot extends MineBot {
public int changeMines(int[][] field) {
return 2;
}

public int[] proceed(int[][] field) {
return new int[] { 2, (int) (Math.random() * 8) };
}
}


This bot just does a random-walk, placing mines as it goes. Usually backs onto its own track and commits suicide.