• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

どうぶつしょうぎの完全解析をするGUI


Commit MetaInfo

Revision25 (tree)
Time2015-07-22 13:19:41
Authorbellyoshi

Log Message

Change Summary

Incremental Difference

--- doubutu.UI.Form/Move.vb (revision 24)
+++ doubutu.UI.Form/Move.vb (revision 25)
@@ -43,7 +43,7 @@
4343 ''' <remarks></remarks>
4444 Public Property ToPos As Position
4545 ''' <summary>
46- ''' 駒の種類
46+ ''' 移動した駒の種類
4747 ''' </summary>
4848 ''' <value></value>
4949 ''' <returns></returns>
@@ -51,6 +51,14 @@
5151 Public Property Koma As Koma
5252
5353 ''' <summary>
54+ ''' 取った駒の種類
55+ ''' </summary>
56+ ''' <value></value>
57+ ''' <returns></returns>
58+ ''' <remarks></remarks>
59+ Public Property CapturedPiece As Koma = Form.Koma.Empty
60+
61+ ''' <summary>
5462 ''' なりごまとなるか(ヒヨコがニワトリになるか)
5563 ''' </summary>
5664 ''' <returns></returns>
@@ -72,5 +80,10 @@
7280 Return False
7381 End Function
7482
75-
83+ Public Shared Operator =(ByVal op1 As Move, ByVal op2 As Move)
84+ Return op1.ToString = op2.ToString
85+ End Operator
86+ Public Shared Operator <>(ByVal op1 As Move, ByVal op2 As Move)
87+ Return Not (op1 = op2)
88+ End Operator
7689 End Class
--- doubutu.UI.Form/Board.vb (revision 24)
+++ doubutu.UI.Form/Board.vb (revision 25)
@@ -15,8 +15,24 @@
1515 ''' <remarks></remarks>
1616 Private _Capured(5) As Integer
1717
18- Private _turn As Side
18+ ''' <summary>
19+ ''' 手番
20+ ''' </summary>
21+ ''' <remarks></remarks>
22+ Private _side As Side
1923
24+ ''' <summary>
25+ ''' 手数
26+ ''' </summary>
27+ ''' <remarks></remarks>
28+ Private _turnCount As Integer
29+
30+ ''' <summary>
31+ ''' 棋譜ログ
32+ ''' </summary>
33+ ''' <remarks></remarks>
34+ Private _logs As New List(Of Move)
35+
2036 Public Function GetCells(ByVal pos As Position) As Koma
2137 Return GetCells(pos.X, pos.Y)
2238 End Function
@@ -61,7 +77,8 @@
6177 For Each c As Integer In _Capured
6278 c = 0
6379 Next
64- Me._turn = Side.sente
80+ Me._side = Side.sente
81+ Me._turnCount = 0
6582 End Sub
6683
6784 ''' <summary>
@@ -78,7 +95,11 @@
7895 For i As Integer = 0 To Me._Capured.Count - 1
7996 Me._Capured(i) = source._Capured(i)
8097 Next
81- Me._turn = source._turn
98+ Me._side = source._side
99+ Me._turnCount = source._turnCount
100+ For Each log As Move In source._logs
101+ _logs.Add(log)
102+ Next
82103 End Sub
83104
84105 ''' <summary>
@@ -101,7 +122,7 @@
101122 s.Append(_Capured(i))
102123 Next
103124 s.AppendLine()
104- s.AppendLine(SideUtil.ToCode(_turn))
125+ s.AppendLine(SideUtil.ToCode(_side))
105126 Return s.ToString
106127 End Function
107128
@@ -145,9 +166,61 @@
145166 Public Sub DoMove(ByVal move As Move)
146167 Debug.Assert(CanMove(move))
147168 DoEdit(move)
148- _turn = DirectCast(-_turn, Side)
169+ AddLog(move)
170+ _side = DirectCast(-_side, Side)
149171 End Sub
150172
173+ ''' <summary>
174+ ''' 一手進める
175+ ''' </summary>
176+ ''' <remarks></remarks>
177+ Public Sub DoNext()
178+ If _turnCount >= _logs.Count Then
179+ Exit Sub
180+ End If
181+ Dim move As Move = _logs(_turnCount)
182+ DoMove(move)
183+ End Sub
184+
185+ Private Sub AddLog(ByVal move As Move)
186+ If _logs.Count = _turnCount Then
187+ _logs.Add(move)
188+ ElseIf _logs.Count > _turnCount Then
189+ If _logs(_turnCount) <> move Then
190+ _logs(_turnCount) = move
191+ End If
192+ For i As Integer = _logs.Count - 1 To _turnCount + 1
193+ _logs.RemoveAt(i)
194+ Next
195+ End If
196+ _turnCount += 1
197+ Debug.Assert(_turnCount <= _logs.Count)
198+ End Sub
199+
200+ ''' <summary>
201+ ''' 一手戻す。
202+ ''' </summary>
203+ ''' <remarks></remarks>
204+ Public Sub Undo()
205+ If _turnCount <= 0 Then
206+ Exit Sub
207+ End If
208+ _turnCount -= 1
209+ Dim move As Move = _logs(_turnCount)
210+ If move.FromPos.IsCaptured Then
211+ _Capured(CapuredKomaIndex(move.Koma)) += 1
212+ SetCells(move.ToPos, Koma.Empty)
213+ Else
214+ If move.CapturedPiece <> Koma.Empty Then
215+ Dim capturedPiece As Koma = KomaUtil.CaputringKoma(move.CapturedPiece)
216+ _Capured(CapuredKomaIndex(capturedPiece)) -= 1
217+ End If
218+ SetCells(move.ToPos, move.CapturedPiece)
219+ SetCells(move.FromPos, move.Koma)
220+ End If
221+ _side = -_side
222+ End Sub
223+
151224 Public Sub DoEdit(ByVal move As Move)
152225 If move.FromPos.IsCaptured Then
153226 _Capured(CapuredKomaIndex(move.Koma)) -= 1
@@ -158,6 +231,7 @@
158231 If capturedPiece <> Koma.GoteLI AndAlso
159232 capturedPiece <> Koma.SenteLI Then
160233 _Capured(CapuredKomaIndex(capturedPiece)) += 1
234+ move.CapturedPiece = GetCells(move.ToPos)
161235 End If
162236 End If
163237 SetCells(move.ToPos, GetCells(move.FromPos))
@@ -172,7 +246,7 @@
172246 ''' <returns></returns>
173247 ''' <remarks></remarks>
174248 Public Function CanMove(ByVal move As Move) As Boolean
175- If Not _turn = KomaUtil.KomaSide(move.Koma) Then
249+ If Not _side = KomaUtil.KomaSide(move.Koma) Then
176250 Return False
177251 End If
178252 Dim fromPos As Position = move.FromPos
--- doubutu.UI.Form/frmMain.Designer.vb (revision 24)
+++ doubutu.UI.Form/frmMain.Designer.vb (revision 25)
@@ -25,7 +25,10 @@
2525 Dim Board1 As doubutu.UI.Form.Board = New doubutu.UI.Form.Board()
2626 Me.btnAnalyze = New System.Windows.Forms.Button()
2727 Me.TextBox1 = New System.Windows.Forms.TextBox()
28+ Me.btnUndoFirst = New System.Windows.Forms.Button()
29+ Me.btnUndo = New System.Windows.Forms.Button()
2830 Me.BoardViewer1 = New doubutu.UI.Form.Control.Board.BoardViewer()
31+ Me.btnNext = New System.Windows.Forms.Button()
2932 Me.SuspendLayout()
3033 '
3134 'btnAnalyze
@@ -46,20 +49,50 @@
4649 Me.TextBox1.Size = New System.Drawing.Size(392, 318)
4750 Me.TextBox1.TabIndex = 2
4851 '
52+ 'btnUndoFirst
53+ '
54+ Me.btnUndoFirst.Location = New System.Drawing.Point(86, 35)
55+ Me.btnUndoFirst.Name = "btnUndoFirst"
56+ Me.btnUndoFirst.Size = New System.Drawing.Size(89, 23)
57+ Me.btnUndoFirst.TabIndex = 4
58+ Me.btnUndoFirst.Text = "初手に戻す"
59+ Me.btnUndoFirst.UseVisualStyleBackColor = True
60+ '
61+ 'btnUndo
62+ '
63+ Me.btnUndo.Location = New System.Drawing.Point(181, 35)
64+ Me.btnUndo.Name = "btnUndo"
65+ Me.btnUndo.Size = New System.Drawing.Size(75, 23)
66+ Me.btnUndo.TabIndex = 4
67+ Me.btnUndo.Text = "一手戻す"
68+ Me.btnUndo.UseVisualStyleBackColor = True
69+ '
4970 'BoardViewer1
5071 '
5172 Me.BoardViewer1.IsBoardViewRotated = False
5273 Me.BoardViewer1.kyokumen = Board1
53- Me.BoardViewer1.Location = New System.Drawing.Point(12, 12)
74+ Me.BoardViewer1.Location = New System.Drawing.Point(12, 92)
5475 Me.BoardViewer1.Name = "BoardViewer1"
5576 Me.BoardViewer1.Size = New System.Drawing.Size(774, 544)
5677 Me.BoardViewer1.TabIndex = 3
5778 '
79+ 'btnNext
80+ '
81+ Me.btnNext.Location = New System.Drawing.Point(262, 35)
82+ Me.btnNext.Name = "btnNext"
83+ Me.btnNext.Size = New System.Drawing.Size(75, 23)
84+ Me.btnNext.TabIndex = 5
85+ Me.btnNext.Text = "一手進める"
86+ Me.btnNext.UseVisualStyleBackColor = True
87+ '
5888 'frmMain
5989 '
6090 Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!)
6191 Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
62- Me.ClientSize = New System.Drawing.Size(1272, 554)
92+ Me.ClientSize = New System.Drawing.Size(1272, 672)
93+ Me.Controls.Add(Me.btnNext)
94+ Me.Controls.Add(Me.btnUndo)
95+ Me.Controls.Add(Me.btnUndoFirst)
6396 Me.Controls.Add(Me.BoardViewer1)
6497 Me.Controls.Add(Me.TextBox1)
6598 Me.Controls.Add(Me.btnAnalyze)
@@ -72,5 +105,8 @@
72105 Friend WithEvents btnAnalyze As System.Windows.Forms.Button
73106 Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
74107 Friend WithEvents BoardViewer1 As doubutu.UI.Form.Control.Board.BoardViewer
108+ Friend WithEvents btnUndoFirst As System.Windows.Forms.Button
109+ Friend WithEvents btnUndo As System.Windows.Forms.Button
110+ Friend WithEvents btnNext As System.Windows.Forms.Button
75111
76112 End Class
--- doubutu.UI.Form/frmMain.vb (revision 24)
+++ doubutu.UI.Form/frmMain.vb (revision 25)
@@ -34,4 +34,19 @@
3434 e.Cancel = True
3535 End If
3636 End Sub
37+
38+ Private Sub btnUndoFirst_Click(sender As System.Object, e As System.EventArgs) Handles btnUndoFirst.Click
39+ BoardViewer1.kyokumen = New Board()
40+ BoardViewer1.DrawCurrentBitmap()
41+ End Sub
42+
43+ Private Sub btnUndo_Click(sender As System.Object, e As System.EventArgs) Handles btnUndo.Click
44+ BoardViewer1.kyokumen.Undo()
45+ BoardViewer1.DrawCurrentBitmap()
46+ End Sub
47+
48+ Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
49+ BoardViewer1.kyokumen.DoNext()
50+ BoardViewer1.DrawCurrentBitmap()
51+ End Sub
3752 End Class