diff --git a/app/build.gradle b/app/build.gradle index 65960f6..4d0177e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.thisispiri.mnk" minSdkVersion 14 targetSdkVersion 28 - versionCode 32 - versionName "1.13.1" + versionCode 33 + versionName "1.13.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/com/thisispiri/mnk/PiriValue01Ai.java b/app/src/main/java/com/thisispiri/mnk/PiriValue01Ai.java index db0f268..5dca925 100644 --- a/app/src/main/java/com/thisispiri/mnk/PiriValue01Ai.java +++ b/app/src/main/java/com/thisispiri/mnk/PiriValue01Ai.java @@ -3,6 +3,7 @@ import com.thisispiri.common.Point; import java.util.LinkedList; +import java.util.Locale; /**This is the oldest surviving version of PIRI Value AI, with some refactoring to make it work on the current version of PIRI MNK.*/ public class PiriValue01Ai implements MnkAi { @@ -15,14 +16,20 @@ private class Pair { } } private MnkGame game; - /* has AI play a turn. - * determine every cell's importance and place a stone on the cell with highest importance. - * cells that can block a line of a higher number always have higher importance than cells that can block many lines of a lower number. - * if two cells can block lines of a same number, the cell that can block more lines has higher importance. - * if a line can't be a line of maxStreak cells(because it's blocked by wall or the other symbol), ignore it. - * cells that can end game(by granting the player win) have infinite importance(represented as 9999999) + /** has AI play a turn. + * determine every cell's importance and place a stone on the cell with highest importance. + * cells that can block a line of a higher number always have higher importance than cells that can block many lines of a lower number. + * if two cells can block lines of a same number, the cell that can block more lines has higher importance. + * if a line can't be a line of maxStreak cells(because it's blocked by wall or the other symbol), ignore it. + * cells that can end game(by granting the player win) have infinite importance(represented as 9999999) */ - public MnkAiDecision playTurnJustify(final MnkGame game) { //the parameter will be true if executed inside a thread. + @Override public MnkAiDecision playTurnJustify(final MnkGame game) { + return play(game, true); + } + @Override public Point playTurn(final MnkGame game) { + return play(game, false).coord; + } + private MnkAiDecision play(final MnkGame game, final boolean justify) { //the parameter will be true if executed inside a thread. this.game = game; int maxStreak = 0, maxLine = 0; //maximum streak appeared until now in the evaluation loop, maximum number of lines of maxStreak cells that can be blocked by a cell Pair temp; @@ -48,13 +55,12 @@ else if(temp.first == maxStreak) { else if(temp.second == maxLine) //if a cell that can block maxLine lines of maxStreak, add it to list. list.addLast(new Point(j, i)); } + if(justify) + justification[i][j] = String.format(Locale.US, "%d,%d", temp.first, temp.second); } } return new MnkAiDecision(new Point(list.get(0).x, list.get(0).y), justification); } - public Point playTurn(final MnkGame game) { - return playTurnJustify(game).coord; - } //first : maximum length of lines the cell can block. second : the value(how many lines of [first] cells it can block) of the cell. private int maxStreak = 0, maxLine = 0, streak = 0; diff --git a/app/src/main/java/com/thisispiri/mnk/PiriValueAi.java b/app/src/main/java/com/thisispiri/mnk/PiriValueAi.java index 04cb121..cb29f56 100644 --- a/app/src/main/java/com/thisispiri/mnk/PiriValueAi.java +++ b/app/src/main/java/com/thisispiri/mnk/PiriValueAi.java @@ -38,7 +38,7 @@ private class CellValue { private MnkAiDecision play(final MnkGame game, final boolean justify) { this.game = game; valueLength = Math.max(game.getHorSize(), game.getVerSize()) * STREAK_SCALE; - //valueLength = (game.winStreak + 1) * STREAK_SCALE; Better for performances on larger boards, but causes crashes + //valueLength = (game.winStreak + 1) * STREAK_SCALE; Better for performance on larger boards, but causes crashes CellValue bestValue = new CellValue(valueLength); //the list of lines that a cell can block and has highest value LinkedList list = new LinkedList<>(); //list of cells to consider. String[][] values = null; diff --git a/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java b/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java index 7c6f66e..be6a811 100644 --- a/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java +++ b/app/src/main/java/com/thisispiri/mnk/andr/DebugBoard.java @@ -3,7 +3,7 @@ import android.graphics.Canvas; import android.graphics.Paint; -public class DebugBoard extends Board { +public class DebugBoard extends Board { //TODO support stone numbering private final Paint textPaint = new Paint(); private String[][] aiInternals; public DebugBoard(android.content.Context context, android.util.AttributeSet attr) { diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 3afa347..30f5ad4 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -1,5 +1,6 @@ + 피리 오목 바탕빛 판 크기 편 바꾸기 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c1ae6b4..2f66162 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - PIRI MNK + PIRI MNK Settings Restart Draw