My thoughts on Othello [Thinking Routine 2]

1. 1. Introduction

As I wrote in the previous article, I was trying GitHub, but it was around this time that only time passed without knowing how to use it even if I made full use of the translation function of Google Chrome. Therefore, from this time, we will utilize bitbucket, which has the same function as GitHub and also supports Japanese. Also, since the Java source so far was created using Eclipse, we will code it while linking Eclipse with bitbucket. I'm sorry GitHub.

So, I decided to implement a thinking routine that automatically searches for the place to put the Othello stone, but while I was a little away from coding, __ what kind of implementation I had done so far I don't understand at all __. As I received a comment when I posted the article of Thinking Routine 1, the number of lines of the OthelloBoard class became ridiculously large (__460 lines! __), and the connection of __variables and methods became extremely complicated. _was. Therefore, we will start by dividing the OthelloBoard class into several classes and rewriting it so that it is a little easier to understand which class refers to which variable / method.

However, the OthelloBoard class is no longer understood even by me who wrote it. If you move a variable to another class or rewrite a little code, Eclipse will give you a lot of error messages. No matter how many errors you crush, there is no sign that it will end at all ...! OthelloBoard class "Don't be dumb, shaved. Be brave. Only tens of thousands of times left."

…… __ The importance of class design __ It was a weekend that I felt sick.

2. New class design

So, I tried to distribute the variables and methods in the OthelloBoard class to each of the following classes.

--Config class for setting the size of the Othello board (the number of stones that can be placed on one side) and the color of the stones on the player side at the start of the game. --Board class that manages the placement of stones. --Print class that displays the number of Othello boards, black stones, and white stones on the command prompt. --Flip class that determines whether the opponent's stone can be turned over when a stone is placed on the specified square. -Strategy class for determining (strategy) the __mass where the stone should be placed __ (mainly on the enemy side). -Player class for inputting (selecting) the square where you want to place the stone (mainly on the player side). --The turn progress and end processing will be left in the OthelloBoard class as before.

If I try to rewrite it from the beginning, it will be out of control (it has become), so I will leave it as it is for the time being.

Config class (and DiscState class)

When starting Othello, it is a class that lets you enter the size of the Othello board and the color of the stone on the player side from the command prompt. In the future, when adding items to be entered at the start of Othello, we plan to implement it in this class. In the future, I would like to be able to choose the difficulty level of the thinking routine on the enemy side.

Config class (click to open)
import java.util.Scanner;

public class Config {
	private final int size;				//One side of the Othello board(8, 10, 12, 14, 16)
	private final char playerColor;		//Player stone color
	private final char otherColor;		//The color of the opponent's stone

	public Config() {
		this.size = this.askBoardSize();
		this.playerColor = this.askPlayerColor();
		if (this.playerColor == DiscState.BLACK) {
			this.otherColor = DiscState.WHITE;
		} else {
			this.otherColor = DiscState.BLACK;
		}
	}

	public int getSize() {
		return this.size;
	}
	public char getPlayerColor() {
		return this.playerColor;
	}
	public char getOtherColor() {
		return this.otherColor;
	}

	//Accepts input until the size of the Othello board is decided
	private int askBoardSize() {
		while (true) {
			System.out.println("\n Determine the length of one side of the Othello board.");
			System.out.print("[6, 8, 10, 12, 14,Any of 16]:");
			Scanner sc = new Scanner(System.in);
			String line = sc.nextLine();
			if ("6".equals(line) || "8".equals(line) || "10".equals(line) || "12".equals(line) ||
					"14".equals(line) || "16".equals(line)) {
				System.out.println("The length of one side of the Othello board is" + line + "is.");
				return Integer.parseInt(line);
			}
			System.out.println("The input is incorrect.");
		}
	}

	//Accept input until the color of the player's stone is decided
	private char askPlayerColor() {
		while (true) {
			System.out.println("\n Decide on your stone.");
			System.out.println("[b (black), w (White)Any of]:");
			Scanner sc = new Scanner(System.in);
			String line = sc.nextLine();
			if ("b".equals(line)) {
				System.out.println("Your stone is black.");
				return DiscState.BLACK;
			} else if ("w".equals(line)) {
				System.out.println("Your stone is white.");
				return DiscState.WHITE;
			}
			System.out.println("The input is incorrect.");
		}
	}
}

