• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

オセロのゲーム


コミットメタ情報

リビジョン58 (tree)
日時2015-07-01 18:03:25
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- VisualBasic/ReversiGame2/ReversiGame/AI/Level3/alphabetaAI.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame/AI/Level3/alphabetaAI.vb (revision 58)
@@ -0,0 +1,69 @@
1+Namespace AI.Level3
2+
3+ Public Class alphabetaAI
4+ Implements AI.computerAI
5+
6+ Private _presearch_depth As Integer = 3
7+ Private _normal_depth As Integer = 5
8+ Private _wld_depth As Integer = 13
9+ Private _perfect_depth As Integer = 11
10+
11+ Private eval As Evaluator
12+
13+ Public Sub Initialize(ByVal nowBoard As Board) Implements computerAI.Initialize
14+ End Sub
15+
16+ Public Function EvaluationValue(ByVal targetBoard As Board) As Integer Implements computerAI.EvaluationValue
17+ Dim tempBoard As AIBoard = New AIBoard(targetBoard)
18+ Dim limit As Integer
19+ eval = New MidEvaluator
20+ If Board.MAX_TURNS - targetBoard.GetTurns <= _wld_depth Then
21+ limit = Integer.MaxValue
22+ If Board.MAX_TURNS - targetBoard.GetTurns <= _perfect_depth Then
23+ eval = New PerfectEvaluator
24+ Else
25+ eval = New WLDEvaluator
26+ End If
27+ Else
28+ limit = _normal_depth
29+ End If
30+
31+ Return -negaMax(tempBoard, limit - 1, -Integer.MaxValue, Integer.MaxValue)
32+ End Function
33+
34+ Function negaMax(ByVal targetBoard As AIBoard, ByVal depth As Integer, ByVal alpha As Integer, ByVal beta As Integer) As Integer
35+ If depth <= 0 OrElse targetBoard.IsGameEnd Then
36+ Return eval.Evaluate(targetBoard)
37+ End If
38+
39+ Dim val As Integer
40+ Dim postions As IList(Of Point) = targetBoard.MovablePostions
41+
42+ If postions.Count = 0 Then
43+ targetBoard.Pass()
44+ val = -negaMax(targetBoard, depth, -beta, -alpha)
45+ targetBoard.Undo()
46+ Return val
47+ End If
48+
49+ For Each discPoint As Point In postions
50+
51+ targetBoard.Move(discPoint)
52+ val = -negaMax(targetBoard, depth - 1, -beta, -alpha)
53+ targetBoard.Undo()
54+ alpha = Math.Max(alpha, val)
55+ If alpha >= beta Then
56+ Return alpha
57+ End If
58+ Next
59+
60+ Return alpha
61+ End Function
62+
63+
64+
65+
66+
67+
68+ End Class
69+End Namespace
--- VisualBasic/ReversiGame2/ReversiGame/AI/Level3/MidEvaluator.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame/AI/Level3/MidEvaluator.vb (revision 58)
@@ -0,0 +1,8 @@
1+Namespace AI.Level3
2+
3+ Public Class MidEvaluator
4+ Inherits AI.Level2.MidEvaluator
5+
6+ End Class
7+
8+End Namespace
\ No newline at end of file
--- VisualBasic/ReversiGame2/ReversiGame/AI/Level3/Node.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame/AI/Level3/Node.vb (revision 58)
@@ -0,0 +1,10 @@
1+Namespace AI.Level3
2+
3+ Public Class Node
4+ Public Property Child As Node = Nothing
5+ Public Property Sibling As Node = Nothing
6+ Public Property Point As Point = Nothing
7+ End Class
8+
9+End Namespace
10+
--- VisualBasic/ReversiGame2/ReversiGame/Board.vb (revision 57)
+++ VisualBasic/ReversiGame2/ReversiGame/Board.vb (revision 58)
@@ -33,9 +33,13 @@
3333 End Property
3434
3535 Protected _updateLogs As New List(Of ReverseLog)
36- Public ReadOnly Property UpdateLogs As IList(Of ReverseLog)
36+ Public ReadOnly Property History As IList(Of Point)
3737 Get
38- Return _updateLogs
38+ Dim points As New List(Of Point)
39+ For Each log As ReverseLog In _updateLogs
40+ points.Add(log.PutDisc)
41+ Next
42+ Return points
3943 End Get
4044 End Property
4145
--- VisualBasic/ReversiGame2/ReversiGame/frmCodes.vb (revision 57)
+++ VisualBasic/ReversiGame2/ReversiGame/frmCodes.vb (revision 58)
@@ -8,18 +8,14 @@
88 End Sub
99
1010 Public Sub ShowCodes()
11- Dim codes As New List(Of Point)
12- For Each log As ReverseLog In Board.UpdateLogs
13- codes.Add(log.PutDisc)
14- Next
15- lstCodes.DataSource = codes
11+ lstCodes.DataSource = Board.History
1612 lstCodes.DisplayMember = "ToString"
1713 End Sub
1814
1915 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
2016 Dim codesLine As String = String.Empty
21- For Each log As ReverseLog In Board.UpdateLogs
22- codesLine += log.PutDisc.ToString
17+ For Each p As Point In Board.History
18+ codesLine += p.ToString
2319 Next
2420 Dim fileName As String = IOUtil.GetExePath + "/reversi.book"
2521 Try