• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

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

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

CEDEC AI 2013 の決勝で使用したプログラムのソースコード。


コミットメタ情報

リビジョンe4b6cd75e8f441f68f8cbc9f73cbd7d882ad6166 (tree)
日時2013-08-14 10:22:07
作者B_head <b_head@user...>
コミッターB_head

ログメッセージ

ビジュアライザーを作成。

Signed-off-by: B_head <b_head@users.sourceforge.jp>

変更サマリ

差分

Binary files a/CedecAI.v11.suo and b/CedecAI.v11.suo differ
--- a/Common/Common.cs
+++ b/Common/Common.cs
@@ -3,10 +3,11 @@ using System.Collections.Generic;
33 using System.Linq;
44 using System.Text;
55 using System.Threading.Tasks;
6+using System.IO;
67
7-namespace CedecAI
8+namespace Common
89 {
9- struct GameMass
10+ public struct GameMass
1011 {
1112 public int Player;
1213 public Terrain Ter;
@@ -14,7 +15,7 @@ namespace CedecAI
1415 public int WaitRobot;
1516 }
1617
17- enum Terrain
18+ public enum Terrain
1819 {
1920 Outside,
2021 Wasteland,
@@ -27,4 +28,27 @@ namespace CedecAI
2728 House,
2829 Town,
2930 }
31+
32+ public enum Direction
33+ {
34+ Right,
35+ UpperRight,
36+ DownerRight,
37+ Left,
38+ UpperLeft,
39+ DownerLeft,
40+ }
41+
42+ public interface GameAI
43+ {
44+ string Prepare(int player, GameField field);
45+ void Think(int turn, int maxTurn, int player, GameField field, Commander com);
46+ }
47+
48+ public interface Commander
49+ {
50+ void Move(int x, int y, Direction dir, int robot);
51+ void Build(int x, int y, Terrain building);
52+ void Finish();
53+ }
3054 }
--- a/Common/Common.csproj
+++ b/Common/Common.csproj
@@ -7,10 +7,11 @@
77 <ProjectGuid>{B44455BF-0F12-47E1-AB63-FE2C7D8F5180}</ProjectGuid>
88 <OutputType>Library</OutputType>
99 <AppDesignerFolder>Properties</AppDesignerFolder>
10- <RootNamespace>CedecAI</RootNamespace>
11- <AssemblyName>CedecAI</AssemblyName>
12- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10+ <RootNamespace>Common</RootNamespace>
11+ <AssemblyName>Common</AssemblyName>
12+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1313 <FileAlignment>512</FileAlignment>
14+ <TargetFrameworkProfile />
1415 </PropertyGroup>
1516 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617 <DebugSymbols>true</DebugSymbols>
@@ -33,16 +34,16 @@
3334 <Reference Include="System" />
3435 <Reference Include="System.Core" />
3536 <Reference Include="System.Xml.Linq" />
36- <Reference Include="System.Data.DataSetExtensions" />
3737 <Reference Include="Microsoft.CSharp" />
38- <Reference Include="System.Data" />
3938 <Reference Include="System.Xml" />
4039 </ItemGroup>
4140 <ItemGroup>
4241 <Compile Include="Common.cs" />
42+ <Compile Include="ExamineFunction.cs" />
4343 <Compile Include="GameField.cs" />
4444 <Compile Include="Field.cs" />
4545 <Compile Include="Properties\AssemblyInfo.cs" />
46+ <Compile Include="TestAI.cs" />
4647 </ItemGroup>
4748 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
4849 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
--- /dev/null
+++ b/Common/ExamineFunction.cs
@@ -0,0 +1,25 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+
7+namespace Common
8+{
9+ public static class ExamineFunction
10+ {
11+ public static int GetEstimateTowerDamage(this GameField field, int player, int x, int y)
12+ {
13+ int result = 0, tx, ty;
14+ for (int i = 1; i < 13; i++)
15+ {
16+ field.TransformTowerRange(i, x, y, out tx, out ty);
17+ if (field.IsInRange(tx, ty)) continue;
18+ if (field[tx, ty].Ter != Terrain.AttackTower) continue;
19+ if (field[tx, ty].Player == player) continue;
20+ result += 2;
21+ }
22+ return result;
23+ }
24+ }
25+}
--- a/Common/Field.cs
+++ b/Common/Field.cs
@@ -4,9 +4,9 @@ using System.Linq;
44 using System.Text;
55 using System.Threading.Tasks;
66
7-namespace CedecAI
7+namespace Common
88 {
9- class Field<TYPE>
9+ public class Field<TYPE>
1010 {
1111 protected TYPE[,] field;
1212 public readonly int Width;
@@ -26,5 +26,15 @@ namespace CedecAI
2626 return field[x, y];
2727 }
2828 }
29+
30+ public bool IsInRange(int x, int y)
31+ {
32+ return x < 0 || x >= Width || y < 0 || y >= Height;
33+ }
34+
35+ public void CopyTo(Field<TYPE> other)
36+ {
37+ Array.Copy(field, other.field, Width * Height);
38+ }
2939 }
3040 }
--- a/Common/GameField.cs
+++ b/Common/GameField.cs
@@ -5,100 +5,140 @@ using System.Text;
55 using System.Threading.Tasks;
66 using System.IO;
77
8-namespace CedecAI
8+namespace Common
99 {
10- class GameField : Field<GameMass>
10+ public class GameField : Field<GameMass>
1111 {
1212 public readonly int Size;
1313
1414 public GameField(int size)
15- : base(size * 2 + 1, size * 2 + 1)
15+ : base(size * 2 - 1, size * 2 - 1)
1616 {
1717 Size = size;
1818 Initialize();
1919 }
2020
21- private void Initialize()
21+ protected void Initialize()
2222 {
2323 for (int x = 0; x < Width; x++)
2424 {
2525 for (int y = 0; y < Height; y++)
2626 {
2727 field[x, y].Player = -1;
28- if (y < 1 || y >= Height - 1) continue;
29- if (y <= Size)
28+ if (y < 0 || y >= Height) continue;
29+ if (y < Size)
3030 {
31- if (x < Size - y + 1 || x >= Width - 1) continue;
31+ if (x < Size - 1 - y || x >= Width) continue;
3232 }
3333 else
3434 {
35- if (x < 1 || x >= Width - 1 + Size - y) continue;
35+ if (x < 0 || x >= Width + Size - 1 - y) continue;
3636 }
3737 field[x, y].Ter = Terrain.Wasteland;
3838 }
3939 }
4040 }
4141
42- public static GameField ParseText(TextReader read, out int turn, out int maxTurn, out int playerTurn)
42+ public bool Move(int player, int fromX, int fromY, Direction dir, int robot)
4343 {
44- string[] line;
45- line = read.ReadLine().Split(' ');
46- turn = int.Parse(line[0]);
47- maxTurn = int.Parse(line[1]);
48- playerTurn = int.Parse(line[2]);
49- line = read.ReadLine().Split(' ');
50- GameField result = new GameField(int.Parse(line[0]));
51- int count = int.Parse(line[1]);
52- for (int i = 0; i < count; i++)
44+ if (!IsMove(player, fromX, fromY, dir, robot)) return false;
45+ int toX, toY;
46+ TransformDirection(dir, fromX, fromY, out toX, out toY);
47+ GameMass from = field[fromX, fromY], to = field[toX, toY];
48+ if (to.Player == player)
5349 {
54- line = read.ReadLine().Split(' ');
55- int x = int.Parse(line[0]), y = int.Parse(line[1]), player = int.Parse(line[2]), robot = int.Parse(line[3]);
56- Terrain ter = ParseTopography(line[5], line[6]);
57- result.field[x, y] = new GameMass { Player = player, Ter = ter, WaitRobot = robot };
50+ from.ActiveRobot -= robot;
51+ to.WaitRobot += robot;
5852 }
59- return result;
53+ else
54+ {
55+ from.ActiveRobot -= robot;
56+ if (to.WaitRobot < robot)
57+ {
58+ to.WaitRobot = robot - to.WaitRobot;
59+ to.Player = player;
60+ }
61+ else
62+ {
63+ to.WaitRobot -= robot;
64+ }
65+ }
66+ field[fromX, fromY] = from;
67+ field[toX, toY] = to;
68+ return true;
6069 }
6170
62- private static Terrain ParseTopography(string ter, string building)
71+ public bool IsMove(int player, int fromX, int fromY, Direction dir, int robot)
6372 {
64- switch (ter)
73+ if (robot <= 0) return false;
74+ int toX, toY;
75+ TransformDirection(dir, fromX, fromY, out toX, out toY);
76+ if (IsInRange(toX, toY)) return false;
77+ GameMass from = field[fromX, fromY], to = field[toX, toY];
78+ if (from.Player != player) return false;
79+ if (from.ActiveRobot < robot) return false;
80+ if (from.Ter == Terrain.Hole) return false;
81+ if (to.Player == player)
6582 {
66- case "wasteland":
67- case "settlement":
68- return Terrain.Wasteland;
69- case "base":
70- switch (building)
71- {
72- case "initial": return Terrain.Initial;
73- case "robotmaker": return Terrain.RobotMaker;
74- case "tower": return Terrain.AttackTower;
75- case "excavator": return Terrain.Excavator;
76- case "bridge": return Terrain.Bridge;
77- case "house": return Terrain.House;
78- case "town": return Terrain.Town;
79- default: throw new Exception();
80- }
81- case "hole":
82- return Terrain.Hole;
83- default:
84- throw new Exception();
83+ if (to.Ter == Terrain.Outside) return false;
84+ }
85+ else
86+ {
87+ if (to.Ter != Terrain.Wasteland && to.Ter != Terrain.Hole) return false;
8588 }
89+ return true;
8690 }
8791
88- public void SetActive(int player)
92+ public bool Build(int player, int x, int y, Terrain building, ref int extraPoint)
93+ {
94+ if (!IsBuild(player, x, y, building)) return false;
95+ int resource, robot;
96+ GetRequirement(building, out resource, out robot);
97+ if (building == Terrain.Town)
98+ {
99+ extraPoint += GetPrepareResource(x, y) - resource;
100+ }
101+ field[x, y].ActiveRobot -= robot;
102+ field[x, y].Ter = building;
103+ return true;
104+ }
105+
106+ public bool IsBuild(int player, int x, int y, Terrain building)
107+ {
108+ if (field[x, y].Player != player) return false;
109+ if (field[x, y].Ter != Terrain.Wasteland && field[x, y].Ter != Terrain.Hole) return false;
110+ if (field[x, y].Ter == Terrain.Wasteland && building == Terrain.Bridge) return false;
111+ if (field[x, y].Ter == Terrain.Hole && building != Terrain.Bridge) return false;
112+ int resource, robot;
113+ GetRequirement(building, out resource, out robot);
114+ if (field[x, y].ActiveRobot < robot) return false;
115+ if (GetPrepareResource(x, y) < resource) return false;
116+ return true;
117+ }
118+
119+ public void StartTurn(int player)
89120 {
90121 for (int x = 0; x < Width; x++)
91122 {
92123 for (int y = 0; y < Height; y++)
93124 {
94- if (field[x, y].Player != player) continue;
95- field[x, y].ActiveRobot += field[x, y].WaitRobot;
96- field[x, y].WaitRobot = 0;
125+ if (field[x, y].Player == player)
126+ {
127+ field[x, y].WaitRobot += GetAddRobot(x, y);
128+ field[x, y].ActiveRobot += field[x, y].WaitRobot;
129+ field[x, y].WaitRobot = 0;
130+ }
131+ else
132+ {
133+ if (field[x, y].WaitRobot <= 0) continue;
134+ field[x, y].WaitRobot -= GetTowerDamage(player, x, y);
135+ if (field[x, y].WaitRobot < 0) field[x, y].WaitRobot = 0;
136+ }
97137 }
98138 }
99139 }
100140
101- public void SetWait(int player)
141+ public void EndTurn(int player)
102142 {
103143 for (int x = 0; x < Width; x++)
104144 {
@@ -111,81 +151,79 @@ namespace CedecAI
111151 }
112152 }
113153
114- public void TowerAttacking(int player)
154+ public void GetRequirement(Terrain ter, out int resource, out int robot)
155+ {
156+ switch (ter)
157+ {
158+ case Terrain.RobotMaker: resource = 4; robot = 50; break;
159+ case Terrain.AttackTower: resource = 5; robot = 25; break;
160+ case Terrain.Excavator: resource = 4; robot = 25; break;
161+ case Terrain.Bridge: resource = 4; robot = 15; break;
162+ case Terrain.House: resource = 4; robot = 10; break;
163+ case Terrain.Town: resource = 9; robot = 10; break;
164+ default: throw new Exception();
165+ }
166+ }
167+
168+ public int GetTotalVictoryPoint(int player)
115169 {
170+ int result = 0;
116171 for (int x = 0; x < Width; x++)
117172 {
118173 for (int y = 0; y < Height; y++)
119174 {
120- if (field[x, y].Player == player) continue;
121- if (field[x, y].WaitRobot <= 0) continue;
122- field[x, y].WaitRobot -= GetTowerDamage(x, y);
175+ if (field[x, y].Player != player) continue;
176+ result += GetVictoryPoint(x, y);
123177 }
124178 }
179+ return result;
125180 }
126181
127- public bool Move(int player, int fromX, int fromY, int toX, int toY, int robot)
182+ public int GetVictoryPoint(int x, int y)
128183 {
129- GameMass from = field[fromX, fromY], to = field[toX, toY];
130- if (from.Player != player) return false;
131- if (from.ActiveRobot < robot) return false;
132- if (from.Ter == Terrain.Hole) return false;
133- if (to.Player == player)
184+ if (field[x, y].Ter == Terrain.Wasteland)
134185 {
135- if (to.Ter == Terrain.Outside) return false;
136- from.ActiveRobot -= robot;
137- to.WaitRobot += robot;
186+ return 1;
187+ }
188+ else if (field[x, y].Ter == Terrain.Hole || field[x, y].Ter == Terrain.Outside)
189+ {
190+ return 0;
138191 }
139192 else
140193 {
141- if (to.Ter != Terrain.Wasteland && to.Ter != Terrain.Hole) return false;
142- from.ActiveRobot -= robot;
143- if (to.WaitRobot < robot)
144- {
145- to.WaitRobot = robot - to.WaitRobot;
146- to.Player = player;
147- }
148- else
149- {
150- to.WaitRobot -= robot;
151- }
194+ return 3;
152195 }
153- field[fromX, fromY] = from;
154- field[toX, toY] = to;
155- return true;
156196 }
157197
158- public bool Build(int player, int x, int y, Terrain ter, ref int extraPoint)
198+ public int GetAddRobot(int x, int y)
159199 {
160- if (field[x, y].Player != player) return false;
161- if (field[x, y].Ter == Terrain.Wasteland && ter == Terrain.Bridge) return false;
162- if (field[x, y].Ter == Terrain.Hole && ter != Terrain.Bridge) return false;
163- int resource, robot;
164- GetRequirement(ter, out resource, out robot);
165- if (field[x, y].ActiveRobot < robot) return false;
166- int pr = GetPrepareResource(x, y);
167- if (pr < resource) return false;
168- if (ter == Terrain.Town)
200+ if (field[x, y].Ter == Terrain.Initial)
169201 {
170- extraPoint += pr - resource;
202+ return 5;
203+ }
204+ else if (field[x, y].Ter == Terrain.RobotMaker)
205+ {
206+ return 1;
207+ }
208+ else
209+ {
210+ return 0;
171211 }
172- field[x, y].ActiveRobot -= robot;
173- field[x, y].Ter = ter;
174- return true;
175212 }
176213
177- public void GetRequirement(Terrain ter, out int resource, out int robot)
214+ public int GetTowerDamage(int player, int x, int y)
178215 {
179- switch (ter)
216+ if (field[x, y].Player == player) return 0;
217+ int result = 0, tx, ty;
218+ for (int i = 1; i < 13; i++)
180219 {
181- case Terrain.RobotMaker: resource = 4; robot = 50; break;
182- case Terrain.AttackTower: resource = 5; robot = 25; break;
183- case Terrain.Excavator: resource = 4; robot = 25; break;
184- case Terrain.Bridge: resource = 4; robot = 15; break;
185- case Terrain.House: resource = 4; robot = 10; break;
186- case Terrain.Town: resource = 9; robot = 10; break;
187- default: throw new Exception();
220+ TransformTowerRange(i, x, y, out tx, out ty);
221+ if (IsInRange(tx, ty)) continue;
222+ if (field[tx, ty].Ter != Terrain.AttackTower) continue;
223+ if (field[tx, ty].Player != player) continue;
224+ result += 2;
188225 }
226+ return result;
189227 }
190228
191229 public int GetPrepareResource(int x, int y)
@@ -194,6 +232,7 @@ namespace CedecAI
194232 for (int i = 0; i < 7; i++)
195233 {
196234 TransformAdjoin(i, x, y, out tx, out ty);
235+ if (IsInRange(tx, ty)) continue;
197236 if (field[tx, ty].Player != player) continue;
198237 result += GetYieldResource(tx, ty);
199238 }
@@ -207,6 +246,7 @@ namespace CedecAI
207246 for (int i = 1; i < 7; i++)
208247 {
209248 TransformAdjoin(i, x, y, out tx, out ty);
249+ if (IsInRange(tx, ty)) continue;
210250 if (field[tx, ty].Player != player) continue;
211251 if (field[tx, ty].Ter != Terrain.Excavator) continue;
212252 result++;
@@ -214,17 +254,20 @@ namespace CedecAI
214254 return result;
215255 }
216256
217- public int GetTowerDamage(int x, int y)
257+ public void TransformDirection(Direction dir, int x, int y, out int tx, out int ty)
218258 {
219- int result = 0, player = field[x, y].Player, tx, ty;
220- for (int i = 1; i < 13; i++)
259+ tx = x;
260+ ty = y;
261+ switch (dir)
221262 {
222- TransformTowerRange(i, x, y, out tx, out ty);
223- if (field[tx, ty].Ter != Terrain.AttackTower) continue;
224- if (field[tx, ty].Player == player) continue;
225- result += 2;
263+ case Direction.Right: tx += 1; ty += 0; break;
264+ case Direction.UpperRight: tx += 1; ty += -1; break;
265+ case Direction.DownerRight: tx += 0; ty += 1; break;
266+ case Direction.Left: tx += -1; ty += 0; break;
267+ case Direction.DownerLeft: tx += -1; ty += 1; break;
268+ case Direction.UpperLeft: tx += 0; ty += -1; break;
269+ default: throw new Exception();
226270 }
227- return result;
228271 }
229272
230273 public void TransformAdjoin(int i, int x, int y, out int tx, out int ty)
@@ -235,10 +278,10 @@ namespace CedecAI
235278 {
236279 case 0: tx += 0; ty += 0; break;
237280 case 1: tx += 1; ty += 0; break;
238- case 2: tx += 1; ty += 1; break;
281+ case 2: tx += 1; ty += -1; break;
239282 case 3: tx += 0; ty += 1; break;
240283 case 4: tx += -1; ty += 0; break;
241- case 5: tx += -1; ty += -1; break;
284+ case 5: tx += -1; ty += 1; break;
242285 case 6: tx += 0; ty += -1; break;
243286 default: throw new Exception();
244287 }
@@ -266,17 +309,5 @@ namespace CedecAI
266309 default: throw new Exception();
267310 }
268311 }
269-
270- public void ToRedress(ref int x, ref int y)
271- {
272- x -= Size;
273- y -= Size;
274- }
275-
276- public void FromRedress(ref int x, ref int y)
277- {
278- x += Size;
279- y += Size;
280- }
281312 }
282313 }
--- /dev/null
+++ b/Common/TestAI.cs
@@ -0,0 +1,95 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+
7+namespace Common
8+{
9+ public class TestAI : GameAI
10+ {
11+ Random random;
12+
13+ public TestAI()
14+ {
15+ random = new Random(0);
16+ }
17+
18+ public string Prepare(int player, GameField field)
19+ {
20+ return "B_head:TestAI";
21+ }
22+
23+ public void Think(int turn, int maxTurn, int player, GameField field, Commander com)
24+ {
25+ if (!Build(player, field, com))
26+ {
27+ Move(player, field, com);
28+ }
29+ com.Finish();
30+ }
31+
32+ private void Move(int player, GameField field, Commander com)
33+ {
34+ int w = field.Width, h = field.Height;
35+ for (int x = 0; x < w; x++)
36+ {
37+ for (int y = 0; y < h; y++)
38+ {
39+ Direction dir = ToDirection(random.Next(6));
40+ int robot = random.Next(field[x, y].ActiveRobot) + 1;
41+ if (field.IsMove(player, x, y, dir, robot))
42+ {
43+ com.Move(x, y, dir, robot);
44+ }
45+ }
46+ }
47+ }
48+
49+ private bool Build(int player, GameField field, Commander com)
50+ {
51+ Terrain building = ToBuilding(random.Next(6));
52+ int w = field.Width, h = field.Height;
53+ for (int x = 0; x < w; x++)
54+ {
55+ for (int y = 0; y < h; y++)
56+ {
57+ if (field.IsBuild(player, x, y, building))
58+ {
59+ com.Build(x, y, building);
60+ return true;
61+ }
62+ }
63+ }
64+ return false;
65+ }
66+
67+ private Direction ToDirection(int i)
68+ {
69+ switch (i)
70+ {
71+ case 0: return Direction.DownerLeft;
72+ case 1: return Direction.DownerRight;
73+ case 2: return Direction.Left;
74+ case 3: return Direction.Right;
75+ case 4: return Direction.UpperLeft;
76+ case 5: return Direction.UpperRight;
77+ default: throw new Exception();
78+ }
79+ }
80+
81+ private Terrain ToBuilding(int i)
82+ {
83+ switch (i)
84+ {
85+ case 0: return Terrain.RobotMaker;
86+ case 1: return Terrain.AttackTower;
87+ case 2: return Terrain.Excavator;
88+ case 3: return Terrain.Bridge;
89+ case 4: return Terrain.House;
90+ case 5: return Terrain.Town;
91+ default: throw new Exception();
92+ }
93+ }
94+ }
95+}
--- a/Production/App.config
+++ b/Production/App.config
@@ -1,6 +1,6 @@
1-<?xml version="1.0" encoding="utf-8" ?>
1+<?xml version="1.0"?>
22 <configuration>
33 <startup>
4- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
4+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
55 </startup>
6-</configuration>
\ No newline at end of file
6+</configuration>
--- /dev/null
+++ b/Production/LinkGameField.cs
@@ -0,0 +1,150 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+using System.IO;
7+using Common;
8+
9+namespace Production
10+{
11+ class LinkGameField : GameField
12+ {
13+ public LinkGameField(int size)
14+ : base(size)
15+ {
16+
17+ }
18+
19+ public static LinkGameField ParseText(out int turn, out int maxTurn, out int playerTurn)
20+ {
21+ string[] line;
22+ if (Console.ReadLine() != "START") throw new Exception();
23+ line = Console.ReadLine().Split(' ');
24+ turn = int.Parse(line[0]);
25+ maxTurn = int.Parse(line[1]);
26+ playerTurn = int.Parse(line[2]);
27+ line = Console.ReadLine().Split(' ');
28+ LinkGameField result = new LinkGameField(int.Parse(line[0]));
29+ int count = int.Parse(line[1]);
30+ for (int i = 0; i < count; i++)
31+ {
32+ line = Console.ReadLine().Split(' ');
33+ int x = int.Parse(line[0]), y = int.Parse(line[1]), player = int.Parse(line[2]), robot = int.Parse(line[3]);
34+ result.FromRedress(ref x, ref y);
35+ Terrain ter = ParseTerrain(line[5], line[6]);
36+ if (player == playerTurn)
37+ {
38+ result.field[x, y] = new GameMass { Player = player, Ter = ter, ActiveRobot = robot };
39+ }
40+ else
41+ {
42+ result.field[x, y] = new GameMass { Player = player, Ter = ter, WaitRobot = robot };
43+ }
44+ }
45+ if (Console.ReadLine() != "EOS") throw new Exception();
46+ return result;
47+ }
48+
49+ private static Terrain ParseTerrain(string ter, string building)
50+ {
51+ switch (ter)
52+ {
53+ case "wasteland":
54+ case "settlement":
55+ return Terrain.Wasteland;
56+ case "base":
57+ switch (building)
58+ {
59+ case "initial": return Terrain.Initial;
60+ case "robotmaker": return Terrain.RobotMaker;
61+ case "tower": return Terrain.AttackTower;
62+ case "excavator": return Terrain.Excavator;
63+ case "bridge": return Terrain.Bridge;
64+ case "house": return Terrain.House;
65+ case "town": return Terrain.Town;
66+ default: throw new Exception();
67+ }
68+ case "hole":
69+ return Terrain.Hole;
70+ default:
71+ throw new Exception();
72+ }
73+ }
74+
75+ public Commander GetCommander()
76+ {
77+ return new LinkCommander(this);
78+ }
79+
80+ private void ToRedress(ref int x, ref int y)
81+ {
82+ x -= Size - 1;
83+ y -= Size - 1;
84+ }
85+
86+ private void FromRedress(ref int x, ref int y)
87+ {
88+ x += Size - 1;
89+ y += Size - 1;
90+ }
91+
92+ class LinkCommander : Commander
93+ {
94+ LinkGameField parent;
95+
96+ public LinkCommander(LinkGameField parent)
97+ {
98+ this.parent = parent;
99+ }
100+
101+ public void Move(int x, int y, Direction dir, int robot)
102+ {
103+ string temp = GenerateDirectionCode(dir);
104+ parent.ToRedress(ref x, ref y);
105+ Console.WriteLine("move {0} {1} {2} {3}", x, y, temp, robot);
106+ }
107+
108+ public void Build(int x, int y, Terrain building)
109+ {
110+ string temp = GenerateBuildingCode(building);
111+ parent.ToRedress(ref x, ref y);
112+ Console.WriteLine("build {0} {1} {2}", x, y, temp);
113+ }
114+
115+ public void Finish()
116+ {
117+ Console.WriteLine("finish");
118+ }
119+
120+ private string GenerateDirectionCode(Direction dir)
121+ {
122+ switch (dir)
123+ {
124+ case Direction.Right: return "r";
125+ case Direction.UpperRight: return "ur";
126+ case Direction.DownerRight: return "dr";
127+ case Direction.Left: return "l";
128+ case Direction.UpperLeft: return "ul";
129+ case Direction.DownerLeft: return "dl";
130+ default: throw new Exception();
131+ }
132+ }
133+
134+ private string GenerateBuildingCode(Terrain building)
135+ {
136+ switch (building)
137+ {
138+ case Terrain.Initial: return "initial";
139+ case Terrain.RobotMaker: return "robotmaker";
140+ case Terrain.AttackTower: return "tower";
141+ case Terrain.Excavator: return "excavator";
142+ case Terrain.Bridge: return "bridge";
143+ case Terrain.House: return "house";
144+ case Terrain.Town: return "town";
145+ default: throw new Exception();
146+ }
147+ }
148+ }
149+ }
150+}
--- a/Production/Production.csproj
+++ b/Production/Production.csproj
@@ -9,8 +9,9 @@
99 <AppDesignerFolder>Properties</AppDesignerFolder>
1010 <RootNamespace>Production</RootNamespace>
1111 <AssemblyName>Production</AssemblyName>
12- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1313 <FileAlignment>512</FileAlignment>
14+ <TargetFrameworkProfile />
1415 </PropertyGroup>
1516 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617 <PlatformTarget>AnyCPU</PlatformTarget>
@@ -35,18 +36,23 @@
3536 <Reference Include="System" />
3637 <Reference Include="System.Core" />
3738 <Reference Include="System.Xml.Linq" />
38- <Reference Include="System.Data.DataSetExtensions" />
3939 <Reference Include="Microsoft.CSharp" />
40- <Reference Include="System.Data" />
4140 <Reference Include="System.Xml" />
4241 </ItemGroup>
4342 <ItemGroup>
43+ <Compile Include="LinkGameField.cs" />
4444 <Compile Include="Program.cs" />
4545 <Compile Include="Properties\AssemblyInfo.cs" />
4646 </ItemGroup>
4747 <ItemGroup>
4848 <None Include="App.config" />
4949 </ItemGroup>
50+ <ItemGroup>
51+ <ProjectReference Include="..\Common\Common.csproj">
52+ <Project>{b44455bf-0f12-47e1-ab63-fe2c7d8f5180}</Project>
53+ <Name>Common</Name>
54+ </ProjectReference>
55+ </ItemGroup>
5056 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
5157 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
5258 Other similar extension points exist, see Microsoft.Common.targets.
--- a/Production/Program.cs
+++ b/Production/Program.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
33 using System.Linq;
44 using System.Text;
55 using System.Threading.Tasks;
6+using Common;
67
78 namespace Production
89 {
@@ -10,6 +11,15 @@ namespace Production
1011 {
1112 static void Main(string[] args)
1213 {
14+ int turn, maxTurn, player;
15+ GameAI ai = new TestAI();
16+ LinkGameField field = LinkGameField.ParseText(out turn, out maxTurn, out player);
17+ Console.WriteLine(ai.Prepare(player, field));
18+ for (int i = 0; i < maxTurn; i++)
19+ {
20+ field = LinkGameField.ParseText(out turn, out maxTurn, out player);
21+ ai.Think(turn, maxTurn, player, field, field.GetCommander());
22+ }
1323 }
1424 }
1525 }
--- a/Visualizer/App.config
+++ b/Visualizer/App.config
@@ -1,6 +1,6 @@
1-<?xml version="1.0" encoding="utf-8" ?>
1+<?xml version="1.0"?>
22 <configuration>
33 <startup>
4- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
4+ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
55 </startup>
6-</configuration>
\ No newline at end of file
6+</configuration>
--- a/Visualizer/App.xaml
+++ b/Visualizer/App.xaml
@@ -3,6 +3,6 @@
33 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44 StartupUri="MainWindow.xaml">
55 <Application.Resources>
6-
6+
77 </Application.Resources>
88 </Application>
--- /dev/null
+++ b/Visualizer/GameManager.cs
@@ -0,0 +1,97 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+using Common;
7+
8+namespace Visualizer
9+{
10+ class GameManager
11+ {
12+ public GenerateGameField Field;
13+ public GameAI[] AI;
14+ public string[] Name;
15+ public int[] ExtraPoint;
16+ public int Player;
17+ public int Turn;
18+ public const int MaxTurn = 200;
19+
20+ public GameManager(Random random)
21+ {
22+ Field = new GenerateGameField(7, random);
23+ AI = new GameAI[3];
24+ Name = new string[3];
25+ ExtraPoint = new int[3];
26+ Player = 0;
27+ Turn = 1;
28+ }
29+
30+ public void Prepare()
31+ {
32+ for (int i = 0; i < 3; i++)
33+ {
34+ GameField temp = Field.GetGameFieldView();
35+ Name[i] = AI[i].Prepare(i, temp);
36+ }
37+ }
38+
39+ public void NextTurn()
40+ {
41+ if (Turn > MaxTurn) return;
42+ Field.StartTurn(Player);
43+ GameField temp = Field.GetGameFieldView();
44+ ManagerCommander com = new ManagerCommander(this);
45+ AI[Player].Think(Turn, MaxTurn, Player, temp, com);
46+ Field.EndTurn(Player);
47+ if (!com.IsFinish) throw new Exception();
48+ if (++Player >= 3)
49+ {
50+ Player = 0;
51+ Turn++;
52+ }
53+ }
54+
55+ public string GetPlayerInfo(int player)
56+ {
57+ return Name[0] + "\nVP:" + Field.GetTotalVictoryPoint(player).ToString() + "+" + ExtraPoint[player];
58+ }
59+
60+ public bool IsGameOver()
61+ {
62+ return Turn > MaxTurn;
63+ }
64+
65+ class ManagerCommander : Commander
66+ {
67+ GameManager parent;
68+ public bool IsMove;
69+ public bool IsBuild;
70+ public bool IsFinish;
71+
72+ public ManagerCommander(GameManager parent)
73+ {
74+ this.parent = parent;
75+ }
76+
77+ public void Move(int x, int y, Direction dir, int robot)
78+ {
79+ if (IsFinish || IsBuild) throw new Exception();
80+ if (!parent.Field.Move(parent.Player, x, y, dir, robot)) throw new Exception();
81+ IsMove = true;
82+ }
83+
84+ public void Build(int x, int y, Terrain building)
85+ {
86+ if (IsFinish || IsBuild || IsMove) throw new Exception();
87+ if (!parent.Field.Build(parent.Player, x, y, building, ref parent.ExtraPoint[parent.Player])) throw new Exception();
88+ IsBuild = true;
89+ }
90+
91+ public void Finish()
92+ {
93+ IsFinish = true;
94+ }
95+ }
96+ }
97+}
--- a/Visualizer/GameModel.cs
+++ /dev/null
@@ -1,12 +0,0 @@
1-using System;
2-using System.Collections.Generic;
3-using System.Linq;
4-using System.Text;
5-using System.Threading.Tasks;
6-
7-namespace Visualizer
8-{
9- class GameModel
10- {
11- }
12-}
--- /dev/null
+++ b/Visualizer/GenerateGameField.cs
@@ -0,0 +1,112 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+using Common;
7+
8+namespace Visualizer
9+{
10+ class GenerateGameField : GameField
11+ {
12+ public GenerateGameField(int size, Random random)
13+ : base(size)
14+ {
15+ Generate(random);
16+ }
17+
18+ public GameField GetGameFieldView()
19+ {
20+ GameField result = new GameField(Size);
21+ CopyTo(result);
22+ return result;
23+ }
24+
25+ private void Generate(Random random)
26+ {
27+ int holeCount = RandomizeHole(random);
28+ SymmetryCopy();
29+ int tileCount = RandomizeInitial(random);
30+ if (holeCount > 15 || tileCount < (Size * (Size - 1) - holeCount) * 3 / 2)
31+ {
32+ Initialize();
33+ Generate(random);
34+ }
35+ }
36+
37+ private int RandomizeHole(Random random)
38+ {
39+ int result = 0;
40+ for (int x = 0; x < Size; x++)
41+ {
42+ for (int y = Size; y < Height; y++)
43+ {
44+ if (random.Next(5) == 0)
45+ {
46+ field[x, y].Ter = Terrain.Hole;
47+ result++;
48+ }
49+ }
50+ }
51+ return result;
52+ }
53+
54+ private void SymmetryCopy()
55+ {
56+ for (int x = 0; x < Width; x++)
57+ {
58+ for (int y = 0; y < Height; y++)
59+ {
60+ if (field[x, y].Ter == Terrain.Outside) continue;
61+ field[y, FuncA(x, y)] = field[x, y];
62+ field[FuncA(x, y), x] = field[x, y];
63+ }
64+ }
65+ }
66+
67+ private int RandomizeInitial(Random random)
68+ {
69+ int x = random.Next(0, Size), y = random.Next(Size, Height);
70+ int[] player = { 0, 1, 2 };
71+ Shuffle(player, random);
72+ field[x, y].Ter = Terrain.Initial;
73+ field[x, y].Player = player[0];
74+ field[y, FuncA(x, y)].Ter = Terrain.Initial;
75+ field[y, FuncA(x, y)].Player = player[1];
76+ field[FuncA(x, y), x].Ter = Terrain.Initial;
77+ field[FuncA(x, y), x].Player = player[2];
78+ return JoiningCount(new bool[Width, Height], x, y);
79+ }
80+
81+ private int FuncA(int x, int y)
82+ {
83+ return (Size - 1) * 3 - x - y;
84+ }
85+
86+ private int JoiningCount(bool[,] settled, int x, int y)
87+ {
88+ if (IsInRange(x, y)) return 0;
89+ if (settled[x, y]) return 0;
90+ if (field[x, y].Ter == Terrain.Outside || field[x, y].Ter == Terrain.Hole) return 0;
91+ int result = 1, tx, ty;
92+ settled[x, y] = true;
93+ for (int i = 1; i < 7; i++)
94+ {
95+ TransformAdjoin(i, x, y, out tx, out ty);
96+ result += JoiningCount(settled, tx, ty);
97+ }
98+ return result;
99+ }
100+
101+ private void Shuffle<T>(T[] array, Random rand)
102+ {
103+ for (int i = 0; i < array.Length; i++)
104+ {
105+ int a = rand.Next(i, array.Length);
106+ T temp = array[i];
107+ array[i] = array[a];
108+ array[a] = temp;
109+ }
110+ }
111+ }
112+}
--- a/Visualizer/MainWindow.xaml
+++ b/Visualizer/MainWindow.xaml
@@ -1,8 +1,24 @@
11 <Window x:Class="Visualizer.MainWindow"
22 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4- Title="MainWindow" Height="350" Width="525">
4+ Title="MainWindow" Height="600" Width="1000">
55 <Grid>
6-
6+ <Grid.ColumnDefinitions>
7+ <ColumnDefinition/>
8+ <ColumnDefinition Width="150"/>
9+ </Grid.ColumnDefinitions>
10+ <Canvas x:Name="FieldInfo" Margin="0" ClipToBounds="True"/>
11+ <StackPanel Grid.Column="1" Margin="10">
12+ <Button x:Name="NextButton" Content="Next" Click="NextTurnHandler"/>
13+ <CheckBox x:Name="AutoNext" Content="Auto" HorizontalAlignment="Center" Checked="NextTurnHandler"/>
14+ <TextBlock x:Name="Player1Info" Text="Player1" Foreground="Red"/>
15+ <TextBlock x:Name="Player2Info" Text="Player2" Foreground="Blue"/>
16+ <TextBlock x:Name="Player3Info" Text="Player3" Foreground="Green"/>
17+ <Label Content="Show infomartion"/>
18+ <CheckBox x:Name="ShowRobot" Content="Robot" IsChecked="True" Click="ShowChangeHandler"/>
19+ <CheckBox x:Name="ShowResource" Content="Resource" Click="ShowChangeHandler"/>
20+ <CheckBox x:Name="ShowTowerDamage" Content="Tower damage" Click="ShowChangeHandler"/>
21+ </StackPanel>
22+ <GridSplitter Width="1" IsEnabled="False" Background="Black" Margin="0"/>
723 </Grid>
824 </Window>
--- a/Visualizer/MainWindow.xaml.cs
+++ b/Visualizer/MainWindow.xaml.cs
@@ -12,6 +12,7 @@ using System.Windows.Media;
1212 using System.Windows.Media.Imaging;
1313 using System.Windows.Navigation;
1414 using System.Windows.Shapes;
15+using Common;
1516
1617 namespace Visualizer
1718 {
@@ -20,9 +21,97 @@ namespace Visualizer
2021 /// </summary>
2122 public partial class MainWindow : Window
2223 {
24+ GameManager manager;
25+ MassInformation[,] mass;
26+
2327 public MainWindow()
2428 {
2529 InitializeComponent();
30+ manager = new GameManager(new Random());
31+ manager.AI[0] = new TestAI();
32+ manager.AI[1] = new TestAI();
33+ manager.AI[2] = new TestAI();
34+ manager.Prepare();
35+ int w = manager.Field.Width, h = manager.Field.Height;
36+ mass = new MassInformation[w, h];
37+ for (int x = 0; x < w; x++)
38+ {
39+ for (int y = 0; y < h; y++)
40+ {
41+ MassInformation temp = new MassInformation();
42+ mass[x, y] = temp;
43+ FieldInfo.Children.Add(temp);
44+ Canvas.SetLeft(temp, (x + y / 2.0) * temp.Width);
45+ Canvas.SetTop(temp, y * temp.Height);
46+ }
47+ }
48+ UpdateInfo();
49+ }
50+
51+ private void UpdateInfo()
52+ {
53+ Player1Info.Text = manager.GetPlayerInfo(0);
54+ Player2Info.Text = manager.GetPlayerInfo(1);
55+ Player3Info.Text = manager.GetPlayerInfo(2);
56+ GameField field = manager.Field;
57+ int w = field.Width, h = field.Height;
58+ for (int x = 0; x < w; x++)
59+ {
60+ for (int y = 0; y < h; y++)
61+ {
62+ mass[x, y].UpdateTerrain(field[x, y].Player, field[x, y].Ter);
63+ mass[x, y].UpdateTextInfo(BuildMassInfo(x, y));
64+ }
65+ }
66+ }
67+
68+ private string BuildMassInfo(int x, int y)
69+ {
70+ StringBuilder result = new StringBuilder();
71+ GameField field = manager.Field;
72+ if (ShowRobot.IsChecked == true)
73+ {
74+ result.AppendLine("Rb:" + field[x, y].WaitRobot.ToString());
75+ }
76+ if (ShowResource.IsChecked == true)
77+ {
78+ result.AppendLine("Rs:" + field.GetPrepareResource(x, y).ToString() + "(" + field.GetYieldResource(x, y).ToString() + ")");
79+ }
80+ if (ShowTowerDamage.IsChecked == true)
81+ {
82+ result.AppendLine("Td:" + field.GetEstimateTowerDamage(field[x, y].Player, x, y) + "(" + field.GetTowerDamage(manager.Player, x, y).ToString() + ")");
83+ }
84+ return result.ToString();
85+ }
86+
87+ private void RunTurn()
88+ {
89+ manager.NextTurn();
90+ Dispatcher.BeginInvoke((Action)CompleteTurn, System.Windows.Threading.DispatcherPriority.Background);
91+ }
92+
93+ private void CompleteTurn()
94+ {
95+ UpdateInfo();
96+ if (AutoNext.IsChecked == true && !manager.IsGameOver())
97+ {
98+ Task.Run((Action)RunTurn);
99+ return;
100+ }
101+ NextButton.IsEnabled = true;
102+ AutoNext.IsChecked = false;
103+ }
104+
105+ private void NextTurnHandler(object sender, RoutedEventArgs e)
106+ {
107+ if (!NextButton.IsEnabled) return;
108+ NextButton.IsEnabled = false;
109+ Task.Run((Action)RunTurn);
110+ }
111+
112+ private void ShowChangeHandler(object sender, RoutedEventArgs e)
113+ {
114+ UpdateInfo();
26115 }
27116 }
28117 }
--- /dev/null
+++ b/Visualizer/MassInformation.xaml
@@ -0,0 +1,12 @@
1+<UserControl x:Class="Visualizer.MassInformation"
2+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+ mc:Ignorable="d"
7+ Width="40" Height="34" BorderBrush="Black" BorderThickness="1">
8+ <Canvas>
9+ <Image x:Name="TerrainImage" Height="32" Width="38"/>
10+ <TextBlock x:Name="TextInfo" FontFamily="Meiryo UI" FontSize="8" Height="32" Width="38"/>
11+ </Canvas>
12+</UserControl>
--- /dev/null
+++ b/Visualizer/MassInformation.xaml.cs
@@ -0,0 +1,122 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Threading.Tasks;
6+using System.Windows;
7+using System.Windows.Controls;
8+using System.Windows.Data;
9+using System.Windows.Documents;
10+using System.Windows.Input;
11+using System.Windows.Media;
12+using System.Windows.Media.Imaging;
13+using System.Windows.Navigation;
14+using System.Windows.Shapes;
15+using Common;
16+
17+namespace Visualizer
18+{
19+ /// <summary>
20+ /// MassInformation.xaml の相互作用ロジック
21+ /// </summary>
22+ public partial class MassInformation : UserControl
23+ {
24+ static readonly BitmapImage[] hole;
25+ static readonly BitmapImage[] attack;
26+ static readonly BitmapImage[] bridge;
27+ static readonly BitmapImage[] excavator;
28+ static readonly BitmapImage[] house;
29+ static readonly BitmapImage[] initial;
30+ static readonly BitmapImage[] robotmaker;
31+ static readonly BitmapImage[] town;
32+
33+ static MassInformation()
34+ {
35+ hole = CreateBitmapImage("hole18.png");
36+ attack = CreateBitmapImage("attack0.png", "attack1.png", "attack2.png");
37+ bridge = CreateBitmapImage("bridge0.png", "bridge1.png", "bridge2.png");
38+ excavator = CreateBitmapImage("excavator0.png", "excavator1.png", "excavator2.png");
39+ house = CreateBitmapImage("house0.png", "house1.png", "house2.png");
40+ initial = CreateBitmapImage("largerobotmaker0.png", "largerobotmaker1.png", "largerobotmaker2.png");
41+ robotmaker = CreateBitmapImage("robotmaker0.png", "robotmaker1.png", "robotmaker2.png");
42+ town = CreateBitmapImage("town0.png", "town1.png", "town2.png");
43+ }
44+
45+ public MassInformation()
46+ {
47+ InitializeComponent();
48+ }
49+
50+ private static BitmapImage[] CreateBitmapImage(params string[] strs)
51+ {
52+ BitmapImage[] result = new BitmapImage[strs.Length];
53+ for (int i = 0; i < strs.Length; i++)
54+ {
55+ result[i] = new BitmapImage(new Uri("/Resources/" + strs[i], UriKind.Relative));
56+ }
57+ return result;
58+ }
59+
60+ public void UpdateTerrain(int player, Terrain ter)
61+ {
62+ switch (player)
63+ {
64+ case 0:
65+ Background = new SolidColorBrush(Color.FromRgb(255, 128, 128));
66+ break;
67+ case 1:
68+ Background = new SolidColorBrush(Color.FromRgb(128, 128, 255));
69+ break;
70+ case 2:
71+ Background = new SolidColorBrush(Color.FromRgb(128, 255, 128));
72+ break;
73+ default:
74+ Background = new SolidColorBrush(Color.FromRgb(128, 128, 128));
75+ break;
76+ }
77+ if (ter == Terrain.Outside)
78+ {
79+ Opacity = 0.3;
80+ }
81+ else
82+ {
83+ Opacity = 1;
84+ }
85+ switch (ter)
86+ {
87+ case Terrain.AttackTower:
88+ TerrainImage.Source = attack[player];
89+ break;
90+ case Terrain.Bridge:
91+ TerrainImage.Source = bridge[player];
92+ break;
93+ case Terrain.Excavator:
94+ TerrainImage.Source = excavator[player];
95+ break;
96+ case Terrain.Hole:
97+ TerrainImage.Source = hole[0];
98+ break;
99+ case Terrain.House:
100+ TerrainImage.Source = house[player];
101+ break;
102+ case Terrain.Initial:
103+ TerrainImage.Source = initial[player];
104+ break;
105+ case Terrain.RobotMaker:
106+ TerrainImage.Source = robotmaker[player];
107+ break;
108+ case Terrain.Town:
109+ TerrainImage.Source = town[player];
110+ break;
111+ default:
112+ TerrainImage.Source = null;
113+ break;
114+ }
115+ }
116+
117+ public void UpdateTextInfo(string info)
118+ {
119+ TextInfo.Text = info;
120+ }
121+ }
122+}
--- a/Visualizer/Properties/Resources.Designer.cs
+++ b/Visualizer/Properties/Resources.Designer.cs
@@ -4,66 +4,58 @@
44 // ランタイム バージョン:4.0.30319.18052
55 //
66 // このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7-// コードが再生成されるときに損失したりします
7+// コードが再生成されるときに損失したりします。
88 // </auto-generated>
99 //------------------------------------------------------------------------------
1010
11-namespace Visualizer.Properties
12-{
13-
14-
11+namespace Visualizer.Properties {
12+ using System;
13+
14+
1515 /// <summary>
1616 /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。
1717 /// </summary>
18- // このクラスは StronglyTypedResourceBuilder クラスによって ResGen
18+ // このクラスは StronglyTypedResourceBuilder クラスが ResGen
1919 // または Visual Studio のようなツールを使用して自動生成されました。
2020 // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に
2121 // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。
2222 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
2323 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
2424 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25- internal class Resources
26- {
27-
25+ internal class Resources {
26+
2827 private static global::System.Resources.ResourceManager resourceMan;
29-
28+
3029 private static global::System.Globalization.CultureInfo resourceCulture;
31-
30+
3231 [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33- internal Resources()
34- {
32+ internal Resources() {
3533 }
36-
34+
3735 /// <summary>
38- /// このクラスに使用される、キャッシュされた ResourceManager のインスタンスを返します。
36+ /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。
3937 /// </summary>
4038 [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41- internal static global::System.Resources.ResourceManager ResourceManager
42- {
43- get
44- {
45- if ((resourceMan == null))
46- {
39+ internal static global::System.Resources.ResourceManager ResourceManager {
40+ get {
41+ if (object.ReferenceEquals(resourceMan, null)) {
4742 global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Visualizer.Properties.Resources", typeof(Resources).Assembly);
4843 resourceMan = temp;
4944 }
5045 return resourceMan;
5146 }
5247 }
53-
48+
5449 /// <summary>
5550 /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、
5651 /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。
5752 /// </summary>
5853 [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59- internal static global::System.Globalization.CultureInfo Culture
60- {
61- get
62- {
54+ internal static global::System.Globalization.CultureInfo Culture {
55+ get {
6356 return resourceCulture;
6457 }
65- set
66- {
58+ set {
6759 resourceCulture = value;
6860 }
6961 }
--- a/Visualizer/Properties/Resources.resx
+++ b/Visualizer/Properties/Resources.resx
@@ -46,7 +46,7 @@
4646
4747 mimetype: application/x-microsoft.net.object.binary.base64
4848 value : The object must be serialized with
49- : System.Serialization.Formatters.Binary.BinaryFormatter
49+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050 : and then encoded with base64 encoding.
5151
5252 mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
6060 : and then encoded with base64 encoding.
6161 -->
6262 <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
6364 <xsd:element name="root" msdata:IsDataSet="true">
6465 <xsd:complexType>
6566 <xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
6869 <xsd:sequence>
6970 <xsd:element name="value" type="xsd:string" minOccurs="0" />
7071 </xsd:sequence>
71- <xsd:attribute name="name" type="xsd:string" />
72+ <xsd:attribute name="name" use="required" type="xsd:string" />
7273 <xsd:attribute name="type" type="xsd:string" />
7374 <xsd:attribute name="mimetype" type="xsd:string" />
75+ <xsd:attribute ref="xml:space" />
7476 </xsd:complexType>
7577 </xsd:element>
7678 <xsd:element name="assembly">
@@ -85,9 +87,10 @@
8587 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
8688 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
8789 </xsd:sequence>
88- <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
90+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
8991 <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
9092 <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93+ <xsd:attribute ref="xml:space" />
9194 </xsd:complexType>
9295 </xsd:element>
9396 <xsd:element name="resheader">
@@ -109,9 +112,9 @@
109112 <value>2.0</value>
110113 </resheader>
111114 <resheader name="reader">
112- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113116 </resheader>
114117 <resheader name="writer">
115- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116119 </resheader>
117120 </root>
\ No newline at end of file
--- a/Visualizer/Properties/Settings.Designer.cs
+++ b/Visualizer/Properties/Settings.Designer.cs
@@ -1,28 +1,24 @@
11 //------------------------------------------------------------------------------
22 // <auto-generated>
3-// This code was generated by a tool.
4-// Runtime Version:4.0.30319.18052
3+// このコードはツールによって生成されました。
4+// ランタイム バージョン:4.0.30319.18052
55 //
6-// Changes to this file may cause incorrect behavior and will be lost if
7-// the code is regenerated.
6+// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
7+// コードが再生成されるときに損失したりします。
88 // </auto-generated>
99 //------------------------------------------------------------------------------
1010
11-namespace Visualizer.Properties
12-{
13-
14-
11+namespace Visualizer.Properties {
12+
13+
1514 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
1615 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18- {
19-
16+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17+
2018 private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21-
22- public static Settings Default
23- {
24- get
25- {
19+
20+ public static Settings Default {
21+ get {
2622 return defaultInstance;
2723 }
2824 }
Binary files /dev/null and b/Visualizer/Resources/attack0.png differ
Binary files /dev/null and b/Visualizer/Resources/attack1.png differ
Binary files /dev/null and b/Visualizer/Resources/attack2.png differ
Binary files /dev/null and b/Visualizer/Resources/bridge0.png differ
Binary files /dev/null and b/Visualizer/Resources/bridge1.png differ
Binary files /dev/null and b/Visualizer/Resources/bridge2.png differ
Binary files /dev/null and b/Visualizer/Resources/excavator0.png differ
Binary files /dev/null and b/Visualizer/Resources/excavator1.png differ
Binary files /dev/null and b/Visualizer/Resources/excavator2.png differ
Binary files /dev/null and b/Visualizer/Resources/hole18.png differ
Binary files /dev/null and b/Visualizer/Resources/house0.png differ
Binary files /dev/null and b/Visualizer/Resources/house1.png differ
Binary files /dev/null and b/Visualizer/Resources/house2.png differ
Binary files /dev/null and b/Visualizer/Resources/largerobotmaker0.png differ
Binary files /dev/null and b/Visualizer/Resources/largerobotmaker1.png differ
Binary files /dev/null and b/Visualizer/Resources/largerobotmaker2.png differ
Binary files /dev/null and b/Visualizer/Resources/robotmaker0.png differ
Binary files /dev/null and b/Visualizer/Resources/robotmaker1.png differ
Binary files /dev/null and b/Visualizer/Resources/robotmaker2.png differ
Binary files /dev/null and b/Visualizer/Resources/town0.png differ
Binary files /dev/null and b/Visualizer/Resources/town1.png differ
Binary files /dev/null and b/Visualizer/Resources/town2.png differ
--- a/Visualizer/Visualizer.csproj
+++ b/Visualizer/Visualizer.csproj
@@ -13,6 +13,7 @@
1313 <FileAlignment>512</FileAlignment>
1414 <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1515 <WarningLevel>4</WarningLevel>
16+ <TargetFrameworkProfile />
1617 </PropertyGroup>
1718 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1819 <PlatformTarget>AnyCPU</PlatformTarget>
@@ -23,6 +24,7 @@
2324 <DefineConstants>DEBUG;TRACE</DefineConstants>
2425 <ErrorReport>prompt</ErrorReport>
2526 <WarningLevel>4</WarningLevel>
27+ <Prefer32Bit>false</Prefer32Bit>
2628 </PropertyGroup>
2729 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2830 <PlatformTarget>AnyCPU</PlatformTarget>
@@ -32,10 +34,12 @@
3234 <DefineConstants>TRACE</DefineConstants>
3335 <ErrorReport>prompt</ErrorReport>
3436 <WarningLevel>4</WarningLevel>
37+ <Prefer32Bit>false</Prefer32Bit>
3538 </PropertyGroup>
3639 <ItemGroup>
3740 <Reference Include="System" />
3841 <Reference Include="System.Data" />
42+ <Reference Include="System.Drawing" />
3943 <Reference Include="System.Xml" />
4044 <Reference Include="Microsoft.CSharp" />
4145 <Reference Include="System.Core" />
@@ -61,13 +65,21 @@
6165 <DependentUpon>App.xaml</DependentUpon>
6266 <SubType>Code</SubType>
6367 </Compile>
64- <Compile Include="GameModel.cs" />
68+ <Compile Include="GameManager.cs" />
69+ <Compile Include="GenerateGameField.cs" />
6570 <Compile Include="MainWindow.xaml.cs">
6671 <DependentUpon>MainWindow.xaml</DependentUpon>
6772 <SubType>Code</SubType>
6873 </Compile>
74+ <Page Include="MassInformation.xaml">
75+ <SubType>Designer</SubType>
76+ <Generator>MSBuild:Compile</Generator>
77+ </Page>
6978 </ItemGroup>
7079 <ItemGroup>
80+ <Compile Include="MassInformation.xaml.cs">
81+ <DependentUpon>MassInformation.xaml</DependentUpon>
82+ </Compile>
7183 <Compile Include="Properties\AssemblyInfo.cs">
7284 <SubType>Code</SubType>
7385 </Compile>
@@ -81,10 +93,10 @@
8193 <DependentUpon>Settings.settings</DependentUpon>
8294 <DesignTimeSharedInput>True</DesignTimeSharedInput>
8395 </Compile>
84- <EmbeddedResource Include="Properties\Resources.resx">
96+ <None Include="Properties\Resources.resx">
8597 <Generator>ResXFileCodeGenerator</Generator>
8698 <LastGenOutput>Resources.Designer.cs</LastGenOutput>
87- </EmbeddedResource>
99+ </None>
88100 <None Include="Properties\Settings.settings">
89101 <Generator>SettingsSingleFileGenerator</Generator>
90102 <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -94,6 +106,122 @@
94106 <ItemGroup>
95107 <None Include="App.config" />
96108 </ItemGroup>
109+ <ItemGroup>
110+ <ProjectReference Include="..\Common\Common.csproj">
111+ <Project>{b44455bf-0f12-47e1-ab63-fe2c7d8f5180}</Project>
112+ <Name>Common</Name>
113+ </ProjectReference>
114+ </ItemGroup>
115+ <ItemGroup>
116+ <Content Include="Resources\attack0.png">
117+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
118+ </Content>
119+ </ItemGroup>
120+ <ItemGroup>
121+ <Content Include="Resources\attack1.png">
122+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
123+ </Content>
124+ </ItemGroup>
125+ <ItemGroup>
126+ <Content Include="Resources\attack2.png">
127+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
128+ </Content>
129+ </ItemGroup>
130+ <ItemGroup>
131+ <Content Include="Resources\bridge0.png">
132+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
133+ </Content>
134+ </ItemGroup>
135+ <ItemGroup>
136+ <Content Include="Resources\bridge1.png">
137+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
138+ </Content>
139+ </ItemGroup>
140+ <ItemGroup>
141+ <Content Include="Resources\bridge2.png">
142+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
143+ </Content>
144+ </ItemGroup>
145+ <ItemGroup>
146+ <Content Include="Resources\excavator0.png">
147+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
148+ </Content>
149+ </ItemGroup>
150+ <ItemGroup>
151+ <Content Include="Resources\excavator1.png">
152+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
153+ </Content>
154+ </ItemGroup>
155+ <ItemGroup>
156+ <Content Include="Resources\excavator2.png">
157+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
158+ </Content>
159+ </ItemGroup>
160+ <ItemGroup>
161+ <Content Include="Resources\hole18.png">
162+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
163+ </Content>
164+ </ItemGroup>
165+ <ItemGroup>
166+ <Content Include="Resources\house0.png">
167+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
168+ </Content>
169+ </ItemGroup>
170+ <ItemGroup>
171+ <Content Include="Resources\house1.png">
172+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
173+ </Content>
174+ </ItemGroup>
175+ <ItemGroup>
176+ <Content Include="Resources\house2.png">
177+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
178+ </Content>
179+ </ItemGroup>
180+ <ItemGroup>
181+ <Content Include="Resources\largerobotmaker0.png">
182+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
183+ </Content>
184+ </ItemGroup>
185+ <ItemGroup>
186+ <Content Include="Resources\largerobotmaker1.png">
187+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
188+ </Content>
189+ </ItemGroup>
190+ <ItemGroup>
191+ <Content Include="Resources\largerobotmaker2.png">
192+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
193+ </Content>
194+ </ItemGroup>
195+ <ItemGroup>
196+ <Content Include="Resources\robotmaker0.png">
197+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
198+ </Content>
199+ </ItemGroup>
200+ <ItemGroup>
201+ <Content Include="Resources\robotmaker1.png">
202+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
203+ </Content>
204+ </ItemGroup>
205+ <ItemGroup>
206+ <Content Include="Resources\robotmaker2.png">
207+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208+ </Content>
209+ </ItemGroup>
210+ <ItemGroup>
211+ <Content Include="Resources\town0.png">
212+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
213+ </Content>
214+ </ItemGroup>
215+ <ItemGroup>
216+ <Content Include="Resources\town1.png">
217+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
218+ </Content>
219+ </ItemGroup>
220+ <ItemGroup>
221+ <Content Include="Resources\town2.png">
222+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
223+ </Content>
224+ </ItemGroup>
97225 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
98226 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
99227 Other similar extension points exist, see Microsoft.Common.targets.