In the previous code,'B','W', which indicates the color of the stone, and'N', which indicates that the stone was not placed, were written __directly __, but these are __ magic numbers __ It is called __not good __ existence (in the unlikely event that another character is assigned, it will be necessary to rewrite the entire code, so it is easy to become a hotbed of errors and bugs). Therefore, we prepared the DiscState class that represents the color and arrangement of stones, and assigned the character constants BLACK, WHITE, and NONE, respectively.

DiscState class (click to open)
//Manage character constants to represent the color and placement of stones on the Othello board
public final class DiscState {
	public static final char BLACK = 'B';		//Kuroishi is placed
	public static final char WHITE = 'W';		//Shiraishi is placed
	public static final char NONE = 'N';		//No stones are placed

	private DiscState() {
	}
}

At last, I feel that I have come to realize the usage of static and final.

Board class

It is a class that manages the state of stones placed on each square of the Othello board, and if they are placed, whether they are black stones or white stones. In addition, the number of black stones and white stones will be updated whenever the Othello board is initialized at the start of the game (stones are placed only in the central 4 squares) and the stone placement status is updated. Especially for the second reason, the stone placement status is updated only by the putDisc method and the flipAllDiscs method __, and the number is updated __ at the same time in both methods. It is assumed that the size of the Othello board will be received from the Config class. When I first started making an Othello program, the coordinates representing the position of the stone were represented by int type variables x and y, but from the middle I made and used the class Coordinates that represents the coordinates. However, this time, I learned that there is a class that represents int type coordinates in the Java library (Point class), so I will use that in the future.

Board class (click to open)
import java.awt.Point;
import java.util.ArrayList;

public class Board {
	private final int size;					//One side of the Othello board(8, 10, 12, 14, 16)
	private char[][] squares;				//Indicates the presence or absence of stones in each square, and the color if there are stones.
	private int blackCounter;				//Number of black stones
	private int whiteCounter;				//Number of Shiroishi

	public Board(int size) {
		this.size = size;
		this.squares = new char[this.size][this.size];
		this.blackCounter = 0;
		this.whiteCounter = 0;
	}

	public int getSize() {
		return this.size;
	}
	public char[][] getSquares() {
		return this.squares;
	}
	public char getSquareState(Point p) {
		return this.squares[p.y][p.x];
	}
	public int getCounter(char color) {
		if (color == DiscState.BLACK) {
			return this.blackCounter;
		} else if (color == DiscState.WHITE) {
			return this.whiteCounter;
		} else {
			return this.size*this.size - this.blackCounter - this.whiteCounter;
		}
	}

	//Put the Othello board in the state at the beginning of the game
	public void initializeBoard() {
		for (int y = 0; y < this.size; y ++) {
			for (int x = 0; x < this.size; x ++) {
				squares[y][x] = 'N';
			}
		}
		//Place stones only in the central 4 squares
		this.putDisc(DiscState.BLACK, new Point(this.size/2 - 1, this.size/2 - 1));
		this.putDisc(DiscState.BLACK, new Point(this.size/2, this.size/2));
		this.putDisc(DiscState.WHITE, new Point(this.size/2, this.size/2 - 1));
		this.putDisc(DiscState.WHITE, new Point(this.size/2 - 1, this.size/2));
	}

	//Place stones at the specified coordinates on the Othello board and update the number of stones at the same time.
	public void putDisc(char color, Point p) {
		this.squares[p.y][p.x] = color;
		if (color == DiscState.BLACK) {
			this.blackCounter ++;
		} else if (color == DiscState.WHITE) {
			this.whiteCounter ++;
		}
	}

	//Turn over the stones at the specified coordinates on the Othello board and update the number of stones at the same time.
	public void flipAllDiscs(ArrayList<Point> discs) {
		for (Point disc : discs) {
			this.flipDisc(disc);
		}
	}

	//Turn over the stones at the specified coordinates on the Othello board and update the number of stones at the same time.
	private void flipDisc(Point p) {
		if (this.squares[p.y][p.x] == DiscState.BLACK) {
			this.squares[p.y][p.x] = DiscState.WHITE;
			this.blackCounter --;
			this.whiteCounter ++;
		} else if (this.squares[p.y][p.x] == DiscState.WHITE) {
			this.squares[p.y][p.x] = DiscState.BLACK;
			this.blackCounter ++;
			this.whiteCounter --;
		}
	}
}

Print class

The Othello board is displayed on the command prompt by making full use of the ruled lines. Receives board class member variables / arrays.

Print class (click to open)
import java.awt.Point;
import java.util.ArrayList;

public class Print {
	private Board board;										//State of Othello board
	private final String alphabets = "abcdefghijklmnop";		//Alphabet showing horizontal coordinates

