• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

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

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

オセロのゲーム


コミットメタ情報

リビジョン56 (tree)
日時2015-07-01 17:36:24
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- VisualBasic/ReversiGame2/ReversiGame/AI/Level3/Coordinate.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame/AI/Level3/Coordinate.vb (revision 56)
@@ -0,0 +1,38 @@
1+Public Class Coordinate
2+
3+ ''' <summary>
4+ ''' 座標回転
5+ ''' </summary>
6+ ''' <param name="oldPoint"></param>
7+ ''' <param name="rotate">0:0度、1:90度,2:180度,3:270度</param>
8+ ''' <returns></returns>
9+ ''' <remarks></remarks>
10+ Shared Function RotatePoint(ByVal oldPoint As Point, ByVal rotate As Integer) As Point
11+ rotate = rotate Mod 4
12+ If rotate < 0 Then
13+ rotate += 4
14+ End If
15+ Dim x As Integer
16+ Dim y As Integer
17+ Select Case rotate
18+ Case 1
19+ x = oldPoint.Y
20+ y = Board.SIZE_X - oldPoint.X + 1
21+ Case 2
22+ x = Board.SIZE_X - oldPoint.X + 1
23+ y = Board.SIZE_Y - oldPoint.Y + 1
24+ Case 3
25+ x = Board.SIZE_X - oldPoint.Y + 1
26+ y = oldPoint.X
27+ Case Else 'case 0
28+ x = oldPoint.X
29+ y = oldPoint.Y
30+ End Select
31+ Return New Point(x, y)
32+ End Function
33+
34+ Shared Function MirrorPoint(ByVal oldPoint As Point) As Point
35+ Return New Point(Board.SIZE_X - oldPoint.X + 1, oldPoint.Y)
36+ End Function
37+
38+End Class
--- VisualBasic/ReversiGame2/ReversiGame/Point.vb (revision 55)
+++ VisualBasic/ReversiGame2/ReversiGame/Point.vb (revision 56)
@@ -7,10 +7,32 @@
77 Me.Y = y
88 End Sub
99
10- Private _xStrings() As String = {"a", "b", "c", "d", "e", "f", "g", "h"}
10+ Sub New(ByVal coordinate As String)
11+ Debug.Assert(coordinate.Length = 2)
12+ Dim coordXAsc As Integer = Asc(coordinate(0))
13+ If Asc("a"c) <= coordXAsc AndAlso coordXAsc <= Asc("h") Then
14+ X = coordXAsc - Asc("a"c) + 1
15+ End If
16+ If Asc("A"c) <= coordXAsc AndAlso coordXAsc <= Asc("H") Then
17+ X = coordXAsc - Asc("A"c) + 1
18+ End If
19+ Dim coordYAsc As Integer = Asc(coordinate(1))
20+ If Asc("1"c) <= coordYAsc AndAlso coordYAsc <= Asc("8"c) Then
21+ Y = Asc(coordinate(1)) - Asc("1"c) + 1
22+ End If
23+ End Sub
24+
25+ Public Shared Operator =(ByVal op1 As Point, ByVal op2 As Point) As Boolean
26+ Return op1.X = op2.X AndAlso op1.Y = op2.Y
27+ End Operator
28+
29+ Public Shared Operator <>(ByVal op1 As Point, ByVal op2 As Point) As Boolean
30+ Return Not (op1 = op2)
31+ End Operator
32+
1133 Public Overrides Function ToString() As String
12- If 1 <= X AndAlso X <= _xStrings.Length Then
13- Return String.Format("{0}{1}", _xStrings(X - 1), Y)
34+ If 1 <= X AndAlso X <= Board.SIZE_X Then
35+ Return String.Format("{0}{1}", Chr(Asc("a"c) + X - 1), Y)
1436 End If
1537 Return String.Format("{0}{1}", X, Y)
1638 End Function
--- VisualBasic/ReversiGame2/ReversiGame.Tests/CoordinateTest.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame.Tests/CoordinateTest.vb (revision 56)
@@ -0,0 +1,75 @@
1+Imports Microsoft.VisualStudio.TestTools.UnitTesting
2+
3+Imports ReversiGame
4+
5+
6+
7+'''<summary>
8+'''CoordinateTest のテスト クラスです。すべての
9+'''CoordinateTest 単体テストをここに含めます
10+'''</summary>
11+<TestClass()> _
12+Public Class CoordinateTest
13+
14+
15+ Private testContextInstance As TestContext
16+
17+ '''<summary>
18+ '''現在のテストの実行についての情報および機能を
19+ '''提供するテスト コンテキストを取得または設定します。
20+ '''</summary>
21+ Public Property TestContext() As TestContext
22+ Get
23+ Return testContextInstance
24+ End Get
25+ Set(value As TestContext)
26+ testContextInstance = Value
27+ End Set
28+ End Property
29+
30+#Region "追加のテスト属性"
31+ '
32+ 'テストを作成するときに、次の追加属性を使用することができます:
33+ '
34+ 'クラスの最初のテストを実行する前にコードを実行するには、ClassInitialize を使用
35+ '<ClassInitialize()> _
36+ 'Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
37+ 'End Sub
38+ '
39+ 'クラスのすべてのテストを実行した後にコードを実行するには、ClassCleanup を使用
40+ '<ClassCleanup()> _
41+ 'Public Shared Sub MyClassCleanup()
42+ 'End Sub
43+ '
44+ '各テストを実行する前にコードを実行するには、TestInitialize を使用
45+ '<TestInitialize()> _
46+ 'Public Sub MyTestInitialize()
47+ 'End Sub
48+ '
49+ '各テストを実行した後にコードを実行するには、TestCleanup を使用
50+ '<TestCleanup()> _
51+ 'Public Sub MyTestCleanup()
52+ 'End Sub
53+ '
54+#End Region
55+
56+
57+ '''<summary>
58+ '''RotatePoint のテスト
59+ '''</summary>
60+ <TestMethod()> _
61+ Public Sub RotatePointTest()
62+ Assert.AreEqual(True, Coordinate.RotatePoint(New Point("f5"), 1) = New Point("e3"))
63+ Assert.AreEqual(True, Coordinate.RotatePoint(New Point("f5"), 2) = New Point("c4"))
64+ Assert.AreEqual(True, Coordinate.RotatePoint(New Point("f5"), 3) = New Point("d6"))
65+ End Sub
66+
67+ '''<summary>
68+ '''MirrorPoint のテスト
69+ '''</summary>
70+ <TestMethod()> _
71+ Public Sub MirrorPointTest()
72+ Assert.AreEqual(True, Coordinate.MirrorPoint(Coordinate.RotatePoint(New Point("f5"), 1)) = New Point("d3"))
73+ Assert.AreEqual(True, Coordinate.MirrorPoint(Coordinate.RotatePoint(New Point("f5"), 3)) = New Point("e6"))
74+ End Sub
75+End Class
--- VisualBasic/ReversiGame2/ReversiGame.Tests/PointTest.vb (revision 55)
+++ VisualBasic/ReversiGame2/ReversiGame.Tests/PointTest.vb (revision 56)
@@ -1,5 +1,9 @@
1-Imports System.Text
1+Imports Microsoft.VisualStudio.TestTools.UnitTesting
22
3+Imports ReversiGame
4+
5+Imports System.Text
6+
37 <TestClass()>
48 Public Class PointTest
59
@@ -71,4 +75,36 @@
7175 Assert.AreEqual("99", point.ToString)
7276 End Sub
7377
78+
79+ '''<summary>
80+ '''op_Equality のテスト
81+ '''</summary>
82+ <TestMethod()> _
83+ Public Sub op_EqualityTest()
84+ Assert.AreEqual(True, New Point("f5") = New Point("f5"))
85+ Assert.AreEqual(False, New Point("f4") = New Point("f5"))
86+ End Sub
87+
88+ '''<summary>
89+ '''op_Inequality のテスト
90+ '''</summary>
91+ <TestMethod()> _
92+ Public Sub op_InequalityTest()
93+ Assert.AreEqual(False, New Point("f5") <> New Point("f5"))
94+ Assert.AreEqual(True, New Point("f4") <> New Point("f5"))
95+ End Sub
96+
97+ '''<summary>
98+ '''Point コンストラクター のテスト
99+ '''</summary>
100+ <TestMethod()> _
101+ Public Sub PointConstructorTest()
102+ Dim p1 As Point = New Point("f5")
103+ Assert.AreEqual(6, p1.X)
104+ Assert.AreEqual(5, p1.Y)
105+ Dim p2 As Point = New Point("A6")
106+ Assert.AreEqual(1, p2.X)
107+ Assert.AreEqual(6, p2.Y)
108+
109+ End Sub
74110 End Class