• R/O
  • SSH
  • HTTPS

shoginextmove: コミット


コミットメタ情報

リビジョン79 (tree)
日時2016-02-23 16:05:10
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- Quantum/QuantumShogi/QuantumShogi.Logic.Test/BoardInitializerTests.cs (nonexistent)
+++ Quantum/QuantumShogi/QuantumShogi.Logic.Test/BoardInitializerTests.cs (revision 79)
@@ -0,0 +1,27 @@
1+using Microsoft.VisualStudio.TestTools.UnitTesting;
2+using QuantumShogi.Logic;
3+using System;
4+using System.Collections.Generic;
5+using System.Linq;
6+using System.Text;
7+
8+namespace QuantumShogi.Logic.Tests
9+{
10+ [TestClass()]
11+ public class BoardInitializerTests
12+ {
13+ [TestMethod()]
14+ public void GetCellsTest()
15+ {
16+ var initialize = new BoardInitializer();
17+ var p11 = initialize.GetCells(1, 1);
18+ Assert.IsTrue(p11.IsWhite);
19+ var p37 = initialize.GetCells(3, 7);
20+ Assert.IsTrue(p37.IsBlack);
21+ var p00 = initialize.GetCells(0, 0);
22+ Assert.IsTrue(p00.IsWall);
23+ var p12 = initialize.GetCells(1, 2);
24+ Assert.IsTrue(p12.IsEmtpy);
25+ }
26+ }
27+}
\ No newline at end of file
--- Quantum/QuantumShogi/QuantumShogi.Logic/BoardInitializer.cs (nonexistent)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/BoardInitializer.cs (revision 79)
@@ -0,0 +1,59 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+
6+namespace QuantumShogi.Logic
7+{
8+
9+ public class BoardInitializer
10+ {
11+ const int L = 9;//壁
12+ const int B = 1;//先手の量子駒
13+ const int W = 2;//後手の量子駒
14+ const int E = 0;//空
15+ int[][] initialArrangement = {
16+ new int[] {L,L,L,L,L,L,L,L,L,L,L},
17+ new int[] {L,W,W,W,W,W,W,W,W,W,L},
18+ new int[] {L,E,W,E,E,E,E,E,W,E,L},
19+ new int[] {L,W,W,W,W,W,W,W,W,W,L},
20+ new int[] {L,E,E,E,E,E,E,E,E,E,L},
21+ new int[] {L,E,E,E,E,E,E,E,E,E,L},
22+ new int[] {L,E,E,E,E,E,E,E,E,E,L},
23+ new int[] {L,B,B,B,B,B,B,B,B,B,L},
24+ new int[] {L,E,B,E,E,E,E,E,B,E,L},
25+ new int[] {L,B,B,B,B,B,B,B,B,B,L},
26+ new int[] {L,L,L,L,L,L,L,L,L,L,L}
27+ };
28+ public Piece GetCells(int x,int y)
29+ {
30+ int s = initialArrangement[y][10 - x];
31+ switch (s)
32+ {
33+ case L:
34+ {
35+ return Piece.GetWall();
36+ }
37+ case B:
38+ {
39+ return Piece.GetInitBlack();
40+ }
41+ case W:
42+ {
43+ return Piece.GetInitWhite();
44+ }
45+ case E:
46+ {
47+ return Piece.GetEmpty();
48+ }
49+ default:
50+ {
51+ System.Diagnostics.Debug.Assert(false);
52+ break;
53+ }
54+ }
55+ return Piece.GetEmpty();
56+
57+ }
58+ }
59+}
--- Quantum/QuantumShogi/QuantumShogi.Logic/Piece.cs (revision 78)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/Piece.cs (revision 79)
@@ -5,7 +5,7 @@
55
66 namespace QuantumShogi.Logic
77 {
8- class Piece
8+ public class Piece
99 {
1010 private bool[] _isTypeOf = new bool[CountOfType()];
1111 /// <summary>
@@ -67,7 +67,7 @@
6767 /// 先手の初期量子駒
6868 /// </summary>
6969 /// <returns></returns>
70- public Piece GetInitBlack()
70+ public static Piece GetInitBlack()
7171 {
7272 return new Piece(true,false,true);
7373 }
@@ -75,7 +75,7 @@
7575 /// 後手の初期量子駒
7676 /// </summary>
7777 /// <returns></returns>
78- public Piece GetInitWhite()
78+ public static Piece GetInitWhite()
7979 {
8080 return new Piece(false, true, true);
8181 }
@@ -86,7 +86,7 @@
8686 }
8787 static private Piece empty = CreateEmpty();
8888
89- public Piece GetEmpty()
89+ public static Piece GetEmpty()
9090 {
9191 return empty;
9292 }
@@ -97,7 +97,7 @@
9797
9898 }
9999 static private Piece wall = CreateWall();
100- public Piece GetWall()
100+ public static Piece GetWall()
101101 {
102102 return wall;
103103 }
--- Quantum/QuantumShogi/QuantumShogi.Logic/Move.cs (revision 78)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/Move.cs (revision 79)
@@ -7,9 +7,34 @@
77 {
88 class Move
99 {
10+ /// <summary>
11+ /// 駒の移動元
12+ /// </summary>
1013 public int from { get; set; }
14+ /// <summary>
15+ /// 駒の移動先
16+ /// </summary>
1117 public int to { get; set; }
18+ /// <summary>
19+ /// 移動または打った駒
20+ /// </summary>
1221 public Piece piece { get; set; }
13- public int
22+ /// <summary>
23+ /// 取られた駒
24+ /// </summary>
25+ public Piece capture { get; set; }
26+ /// <summary>
27+ /// 駒がなったか
28+ /// </summary>
29+ public bool promote;
30+ public Move(int from,int to,Piece piece,Piece capture = null,bool promote = false)
31+ {
32+ this.from = from;
33+ this.to = to;
34+ this.piece = piece;
35+ this.capture = capture;
36+ this.promote = promote;
37+
38+ }
1439 }
1540 }
--- Quantum/QuantumShogi/QuantumShogi.Logic/Board.cs (revision 78)
+++ Quantum/QuantumShogi/QuantumShogi.Logic/Board.cs (revision 79)
@@ -7,37 +7,51 @@
77 {
88 class Board
99 {
10- const int SIZE_OF_X = 9 + 2;
11- const int SIZE_OF_Y = 9 + 2;
10+ /// <summary>
11+ /// 盤の横サイズ
12+ /// </summary>
13+ const int SIZE_OF_X = 9;
14+ /// <summary>
15+ /// 盤の縦サイズ
16+ /// </summary>
17+ const int SIZE_OF_Y = 9;
18+ /// <summary>
19+ /// 壁を含めた盤の横サイズ
20+ /// </summary>
21+ const int MEM_SIZE_OF_X = SIZE_OF_X + 2;
22+ /// <summary>
23+ /// 盤を含めた盤の縦サイズ
24+ /// </summary>
25+ const int MEM_SIZE_OF_Y = SIZE_OF_Y + 2;
26+
27+ int GetIndexOfCell(int x, int y)
28+ {
29+ return MEM_SIZE_OF_X * y + x;
30+ }
1231 private Piece[] _cells;
1332 public Piece GetCells(int x,int y)
1433 {
15- return _cells[SIZE_OF_X * y + x];
34+ return _cells[GetIndexOfCell(x, y)];
1635 }
1736 private void SetCell(int x,int y,Piece koma)
1837 {
19-
38+ _cells[GetIndexOfCell(x, y)] = koma;
2039 }
21- public Board()
40+ public Board(BoardInitializer boardInitializer)
2241 {
23- _cells = new Piece[SIZE_OF_X * SIZE_OF_Y];
42+ _cells = new Piece[MEM_SIZE_OF_X * MEM_SIZE_OF_Y];
43+ for(int i = 0; i < _cells.Count(); i++)
44+ {
45+ _cells[i] = Piece.GetWall();
46+ }
47+ for(int x = 1; x <= SIZE_OF_X; x++)
48+ {
49+ for(int y = 1; y <= SIZE_OF_Y; y++)
50+ {
51+ SetCell(x, y, boardInitializer.GetCells(x, y));
52+ }
53+ }
2454
25- //9 壁
26- //1 量子
27- //0 空
28- int[][] initialArrangement = {
29- new int[] {9,9,9,9,9,9,9,9,9,9,9},
30- new int[] {9,1,1,1,1,1,1,1,1,1,9},
31- new int[] {9,0,1,0,0,0,0,0,1,0,9},
32- new int[] {9,1,1,1,1,1,1,1,1,1,9},
33- new int[] {9,0,0,0,0,0,0,0,0,0,9},
34- new int[] {9,0,0,0,0,0,0,0,0,0,9},
35- new int[] {9,0,0,0,0,0,0,0,0,0,9},
36- new int[] {9,1,1,1,1,1,1,1,1,1,9},
37- new int[] {9,0,1,0,0,0,0,0,1,0,9},
38- new int[] {9,1,1,1,1,1,1,1,1,1,9},
39- new int[] {9,9,9,9,9,9,9,9,9,9,9}
40- };
4155 }
4256
4357 }
旧リポジトリブラウザで表示