	public Print(Board board) {
		this.board = board;
	}

	//Display the Othello board on the console
	public void printBoard() {
		this.printBoardAlphabetLine();							//Alphabet line
		this.printBoardOtherLine("┏", "┳", "┓");					//Top edge
		for (int y = 0; y < this.board.getSize() - 1; y ++) {
			this.printBoardDiscLine(y);							//Line to display stones
			this.printBoardOtherLine("┣", "╋", "┫");			//Line spacing
		}
		this.printBoardDiscLine(this.board.getSize() - 1);		//Line to display stones
		this.printBoardOtherLine("┗", "┻", "┛");				//lower end
	}

	//Show the number of stones of the player and opponent
	public void printDiscNumber(char playerColor) {
		if (playerColor == DiscState.BLACK) {
			System.out.print("you= " + this.board.getCounter(DiscState.BLACK) + "  ");
			System.out.println("Opponent= " + this.board.getCounter(DiscState.WHITE));
		} else if (playerColor == DiscState.WHITE) {
			System.out.print("you= " + this.board.getCounter(DiscState.WHITE) + "  ");
			System.out.println("Opponent= " + this.board.getCounter(DiscState.BLACK));
		}
	}

	//Show all coordinates of flipped stones
	public void printAllFlippedDiscs(ArrayList<Point> discs) {
		System.out.println("I flipped the next stone.");
		int count = 0;
		for (Point disc : discs) {
			System.out.print(alphabets.substring(disc.x, disc.x + 1) + (disc.y + 1) + " ");
			count ++;
			if (count == 8) {
				System.out.println("");
				count = 0;
			}
		}
		System.out.println("");
	}

	//Display the alphabet indicating the row of Othello board
	private void printBoardAlphabetLine() {
		String buf = "  ";
		for (int x = 0; x < this.board.getSize(); x ++) {
			buf += "   " + this.alphabets.charAt(x);
		}
		System.out.println(buf);
	}

	//Display one line with stones on the Othello board
	private void printBoardDiscLine(int y) {
		String buf = String.format("%2d┃", y+1);
		for (int x = 0; x < this.board.getSize(); x ++) {
			if (this.board.getSquareState(new Point(x, y)) == DiscState.BLACK) {
				buf += "●┃";
			} else if (this.board.getSquareState(new Point(x, y)) == DiscState.WHITE) {
				buf += "○┃";
			} else {
				buf += " ┃";
			}
		}
		System.out.println(buf);
	}

	//Display one line of ruled lines representing the frame of the Othello board
	private void printBoardOtherLine(String left, String middle, String right) {
		String buf = "  " + left;
		for (int x = 0; x < this.board.getSize() - 1; x ++) {
			buf += "━" + middle;
		}
		System.out.println(buf + "━" + right);
	}
}

Flip class

Assuming that you have placed a stone on the specified square, determine if you can turn the opponent's stone over. You will receive information about the member variables and arrays of the Board class and where and what color stone to put in the next turn. As for determining whether the opponent's stone can be turned over, I tried to make it much lighter than the previous code. In particular, for the part that searches for stones that can be turned over in eight directions, vertical, horizontal, and diagonal, we first prepared the Directions class as a vector for advancing one square in each direction.

Directions class (click to open)
import java.awt.Point;
import java.util.ArrayList;

public class Directions {
	public static final ArrayList<Point> directions;

	static {
		directions = new ArrayList<Point>();
		directions.add(new Point(1, 0));		//0 degrees
		directions.add(new Point(1, 1));		//45 degrees
		directions.add(new Point(0, 1));		//90 degree
		directions.add(new Point(-1, 1));		//135 degrees
		directions.add(new Point(-1, 0));		//180 degrees
		directions.add(new Point(-1, -1));		//225 degrees
		directions.add(new Point(0, -1));		//270 degrees
		directions.add(new Point(1, -1));		//315 degrees
	}
}

The Flip class provides an isAvailableSquare method that checks whether a stone can be turned over by placing a stone in the specified square, and a getAllFlippedDiscs method that gets a list of the coordinates of the stone that can be turned over. Also, I used the Directions class and separated the similar processing into new methods, so I think it's much cleaner than the previous one.

Flip class (click to open)
import java.awt.Point;
import java.util.ArrayList;

public class Flip {
	private Board board;					//State of Othello board
	private char nextColor;					//The color of the stone you are trying to place
	private Point nextMove;					//The square where the stone is going to be placed

