• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

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

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

オセロのゲーム


コミットメタ情報

リビジョン57 (tree)
日時2015-07-01 17:50:28
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- VisualBasic/ReversiGame2/ReversiGame/AI/Level3/Coordinate.vb (revision 56)
+++ VisualBasic/ReversiGame2/ReversiGame/AI/Level3/Coordinate.vb (nonexistent)
@@ -1,38 +0,0 @@
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/AI/Level3/CoordinatesTransFormer.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame/AI/Level3/CoordinatesTransFormer.vb (revision 57)
@@ -0,0 +1,86 @@
1+Public Class CoordinatesTransFormer
2+
3+ Private _rotate As Integer
4+ Private _isMirror As Boolean
5+
6+ Sub New(ByVal first As Point)
7+ _rotate = 0
8+ _isMirror = False
9+
10+ If first = New Point("d3") Then
11+ _rotate = 1
12+ _isMirror = True
13+ ElseIf first = New Point("c4") Then
14+ _rotate = 2
15+ ElseIf first = New Point("e6") Then
16+ _rotate = 3
17+ _isMirror = True
18+ End If
19+ End Sub
20+
21+ ''' <summary>
22+ ''' 座標をf5を開始点とする座標系に正規化する
23+ ''' </summary>
24+ ''' <param name="p"></param>
25+ ''' <returns></returns>
26+ ''' <remarks></remarks>
27+ Public Function Normalize(ByVal p As Point) As Point
28+ Dim newp As Point = RotatePoint(p, _rotate)
29+ If _isMirror Then
30+ newp = MirrorPoint(newp)
31+ End If
32+ Return newp
33+ End Function
34+
35+ ''' <summary>
36+ ''' f5を開始点とする座標系を本来の座標に戻す。
37+ ''' </summary>
38+ ''' <param name="p"></param>
39+ ''' <returns></returns>
40+ ''' <remarks></remarks>
41+ Public Function DeNormalize(ByVal p As Point) As Point
42+ Dim newp As Point
43+ If _isMirror Then
44+ newp = MirrorPoint(p)
45+ Else
46+ newp = New Point(p.X, p.Y)
47+ End If
48+ Return RotatePoint(newp, -_rotate)
49+ End Function
50+
51+ ''' <summary>
52+ ''' 座標回転
53+ ''' </summary>
54+ ''' <param name="oldPoint"></param>
55+ ''' <param name="rotate">0:0度、1:90度,2:180度,3:270度</param>
56+ ''' <returns></returns>
57+ ''' <remarks></remarks>
58+ Shared Function RotatePoint(ByVal oldPoint As Point, ByVal rotate As Integer) As Point
59+ rotate = rotate Mod 4
60+ If rotate < 0 Then
61+ rotate += 4
62+ End If
63+ Dim x As Integer
64+ Dim y As Integer
65+ Select Case rotate
66+ Case 1
67+ x = oldPoint.Y
68+ y = Board.SIZE_X - oldPoint.X + 1
69+ Case 2
70+ x = Board.SIZE_X - oldPoint.X + 1
71+ y = Board.SIZE_Y - oldPoint.Y + 1
72+ Case 3
73+ x = Board.SIZE_X - oldPoint.Y + 1
74+ y = oldPoint.X
75+ Case Else 'case 0
76+ x = oldPoint.X
77+ y = oldPoint.Y
78+ End Select
79+ Return New Point(x, y)
80+ End Function
81+
82+ Shared Function MirrorPoint(ByVal oldPoint As Point) As Point
83+ Return New Point(Board.SIZE_X - oldPoint.X + 1, oldPoint.Y)
84+ End Function
85+
86+End Class
--- VisualBasic/ReversiGame2/ReversiGame.Tests/CoordinateTest.vb (revision 56)
+++ VisualBasic/ReversiGame2/ReversiGame.Tests/CoordinateTest.vb (revision 57)
@@ -59,9 +59,9 @@
5959 '''</summary>
6060 <TestMethod()> _
6161 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"))
62+ Assert.AreEqual(True, CoordinatesTransFormer.RotatePoint(New Point("f5"), 1) = New Point("e3"))
63+ Assert.AreEqual(True, CoordinatesTransFormer.RotatePoint(New Point("f5"), 2) = New Point("c4"))
64+ Assert.AreEqual(True, CoordinatesTransFormer.RotatePoint(New Point("f5"), 3) = New Point("d6"))
6565 End Sub
6666
6767 '''<summary>
@@ -69,7 +69,7 @@
6969 '''</summary>
7070 <TestMethod()> _
7171 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"))
72+ Assert.AreEqual(True, CoordinatesTransFormer.MirrorPoint(CoordinatesTransFormer.RotatePoint(New Point("f5"), 1)) = New Point("d3"))
73+ Assert.AreEqual(True, CoordinatesTransFormer.MirrorPoint(CoordinatesTransFormer.RotatePoint(New Point("f5"), 3)) = New Point("e6"))
7474 End Sub
7575 End Class
--- VisualBasic/ReversiGame2/ReversiGame.Tests/CoordinatesTransFormerTest.vb (nonexistent)
+++ VisualBasic/ReversiGame2/ReversiGame.Tests/CoordinatesTransFormerTest.vb (revision 57)
@@ -0,0 +1,74 @@
1+Imports Microsoft.VisualStudio.TestTools.UnitTesting
2+
3+Imports ReversiGame
4+
5+
6+
7+'''<summary>
8+'''CoordinatesTransFormerTest のテスト クラスです。すべての
9+'''CoordinatesTransFormerTest 単体テストをここに含めます
10+'''</summary>
11+<TestClass()> _
12+Public Class CoordinatesTransFormerTest
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+ '''Normalize のテスト
59+ '''</summary>
60+ <TestMethod()> _
61+ Public Sub NormalizeTest()
62+ Dim target As CoordinatesTransFormer = New CoordinatesTransFormer(New Point("d3"))
63+ Assert.AreEqual(True, target.Normalize(New Point("c3")) = New Point("f6"))
64+ End Sub
65+
66+ '''<summary>
67+ '''DeNormalize のテスト
68+ '''</summary>
69+ <TestMethod()> _
70+ Public Sub DeNormalizeTest()
71+ Dim target As CoordinatesTransFormer = New CoordinatesTransFormer(New Point("d3"))
72+ Assert.AreEqual(True, target.DeNormalize(New Point("f6")) = New Point("c3"))
73+ End Sub
74+End Class