This is revised version from powershell article (Othello013) in Japanese.
When the code below is coped and pasted in notepad and saved as character code "UTF8 (with BOM)" and file extension "ps1", it will work.
- This is othello game. White and black stones are alternatively and automatically placed.
Places are decided by logic 0 - 6, which is decided in code (0: random, 1: corner prioritized, 2: one zone prioritized, 3: max stones which can be reversed, 4: min stones which can be reversed (from specific turn), 5: Selection of more win routes at the third turn, 6: mix of 0, 3, 5 logics).
- If there is no place, pass is done and the turn is changed to counterpart one.
- If there is no place for both players, the game ends.
- Console only displays results of each game. Data on board is saved in textfile.
■ Example
■ Code
# =========================================================================
# [Board]クラス: オセロの盤(10×10マス (黒("●")、白("〇")、空欄("_")のどれか。)、表示の機能、結果集計機能
# [Player]クラス: プレイヤー(白か黒、ロジックを持つ)、石を置く機能、裏返す機能
# [Logic]クラス:0,ランダム 1,四隅優先 2,1つの区画優先(左上、右上、右下、左下) 3,最大数(最大数となるものでランダム) 4,最小数(途中から変更) 5,3手目で勝ち筋となる手が多いものを選択 6,ミックス
# [Utility]クラス: よく使う機能をメソッドに取り出したクラス
# $turn: 順番(player AかB)
# $endflag: ゲーム終了を判断するフラグ(passが両プレイヤーから連続した場合に終了)
# $trialnum: 現在、何手目かのカウント(無効となる場所に石を置いたときはカウントされない)
# =========================================================================
# $TEXTFILE= (結果を保存するファイル名)
# $GAME_NUM = (オセロを行う回数)
# $PLAYER_A_LOGIC=(プレイヤーAのロジック: 0~6)
# $PLAYER_B_LOGIC=(プレイヤーBのロジック: 0~6)
# =========================================================================
$TEXTFILE="result.txt"
$GAME_NUM = 1000
$PLAYER_A_LOGIC=0
$PLAYER_B_LOGIC=1
# =========================================================================
$result = @(0,0,0)
# GAME_NUMの数だけゲームを行う
for ($i=1; $i -le $GAME_NUM ; $i++) {
$othboard = [Board]::new()
$playerA = [Player]::new("〇", $PLAYER_A_LOGIC)
$playerB = [Player]::new("●", $PLAYER_B_LOGIC)
$turn = $playerA
$endflag = 0
$trialnum = 0
echo ("Game:"+$i+"| Start Othello") | Out-file $TEXTFILE -Append
$othboard.showBoard($othboard.boardData) | Out-file $TEXTFILE -Append
# 1ゲームの中、石を置く処理を繰り返す。
while($true) {
if ($turn -eq $playerA) {
$position = $playerA.placeStone($othboard.boardData,$playerA.logic)
if ($position -eq "pass") {
$endflag += $endflag + 1
$turn = $playerB
} else {
$othboard.boardData = $playerA.reverseStones($position, $othboard.boardData)
$trialnum++
$turn = $playerB
}
} elseif ($turn -eq $playerB) {
$position = $playerB.placeStone($othboard.boardData,$playerB.logic)
if ($position -eq "pass") {
$endflag += $endflag + 1
$turn = $playerA
} else {
$othboard.boardData = $playerB.reverseStones($position, $othboard.boardData)
$trialnum++
$turn = $playerA
}
}
echo ("=====Trial:"+$trialnum+"=====") | Out-file $TEXTFILE -Append
[String]$str = $othboard.showBoard($othboard.boardData)
echo ($str) | Out-file $TEXTFILE -Append
if ($endflag -ge 2) {
break
} elseif ($trialnum -ge 60) {
break
}
}
[String]$str = $othboard.sumResult($othboard.boardData, $result)
echo ($str + " Game:"+$i+" | End Othello")
echo ($str + " Game:"+$i+" | End Othello") | Out-file $TEXTFILE -Append
}
echo ("●"+$result[0]+"vs〇"+$result[1]+"vsE"+$result[2])
##############################################################
## [Board]クラス:
# コンストラクタ
# 表示の機能:[String]showBoard($boardData)
# 結果集計機能:[String]sumResult($boardData, $result)
##############################################################
class Board {
$boardData
#コンストラクタ、盤上のデータを初期化
Board() {
$this.boardData=@(
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','〇','●','_','_','_','_'),
@('_','_','_','_','●','〇','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_')
)
}
#盤上のデータ表示(引数:盤上のデータ、戻し値:現在の盤上を示した文字列)
[String]showBoard($boardData) {
[String]$boardStr=""
for ($n=1; $n -lt 8; $n++) {
$boardStr+=$boardData[$n][1]+$boardData[$n][2]+$boardData[$n][3]+$boardData[$n][4]+$boardData[$n][5]+$boardData[$n][6]+$boardData[$n][7]+$boardData[$n][8]+"`r`n"
}
$boardStr+=$boardData[$n][1]+$boardData[$n][2]+$boardData[$n][3]+$boardData[$n][4]+$boardData[$n][5]+$boardData[$n][6]+$boardData[$n][7]+$boardData[$n][8]
return $boardStr
}
#結果集計、白の石と黒の石のカウントとresultの勝敗を1つ増やす(引数:盤上のデータ、複数のゲームの勝率、戻し値:結果として表示する文字列)
[String]sumResult($boardData, $result) {
$whitecnt = 0
$blackcnt = 0
for ($n=1; $n -le 8; $n++) {
for ($m=1; $m -le 8; $m++) {
if ($boardData[$n][$m] -eq "●") {
$blackcnt++
} elseif ($boardData[$n][$m] -eq "〇") {
$whitecnt++
}
}
}
if ($blackcnt -gt $whitecnt) {
$result[0]++
} elseif ($blackcnt -lt $whitecnt) {
$result[1]++
} elseif ($blackcnt -eq $whitecnt) {
$result[2]++
}
return ("●"+$blackcnt+"vs〇"+$whitecnt)
}
}
##############################################################
## [Player]クラス:
# コンストラクタ
# 石を置く機能:[String]placeStone($boardData, $logic_num)(手動入力の場合、[String]placeStone($boardData))
# 裏返す機能:[String[][]]reverseStones($position, $boardData)
##############################################################
class Player {
$playerColor
$logic
#コンストラクタ、プレイヤーデータを初期化
Player($color, $logicNum) {
$this.playerColor = $color
$this.logic = $logicNum
}
#石を置く処理(引数:盤上のデータ、ロジックの番号、戻し値:石を置く場所の文字列(11~88))
[String]placeStone($boardData, $logic_num) {
$logic_num = $this.logic
$position ="00"
$blankArray=@()
$inputArray=@()
for ($n=1; $n -le 8; $n++) {
for ($m=1; $m -le 8; $m++) {
if ($boardData[$n][$m] -eq '_') {
$blankArray+= [string]$n + [string]$m
}else{
}
}
}
if ($blankArray.count -eq 0) {
$position = "pass"
} else{
if ($blankArray.count -eq 1) {
$inputArray = $blankArray
} else {
if ($logic_num -eq 0) {
$inputArray = [Logic]::logic_random($blankArray)
}elseif ($logic_num -eq 1){
$inputArray = [Logic]::logic_corner($blankArray, $boardData)
}elseif ($logic_num -eq 2){
$inputArray = [Logic]::logic_zone($blankArray, $boardData)
}elseif ($logic_num -eq 3){
$inputArray = [Logic]::logic_max($blankArray, $boardData, $this)
}elseif ($logic_num -eq 4){
$inputArray = [Logic]::logic_min($blankArray, $boardData, $this)
}elseif ($logic_num -eq 5){
$inputArray = [Logic]::logic_winroute($blankArray, $boardData, $this)
}elseif ($logic_num -eq 6){
$inputArray = [Logic]::logic_mix($blankArray, $boardData, $this)
}
}
#石を置いた場合に裏返すものがあるかのチェック(裏返すものがなければ、pass)
foreach ($position in $inputArray) {
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass = [Player]::new($this.playercolor, $this.logic)
$tempClass.reverseStones($position, $tempBoard)
$canBeReversed = [Utility]::compareBoard($tempBoard, $boardData)
if($canBeReversed) {
$position = "pass"
} else {
break
}
}
}
return $position
}
#石を置く処理(引数:盤上のデータ、戻し値:石を置く場所の文字列(11~88))
[String]placeStone($boardData) {
$position='00'
while ($true) {
$position = Read-Host ("Player ("+$this.playerColor+")")
if($position -eq "pass") {
break
} elseif($position.length -le 1) {
} else {
$line=$position.substring(0,1)
$row=$position.substring(1,1)
if (($line -ge 1) -And ($line -le 8) -And ($row -ge 1) -And ($row -le 8)) {
if ($boardData[$line][$row] -eq "_") {
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass = [Player]::new($this.playercolor, $this.logic)
$tempClass.reverseStones($position, $tempBoard)
$canBeReversed = [Utility]::compareBoard($tempBoard, $boardData)
if($canBeReversed) {
} else { break
}
}
}
}
}
return $position
}
#石を裏返す処理(引数:石を置く場所、盤上のデータ、戻し値:裏返した後の盤上のデータ)
[String[][]]reverseStones($position, $boardData) {
if ($position -eq "pass") {
return $boardData
}
for ($checkcnt=0; $checkcnt -lt 8; $checkcnt++) {
$line=$position.substring(0,1)
$row=$position.substring(1,1)
[Int]$startline=$line
[Int]$startrow=$row
[Int]$opponentstonenum=0
for ($extension=0; $extension -lt 8; $extension++) {
if ($checkcnt -eq 0) {
$startline=$startline-1
} elseif ($checkcnt -eq 1) {
$startline=$startline-1
$startrow=$startrow+1
} elseif ($checkcnt -eq 2) {
$startrow=$startrow+1
} elseif ($checkcnt -eq 3) {
$startline=$startline+1
$startrow=$startrow+1
} elseif ($checkcnt -eq 4) {
$startline=$startline+1
} elseif ($checkcnt -eq 5) {
$startline=$startline+1
$startrow=$startrow-1
} elseif ($checkcnt -eq 6) {
$startrow=$startrow-1
} elseif ($checkcnt -eq 7) {
$startline=$startline-1
$startrow=$startrow-1
} else {
}
if ($boardData[$startline][$startrow] -eq "_") {
break
} elseif ($boardData[$startline][$startrow] -ne $this.playerColor) {
$opponentstonenum=$opponentstonenum+1
} elseif ($boardData[$startline][$startrow] -eq $this.playerColor) {
if ($opponentstonenum -ge 1) {
if ($checkcnt -eq 0) {
for ($startline;$startline -le $line;$startline++) {
$boardData[$startline][$startrow]=$this.playerColor
}
break
} elseif ($checkcnt -eq 1) {
for ($startline;$startline -le $line;$startline++) {
$boardData[$startline][$startrow]=$this.playerColor
$startrow=$startrow-1
}
break
} elseif ($checkcnt -eq 2) {
for ($startrow;$startrow -ge $row;$startrow--) {
$boardData[$startline][$startrow]=$this.playerColor
}
break
} elseif ($checkcnt -eq 3) {
for ($startrow;$startrow -ge $row;$startrow--) {
$boardData[$startline][$startrow]=$this.playerColor
$startline=$startline-1
}
break
} elseif ($checkcnt -eq 4) {
for ($startline;$startline -ge $line;$startline--) {
$boardData[$startline][$startrow]=$this.playerColor
}
break
} elseif ($checkcnt -eq 5) {
for ($startline;$startline -ge $line;$startline--) {
$boardData[$startline][$startrow]=$this.playerColor
$startrow=$startrow+1
}
break
} elseif ($checkcnt -eq 6) {
for ($startrow;$startrow -le $row;$startrow++) {
$boardData[$startline][$startrow]=$this.playerColor
}
break
} elseif ($checkcnt -eq 7) {
for ($startrow;$startrow -le $row;$startrow++) {
$boardData[$startline][$startrow]=$this.playerColor
$startline=$startline+1
}
break
}
} else {
break
}
}
}
}
return $boardData
}
}
##############################################################
## [Logic]クラス:
##############################################################
Class Logic{
static [String[]]logic_random($blankArray) {
$inputArray=@()
$inputArray = get-random -input $blankArray -count ([int]::MaxValue)
return $inputArray
}
static [String[]]logic_corner($blankArray, $boardData) {
$inputArray=@()
$inputArray = get-random -input $blankArray -count ([int]::MaxValue)
$cornerArray = @()
if ($boardData[1][1] -eq '_') {
$cornerArray += "11"
}
if ($boardData[8][1] -eq '_') {
$cornerArray += "81"
}
if ($boardData[1][8] -eq '_') {
$cornerArray += "18"
}
if ($boardData[8][8] -eq '_') {
$cornerArray += "88"
}
$inputArray = $cornerArray + $inputArray
return $inputArray
}
static [String[]]logic_zone($blankArray, $boardData) {
$inputArray=@()
$zoneArray = @()
for ($n=1; $n -le 4; $n++) {
for ($m=1; $m -le 4; $m++) {
if ($boardData[$n][$m] -eq '_') {
$zoneArray+= [string]$n + [string]$m
}else{
}
}
}
if($zoneArray.count -eq 0) {
} elseif($zoneArray.count -eq 1) {
$inputArray = $zoneArray
} else {
$inputArray = get-random -input $zoneArray -count ([int]::MaxValue)
}
$zoneArray = @()
for ($n=1; $n -le 4; $n++) {
for ($m=5; $m -le 8; $m++) {
if ($boardData[$n][$m] -eq '_') {
$zoneArray+= [string]$n + [string]$m
}else{
}
}
}
if($zoneArray.count -eq 0) {
} elseif($zoneArray.count -eq 1) {
$inputArray = $zoneArray
} else {
$inputArray = $inputArray + (get-random -input $zoneArray -count ([int]::MaxValue))
}
$zoneArray = @()
for ($n=5; $n -le 8; $n++) {
for ($m=5; $m -le 8; $m++) {
if ($boardData[$n][$m] -eq '_') {
$zoneArray+= [string]$n + [string]$m
}else{
}
}
}
if($zoneArray.count -eq 0) {
} elseif($zoneArray.count -eq 1) {
$inputArray = $zoneArray
} else {
$inputArray = $inputArray + (get-random -input $zoneArray -count ([int]::MaxValue))
}
$zoneArray = @()
for ($n=5; $n -le 8; $n++) {
for ($m=1; $m -le 4; $m++) {
if ($boardData[$n][$m] -eq '_') {
$zoneArray+= [string]$n + [string]$m
}else{
}
}
}
if($zoneArray.count -eq 0) {
} elseif($zoneArray.count -eq 1) {
$inputArray = $zoneArray
} else {
$inputArray = $inputArray + (get-random -input $zoneArray -count ([int]::MaxValue))
}
return $inputArray
}
static [String[]]logic_max($blankArray, $boardData, $Player) {
$max_diff_num = 0
$tempposition ="00"
$inputArray = get-random -input $blankArray -count ([int]::MaxValue)
foreach ($position in $inputArray) {
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass = [Player]::new($Player.playercolor, $Player.logic)
$tempClass.reverseStones($position, $tempBoard)
$diff_num = [Utility]::compareBoardDiffNum($tempBoard, $boardData)
if ($diff_num -gt $max_diff_num) {
$max_diff_num = $diff_num
$tempposition = $position
}
}
$inputArray[0] = $tempposition
return $inputArray
}
static [String[]]logic_min($blankArray, $boardData, $Player) {
$min_diff_num = 32
$tempposition ="00"
$inputArray = get-random -input $blankArray -count ([int]::MaxValue)
if($blankArray.count -le 55) {
} else{
foreach ($position in $inputArray) {
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass = [Player]::new($Player.playercolor, $Player.logic)
$tempClass.reverseStones($position, $tempBoard)
$diff_num = [Utility]::compareBoardDiffNum($tempBoard, $boardData)
if ($diff_num -ne 0) {
if ($diff_num -lt $min_diff_num) {
$min_diff_num = $diff_num
$tempposition = $position
}
}
}
$inputArray[0] = $tempposition
}
return $inputArray
}
static [String[]]logic_winroute($blankArray, $boardData, $Player) {
$max_win_route_rate = 0
$tempposition ="00"
$inputArray = get-random -input $blankArray -count ([int]::MaxValue)
$boardList = [System.Collections.ArrayList]::new()
foreach ($position in $inputArray) {
$win_route = 0
$boardList.clear()
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass = [Player]::new($Player.playerColor, $Player.logic)
$tempClass.reverseStones($position, $tempBoard)
$canBeReversed = [Utility]::compareBoard($tempBoard, $boardData)
if($canBeReversed) {
} else {
if($Player.playerColor -eq "●") {
$tempboardList = [System.Collections.ArrayList]::new()
$tempboardList = [Utility]::reversedBoardList($tempBoard, "〇")
foreach ($nextBlackTurnBoard in $tempboardList) {
$boardList.AddRange([Utility]::reversedBoardList($nextBlackTurnBoard, "●"))
}
} elseif ($Player.playerColor -eq "〇") {
$tempboardList = [System.Collections.ArrayList]::new()
$tempboardList = [Utility]::reversedBoardList($tempBoard, "●")
foreach ($nextWhiteTurnBoard in $tempboardList) {
$boardList.AddRange([Utility]::reversedBoardList($nextWhiteTurnBoard, "〇"))
}
}
foreach ($field in $boardList) {
$fieldLeth = ""
foreach($item in $field) {
$fieldLeth = $fieldLeth + ($item -join "")
}
$blackcnt = $fieldLeth.Length - ($fieldLeth -replace "●","").Length
$whitecnt = $fieldLeth.Length - ($fieldLeth -replace "〇","").Length
if($Player.playerColor -eq "●") {
if($blackcnt -gt $whitecnt) {
$win_route++
}
} elseif ($Player.playerColor -eq "〇") {
if($whitecnt -gt $blackcnt) {
$win_route++
}
}
}
if ($boardList.count -eq 0) {
} else {
if (($win_route/$boardList.count) -ge $max_win_route_rate) {
$max_win_route_rate = $win_route/$boardList.count
$tempposition = $position
}
}
}
}
$inputArray[0] = $tempposition
return $inputArray
}
static [String[]]logic_mix($blankArray, $boardData, $Player) {
######
#最も多くの石を裏返すところをリスト化する。
$max_diff_num = 0
$tempposition ="00"
$maxboardList = [System.Collections.ArrayList]::new()
$inputArray = get-random -input $blankArray -count ([int]::MaxValue)
foreach ($position in $inputArray) {
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass = [Player]::new($Player.playercolor, $Player.logic)
$tempClass.reverseStones($position, $tempBoard)
$diff_num = [Utility]::compareBoardDiffNum($tempBoard, $boardData)
if ($diff_num -gt $max_diff_num) {
$max_diff_num = $diff_num
$maxboardList.Add($position)
}
}
######
######
#上で作ったリストから3手目先で勝っている状態となるルートとなる確率が高い一手を選択する。
$max_win_route_rate = 0
$tempposition ="00"
$boardList = [System.Collections.ArrayList]::new()
foreach ($position in $maxboardList) {
$win_route = 0
$boardList.clear()
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass = [Player]::new($Player.playerColor, $Player.logic)
$tempClass.reverseStones($position, $tempBoard)
$canBeReversed = [Utility]::compareBoard($tempBoard, $boardData)
if($canBeReversed) {
} else {
if($Player.playerColor -eq "●") {
$tempboardList = [System.Collections.ArrayList]::new()
$tempboardList = [Utility]::reversedBoardList($tempBoard, "〇")
foreach ($nextBlackTurnBoard in $tempboardList) {
$boardList.AddRange([Utility]::reversedBoardList($nextBlackTurnBoard, "●"))
}
} elseif ($Player.playerColor -eq "〇") {
$tempboardList = [System.Collections.ArrayList]::new()
$tempboardList = [Utility]::reversedBoardList($tempBoard, "●")
foreach ($nextWhiteTurnBoard in $tempboardList) {
$boardList.AddRange([Utility]::reversedBoardList($nextWhiteTurnBoard, "〇"))
}
}
foreach ($field in $boardList) {
$fieldLeth = ""
foreach($item in $field) {
$fieldLeth = $fieldLeth + ($item -join "")
}
$blackcnt = $fieldLeth.Length - ($fieldLeth -replace "●","").Length
$whitecnt = $fieldLeth.Length - ($fieldLeth -replace "〇","").Length
if($Player.playerColor -eq "●") {
if($blackcnt -gt $whitecnt) {
$win_route++
}
} elseif ($Player.playerColor -eq "〇") {
if($whitecnt -gt $blackcnt) {
$win_route++
}
}
}
if ($boardList.count -eq 0) {
} else {
if (($win_route/$boardList.count) -ge $max_win_route_rate) {
$max_win_route_rate = $win_route/$boardList.count
$tempposition = $position
}
}
}
}
$inputArray[0] = $tempposition
######
######
#上で選択した一手より四隅を優先する。
$cornerArray = @()
if ($boardData[1][1] -eq '_') {
$cornerArray += "11"
}
if ($boardData[8][1] -eq '_') {
$cornerArray += "81"
}
if ($boardData[1][8] -eq '_') {
$cornerArray += "18"
}
if ($boardData[8][8] -eq '_') {
$cornerArray += "88"
}
$inputArray = $cornerArray + $inputArray
######
return $inputArray
}
}
##############################################################
## [Utility]クラス:
# 盤上のデータを比較する機能:[Boolean]compareBoard($tempBoard, $boardData)
# 盤上のデータを比較する機能(差の取得):[Int]compareBoardDiffNum($tempBoard, $boardData)
# 盤上のデータをコピーする機能:[String[][]]copyBoard($boardData)
# 盤上のデータから石をおくことができる場所に石を置いた際の盤上のデータのリストを返す
##############################################################
Class Utility {
#盤上のデータを比較する機能(引数:盤上データ、盤上のデータ、戻し値:一致するかどうか($true, $false))
static [Boolean]compareBoard($tempBoard, $boardData) {
for ($n=1; $n -le 8; $n++) {
for ($m=1; $m -le 8; $m++) {
if ($boardData[$n][$m] -eq $tempBoard[$n][$m]) {
}else{
return $false
}
}
}
return $true
}
#盤上のデータを比較する機能(引数:盤上データ、盤上のデータ、戻し値:差の数))
static [Int]compareBoardDiffNum($tempBoard, $boardData) {
[Int]$diff_num = 0
for ($n=1; $n -le 8; $n++) {
for ($m=1; $m -le 8; $m++) {
if ($boardData[$n][$m] -eq $tempBoard[$n][$m]) {
}else{
$diff_num++
}
}
}
return $diff_num
}
#盤上のデータをコピーする機能(引数:盤上のデータ、戻し値:コピーした盤上のデータ(配列は参照型なので、別の2次元配列を準備して戻す))
static [String[][]]copyBoard($boardData) {
$tempBoard=@(
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_'),
@('_','_','_','_','_','_','_','_','_','_')
)
for ($n=1; $n -le 8; $n++) {
for ($m=1; $m -le 8; $m++) {
$tempBoard[$n][$m] = $boardData[$n][$m]
}
}
return $tempBoard
}
#盤上のデータから石をおくことができる場所に石を置いた際の盤上のデータのリストを返す(引数:盤上のデータ、戻し値:裏返された盤上のデータのリスト)
static [System.Collections.ArrayList]reversedBoardList($boardData, $color) {
$boardList = [System.Collections.ArrayList]::new()
$tempClass = [Player]::new($color, 0)
for ($n=1; $n -le 8; $n++) {
for ($m=1; $m -le 8; $m++) {
if ($boardData[$n][$m] -ne '_') {
} else {
$position = [String]$n + [String]$m
$tempBoard = [Utility]::copyBoard($boardData)
$tempClass.reverseStones($position, $tempBoard)
$canBeReversed = [Utility]::compareBoard($tempBoard, $boardData)
if($canBeReversed) {
} else {
$boardList.Add($tempBoard)
}
}
}
}
return $boardList
}
}