	public Flip(Board board, char nextColor, Point nextMove) {
		this.board = board;
		this.nextColor = nextColor;
		this.nextMove = nextMove;
	}

	//Determine if the specified square can turn over the opponent's stone
	public boolean isAvailableSquare() {
		//Find out if stones have already been placed
		if (!this.isEmptySquare(this.nextMove)) {
			return false;
		}
		//Find out if there are stones that can be turned over in each direction
		for (Point direction : Directions.directions) {
			if (this.searchFlippedDiscs(this.nextMove, direction).size() > 0) {
				//If there is a stone that can be turned over
				return true;
			}
		}
		//If there is no stone that can be turned over in any direction
		return false;
	}

	//Returns a list of the coordinates of the stone to be flipped over
	public ArrayList<Point> getAllFlippedDiscs() {
		ArrayList<Point> allFlippedDiscs = new ArrayList<Point>();
		for (Point direction : Directions.directions) {
			allFlippedDiscs.addAll(this.searchFlippedDiscs(this.nextMove, direction));
		}
		return allFlippedDiscs;
	}

	//Determine if there are stones in the specified square
	private boolean isEmptySquare(Point square) {
		if (this.board.getSquareState(square) == DiscState.NONE) {
			return true;
		} else {
			return false;
		}
	}

	//Get a list of the coordinates of stones that can be turned over in one of the vertical, horizontal, and diagonal directions.
	//Temporarily register in the list while the opponent's stones are continuous, and return the list when your own stone comes immediately after that
	//But there is no square next to it(Outside the board)Or if there are no stones, clear the list and return(= Can't turn over)
	private ArrayList<Point> searchFlippedDiscs(Point square, Point direction) {
		Point currentSquare = new Point(square);
		ArrayList<Point> flippedDiscs = new ArrayList<Point>();

		while(true) {
			//Find the coordinates of the next cell
			Point nextSquare = this.getNextSquare(currentSquare, direction);
			//When exiting the loop depending on the situation of the next square
			if (!this.isSquareInRange(nextSquare)) {
				//If there is no square next to it
				flippedDiscs.clear();
				break;
			} else if (board.getSquareState(nextSquare) == DiscState.NONE) {
				//If there is no stone in the next square
				flippedDiscs.clear();
				break;
			} else if (board.getSquareState(nextSquare) == this.nextColor) {
				//If you have your own stone in the next square
				break;
			}
			//If there is an opponent's stone in the next square, proceed to the next square
			flippedDiscs.add(nextSquare);
			currentSquare.setLocation(nextSquare);
		}
		return flippedDiscs;
	}

	//Find the coordinates of the next cell in the specified orientation
	private Point getNextSquare(Point currentSquare, Point direction) {
		Point nextSquare = new Point(currentSquare.x, currentSquare.y);
		nextSquare.translate(direction.x, direction.y);
		return nextSquare;
	}

	//Check if the specified square is in the Othello board
	private boolean isSquareInRange(Point square) {
		if (0 <= square.x && square.x < this.board.getSize() &&
			0 <= square.y && square.y < this.board.getSize()) {
			return true;
		} else {
			return false;
		}
	}
}

Note that the Flip class only determines whether it can be flipped, and it is the flipAllDiscs method in the Board class that actually performs the flipping process. In that sense, it might have been better to name the Flip class as the CheckFlip class.

Strategy class

It is a class that judges whether there is a square where you can put a stone, and if so, chooses which square to put the stone on. Receives board class member variables / arrays. Due to the processing (mainly logs) that we are considering in the future, we have changed it from the previous code. First, I created a Candidate class that inherits the Point class so that I can assign some evaluation value to the candidate of the square where the stone should be placed next, or set a flag when some condition is met. Right now, I keep the coordinates of the stone that can be turned over when I put a stone on that square, but for example, depending on whether it can be placed at the corner and the number of turns so far, I will take less or more stone. We plan to add processing.

Candidate class (click to open)
import java.awt.Point;
import java.util.ArrayList;

public class Candidate extends Point {
	private ArrayList<Point> allFlippedDiscs;

	public Candidate(Point point) {
		super(point);
	}
	public Candidate(Point point, ArrayList<Point> allFlippedDiscs) {
		super(point);
		this.allFlippedDiscs = allFlippedDiscs;
	}
	public void setAllFlippedDiscs(ArrayList<Point> allFlippedDiscs) {
		this.allFlippedDiscs = allFlippedDiscs;
	}
	public ArrayList<Point> getAllFlippedDiscs() {
		return this.allFlippedDiscs;
	}
}

Next is the Strategy class.

Strategy class (click to open)
import java.awt.Point;
import java.util.ArrayList;
import java.util.Random;

public class Strategy {
	private Config config;						//Initial setting
	private Board board;						//State of Othello board
	private char nextColor;						//The color of the stone you are trying to place
	ArrayList<Candidate> candidates;			//Can put stones(= You can turn over the opponent's stone)List of trout

	public Strategy(Config config, Board board, char nextColor) {
		this.config = config;
		this.board = board;
		this.nextColor = nextColor;
		this.candidates = new ArrayList<Candidate>();
	}

	//Next, determine if there is a square where you can place a stone
	public boolean hasCandidates() {
		this.searchCandidates();
		if (this.candidates.size() > 0) {
			return true;
		} else {
			return false;
		}
	}


	//Next, choose one square to put the stone on
	public Candidate getNextMove() {
		return this.getNextMoveRandom();
	}

	//Randomly choose one square to put the stone next
	private Candidate getNextMoveRandom() {
		return this.candidates.get(new Random().nextInt(this.candidates.size()));
	}

	//Can put stones(= You can turn over the opponent's stone)Explore the trout
	private void searchCandidates() {
		for (int y = 0; y < this.board.getSize(); y ++) {
			for (int x = 0; x < this.board.getSize(); x ++) {
				Point currentSquare = new Point(x, y);
				Flip flip = new Flip(this.board, this.nextColor, currentSquare);
				if (flip.isAvailableSquare()) {
					this.candidates.add(new Candidate(currentSquare, flip.getAllFlippedDiscs()));
				}
			}
		}
	}
}

Continuing from the last time, the enemy's thinking routine is as simple as randomly choosing one from where you can place the stone. Next time, we plan to make this class even more fulfilling.

Player class

This is a class that lets the player enter where to place the next stone. It determines whether there are other stones in the square of the entered coordinates, whether the opponent's stone can be turned over, and whether the entered character string is correct as the coordinates in the first place. I regret that the class naming was straightforward.

Player class (click to open)
import java.awt.Point;
import java.util.Scanner;

public class Player {
	private Board board;									//State of Othello board
	private char nextColor;								//The color of the stone you are trying to place

	private Candidate nextMove;							//Next place to put the stone
	private Flip flip;										//Information on stones that can be turned over

	private final String alphabets = "abcdefghijklmnop";	//Alphabet showing horizontal coordinates

	public Player(Board board, char nextColor) {
		this.board = board;
		this.nextColor = nextColor;
		this.nextMove = new Candidate(new Point(0, 0));
	}

	//Accept input until the next place to put the stone is decided
	public Candidate askNextMove() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			//input
			System.out.println("\n Decide where to put the stone.");
			System.out.print("[x coordinate y coordinate](Examplea1):");
			String line = sc.nextLine();
			//Determine if the coordinates entered by the player are within the range of the Othello board
			if (!this.checkCoordinatesRange(line)) {
				//If the coordinates are incorrect, re-enter
				System.out.println("The input is incorrect.");
				continue;
			}
			//Can put stones(= You can turn over the opponent's stone)Determine if it is a mass
			this.flip = new Flip(this.board, this.nextColor, this.nextMove);
			if (!this.flip.isAvailableSquare()) {
				System.out.println("You cannot put stones on that square.");
				continue;
			}
			this.nextMove.setAllFlippedDiscs(this.flip.getAllFlippedDiscs());
			return this.nextMove;
		}
	}

	//Determine if the coordinates entered by the player are within the range of the Othello board
	private boolean checkCoordinatesRange(String line) {
		String[] tokens = line.split(" ");
		//Read the horizontal coordinates from the first letter of the alphabet
		int x = this.alphabets.indexOf(tokens[0]);
		if (tokens[0].length() != 1 || x < 0 || x >= this.board.getSize()) {
			return false;
		}
		//Read the vertical coordinates from the remaining characters
		int y;
		try {
			y = Integer.parseInt(tokens[1]);
		} catch (NumberFormatException e) {
			return false;
		}
		if (y <= 0 || y > this.board.getSize()) {
			return false;
		}

		this.nextMove.setLocation(x, y - 1);
		return true;
	}
}

OthelloBoard class

This class handles the progress of Othello's turns. I think that it became much easier to read by separating various other processes as separate classes. Of course, we still need to work on it, but ...

OthelloBoard class (click to open)
public class OthelloBoard {
	private Config config;										//Initial setting
	private Board board;										//State of Othello board
	private int turnCountMax;									//Maximum number of turns(1 side*1 side-4)

	private int turnCounter;									//Current number of turns
	private int skipCounter;									//Number of consecutive skips(When it reaches 2, Othello ends)
	private boolean isPlayerTurn;								//True if the current turn is the player's turn
	private char nextColor;									//Which color's turn is the current turn?

	//constructor
	public OthelloBoard() {
		System.out.println("Start Othello.");
		//Initial setting
		this.config = new Config();
		this.board = new Board(this.config.getSize());
		this.board.initializeBoard();
		this.turnCountMax = this.config.getSize()*this.config.getSize() - 4;
		Print print = new Print(this.board);
		print.printBoard();
		print.printDiscNumber(this.config.getPlayerColor());

		//Processing only for the first turn
		this.turnCounter = 1;
		this.skipCounter = 0;
		this.isPlayerTurn = this.getFirstMove();
		this.nextColor = this.getNextColor();
	}

	//Start Othello
	public void start() {
		//Processing every turn
		while (this.turnCounter <= this.turnCountMax) {
			//Determine if to skip the turn
			Strategy strategy = new Strategy(this.config, this.board, this.nextColor);
			if (!strategy.hasCandidates()) {
				//Transfer the current turn to the enemy side
				System.out.println("The turn was skipped.");
				this.skipCounter ++;
				if (this.skipCounter == 2) {
					System.out.println("Ends Othello because the turns were skipped in a row.");
					break;
				}
				this.isPlayerTurn = !this.isPlayerTurn;
				this.nextColor = this.getNextColor();
				continue;
			}
			//Below, if you do not skip the turn
			//Decide where to put the stone next
			this.skipCounter = 0;
			Candidate nextMove;
			if (this.isPlayerTurn) {
				//Player turn
				System.out.println("\nTurn " + this.turnCounter + ":It's your turn.");
				Player player = new Player(this.board, this.nextColor);
				nextMove = player.askNextMove();
			} else {
				//Opponent's turn
				System.out.println("\nTurn " + this.turnCounter + ":It's your opponent's turn.");
				nextMove = strategy.getNextMove();
			}
			//Display the board after turning it over
			this.board.putDisc(this.nextColor, nextMove);
			this.board.flipAllDiscs(nextMove.getAllFlippedDiscs());
			Print print = new Print(this.board);
			print.printBoard();
			print.printDiscNumber(this.config.getPlayerColor());
			print.printAllFlippedDiscs(nextMove.getAllFlippedDiscs());
			//Processing for the next turn
			this.turnCounter ++;
			this.isPlayerTurn = !this.isPlayerTurn;
			if (this.isPlayerTurn) {
				this.nextColor = this.config.getPlayerColor();
			} else {
				this.nextColor = this.config.getOtherColor();
			}
		}
		//Judgment of victory or defeat
		this.printResult();
	}

	//Show the outcome of the game
	private void printResult() {
		if (this.board.getCounter(DiscState.BLACK) > this.board.getCounter(DiscState.WHITE)) {
			System.out.println("Kuroishi wins.");
		} else {
			System.out.println("Shiroishi wins.");
		}
	}

	//Determine which color's turn the current turn is
	private char getNextColor() {
		if (this.isPlayerTurn) {
			return this.config.getPlayerColor();
		} else {
			return this.config.getOtherColor();
		}
	}

	//The first move decides which one
	//If the player is Kuroishi, the player is on the play, and if the player is Shiraishi, the opponent is on the play.
	private boolean getFirstMove() {
		if (this.config.getPlayerColor() == DiscState.BLACK) {
			return true;
		} else {
			return false;
		}
	}
}

OthelloBoardTest class

It's just a class that calls the OthelloBoard class.

OthelloBoardTest class (click to open)
public class OthelloBoardTest {
	public static void main(String args[]) {
		OthelloBoard ob = new OthelloBoard();
		ob.start();
	}
}

3. 3. (For the time being) Completed ⇒ Commit

I've committed the source code I mentioned earlier to Bitbucket. ⇒ MyOthello

I'd like to try various things with Bitbucket for a while and revenge on GitHub at some point. In addition, the method of cooperation with eclipse seems to be almost the same on GitHub.

Thank you for reading!

Recommended Posts

My thoughts on Othello [Thinking Routine 2]
My thoughts on Othello [Thinking Routine 1]
My thoughts on the future [Preparation]
My thoughts on the equals method (Java)
My thoughts on the future [Gradle app version ①]