質問編集履歴
3
コードを見やすくしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,146 +28,418 @@
|
|
28
28
|
|
29
29
|
*完全に独学故、自分のレベルもよく分かってないので下記に自分が0から書いたコードを載せておきます。
|
30
30
|
|
31
|
-
```ここに言語を入力
|
32
|
-
|
33
|
-
オセロプログラムで使った諸メソッドの一部です。他にも2048というゲームも作りました。
|
34
|
-
|
35
31
|
```
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
33
|
+
public class GameSystem
|
34
|
+
|
35
|
+
{
|
36
|
+
|
37
|
+
public int Matrix { get; set; }
|
38
|
+
|
39
|
+
public int Player { get; set; }
|
40
|
+
|
41
|
+
public int PlayerChanger { get; set; }
|
42
|
+
|
43
|
+
public string[] Color { get; set; }
|
44
|
+
|
45
|
+
public string[,] Place { get; set; }
|
46
|
+
|
47
|
+
public string Blank { get; private set; }
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
public GameSystem()
|
52
|
+
|
53
|
+
{
|
54
|
+
|
55
|
+
Matrix = 3;
|
56
|
+
|
57
|
+
Player = 0;
|
58
|
+
|
59
|
+
PlayerChanger = 1;
|
60
|
+
|
61
|
+
Color = new string[] { "⚫️" , "⚪️" };
|
62
|
+
|
63
|
+
Blank = "⬜︎";
|
64
|
+
|
65
|
+
Place = new string[Matrix, Matrix];
|
66
|
+
|
67
|
+
for (int i = 0; i < Place.GetLength(0); i++)
|
68
|
+
|
69
|
+
{
|
70
|
+
|
71
|
+
for (int j = 0; j < Place.GetLength(1); j++)
|
72
|
+
|
73
|
+
{
|
74
|
+
|
75
|
+
Place[i, j] = Blank;
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
Place[(int)(Matrix / 2) - 1, (int)(Matrix / 2) - 1] = Color[0];
|
82
|
+
|
83
|
+
Place[(int)(Matrix / 2), (int)(Matrix / 2)] = Color[0];
|
84
|
+
|
85
|
+
Place[(int)(Matrix / 2) - 1, (int)(Matrix / 2)] = Color[1];
|
86
|
+
|
87
|
+
Place[(int)(Matrix / 2), (int)(Matrix / 2) - 1] = Color[1];
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
public void Put(int x, int y)
|
94
|
+
|
95
|
+
{
|
96
|
+
|
97
|
+
Place[y, x] = Color[Player];
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
public void Reverse(int x, int y)
|
104
|
+
|
105
|
+
{
|
106
|
+
|
107
|
+
//右
|
108
|
+
|
109
|
+
for (int i = 1; x + i < Place.GetLength(1); i++)
|
110
|
+
|
111
|
+
{
|
112
|
+
|
113
|
+
if (Place[y, x + i] == Blank)
|
114
|
+
|
115
|
+
{
|
116
|
+
|
117
|
+
break;
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
else if (Place[y, x + i] == Color[Player])
|
122
|
+
|
123
|
+
{
|
124
|
+
|
125
|
+
for (int j = 1; j < i; j++)
|
126
|
+
|
127
|
+
{
|
128
|
+
|
129
|
+
Place[y, x + j] = Color[Player];
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
break;
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
//左
|
140
|
+
|
141
|
+
for (int i = 1; x - i >= 0; i++)
|
142
|
+
|
143
|
+
{
|
144
|
+
|
145
|
+
if (Place[y, x - i] == Blank)
|
146
|
+
|
147
|
+
{
|
148
|
+
|
149
|
+
break;
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
else if (Place[y, x - i] == Color[Player])
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
for (int j = 1; j < i; j++)
|
158
|
+
|
159
|
+
{
|
160
|
+
|
161
|
+
Place[y, x - j] = Color[Player];
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
break;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
//上
|
172
|
+
|
173
|
+
for (int i = 1; y + i < Place.GetLength(0); i++)
|
174
|
+
|
175
|
+
{
|
176
|
+
|
177
|
+
if (Place[y + i, x] == Blank)
|
178
|
+
|
179
|
+
{
|
180
|
+
|
181
|
+
break;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
else if (Place[y + i, x] == Color[Player])
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
for (int j = 1; j < i; j++)
|
190
|
+
|
191
|
+
{
|
192
|
+
|
193
|
+
Place[y + j, x] = Color[Player];
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
break;
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
//下
|
204
|
+
|
205
|
+
for (int i = 1; y - i >= 0; i++)
|
206
|
+
|
207
|
+
{
|
208
|
+
|
209
|
+
if (Place[y - i, x] == Blank)
|
210
|
+
|
211
|
+
{
|
212
|
+
|
213
|
+
break;
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
else if (Place[y - i, x] == Color[Player])
|
218
|
+
|
219
|
+
{
|
220
|
+
|
221
|
+
for (int j = 1; j < i; j++)
|
222
|
+
|
223
|
+
{
|
224
|
+
|
225
|
+
Place[y - j, x] = Color[Player];
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
break;
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
//右斜め上
|
236
|
+
|
237
|
+
for (int k = 1; y + k < Place.GetLength(0) && x + k < Place.GetLength(1); k++)
|
238
|
+
|
239
|
+
{
|
240
|
+
|
241
|
+
if (Place[y + k, x + k] == Blank)
|
242
|
+
|
243
|
+
{
|
244
|
+
|
245
|
+
break;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
else if (Place[y + k, x + k] == Color[Player])
|
250
|
+
|
251
|
+
{
|
252
|
+
|
253
|
+
for (int r = 1; r < k; r++)
|
254
|
+
|
255
|
+
{
|
256
|
+
|
257
|
+
Place[y + r, x + r] = Color[Player];
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
break;
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
//左斜め下
|
272
|
+
|
273
|
+
for (int k = 1; y - k >= 0 && x - k >= 0; k++)
|
274
|
+
|
275
|
+
{
|
276
|
+
|
277
|
+
if (Place[y - k, x - k] == Blank)
|
278
|
+
|
279
|
+
{
|
280
|
+
|
281
|
+
break;
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
else if (Place[y - k, x - k] == Color[Player])
|
286
|
+
|
287
|
+
{
|
288
|
+
|
289
|
+
for (int r = 1; r < k; r++)
|
290
|
+
|
291
|
+
{
|
292
|
+
|
293
|
+
Place[y - r, x - r] = Color[Player];
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
break;
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
//左斜め上
|
304
|
+
|
305
|
+
for (int k = 1; y + k < Place.GetLength(0) && x - k >= 0; k++)
|
306
|
+
|
307
|
+
{
|
308
|
+
|
309
|
+
if (Place[y + k, x - k] == Blank)
|
310
|
+
|
311
|
+
{
|
312
|
+
|
313
|
+
break;
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
else if (Place[y + k, x - k] == Color[Player])
|
318
|
+
|
319
|
+
{
|
320
|
+
|
321
|
+
for (int r = 1; r < k; r++)
|
322
|
+
|
323
|
+
{
|
324
|
+
|
325
|
+
Place[y + r, x - r] = Color[Player];
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
break;
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
//右斜め下
|
336
|
+
|
337
|
+
for (int k = 1; y - k >= 0 && x + k < Place.GetLength(1); k++)
|
338
|
+
|
339
|
+
{
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
if (Place[y - k, x + k] == Blank)
|
344
|
+
|
345
|
+
{
|
346
|
+
|
347
|
+
break;
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
else if (Place[y - k, x + k] == Color[Player])
|
352
|
+
|
353
|
+
{
|
354
|
+
|
355
|
+
for (int r = 1; r < k; r++)
|
356
|
+
|
357
|
+
{
|
358
|
+
|
359
|
+
Place[y - r, x + r] = Color[Player];
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
break;
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
}
|
368
|
+
|
369
|
+
}
|
370
|
+
|
371
|
+
public void OutPutPieces()
|
372
|
+
|
373
|
+
{
|
374
|
+
|
375
|
+
for (int i = 0; i < Place.GetLength(0); i++)
|
376
|
+
|
377
|
+
{
|
378
|
+
|
379
|
+
for (int j = 0; j < Place.GetLength(1); j++)
|
380
|
+
|
381
|
+
{
|
382
|
+
|
383
|
+
Console.Write(Place[i, j]);
|
384
|
+
|
385
|
+
}
|
386
|
+
|
387
|
+
Console.WriteLine();
|
388
|
+
|
389
|
+
}
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
public bool Pass(GameSystem gameSystem)
|
396
|
+
|
397
|
+
{
|
398
|
+
|
399
|
+
var passBool = true;
|
400
|
+
|
401
|
+
for (int i = 0; passBool == true && i < Place.GetLength(0); i++)
|
402
|
+
|
403
|
+
{
|
404
|
+
|
405
|
+
for (int j = 0; passBool == true && j < Place.GetLength(1); j++)
|
406
|
+
|
407
|
+
{
|
408
|
+
|
409
|
+
if (Place[i, j] == Blank && gameSystem.ReverseCounter(i, j) != 0)
|
410
|
+
|
411
|
+
{
|
412
|
+
|
413
|
+
passBool = false;
|
414
|
+
|
415
|
+
}
|
416
|
+
|
417
|
+
}
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
return passBool;
|
422
|
+
|
423
|
+
}
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
public void SwapPlayer()
|
428
|
+
|
429
|
+
{
|
430
|
+
|
431
|
+
int swap;
|
432
|
+
|
433
|
+
swap = Player;
|
434
|
+
|
435
|
+
Player = PlayerChanger;
|
436
|
+
|
437
|
+
PlayerChanger = swap;
|
438
|
+
|
439
|
+
}
|
440
|
+
|
441
|
+
}
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
```
|
2
コードを見やすくしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,618 +32,142 @@
|
|
32
32
|
|
33
33
|
オセロプログラムで使った諸メソッドの一部です。他にも2048というゲームも作りました。
|
34
34
|
|
35
|
-
```
|
35
|
+
```
|
36
36
|
|
37
|
+
--- public class GameSystem
|
37
38
|
|
39
|
+
--- {
|
38
40
|
|
39
|
-
na
|
41
|
+
--- public int Matrix { get; set; }
|
40
42
|
|
41
|
-
{
|
43
|
+
--- public int Player { get; set; }
|
42
44
|
|
43
|
-
public
|
45
|
+
--- public string[] Color { get; set; }
|
44
46
|
|
45
|
-
{
|
47
|
+
--- public string[,] Place { get; set; }
|
46
48
|
|
47
|
-
public in
|
49
|
+
--- public string Blank { get; set; }
|
48
50
|
|
49
|
-
public int
|
51
|
+
--- public GameSystem(int player)
|
50
52
|
|
51
|
-
|
53
|
+
--- {
|
52
54
|
|
53
|
-
|
55
|
+
--- Matrix = 4;
|
54
56
|
|
55
|
-
|
57
|
+
--- Player = player;
|
56
58
|
|
57
|
-
|
59
|
+
--- Color = new string[] { "⚫️" , "⚪️" };
|
58
60
|
|
59
|
-
|
61
|
+
--- Blank = "⬜︎";
|
60
62
|
|
61
|
-
Matrix
|
63
|
+
--- Place = new string[Matrix, Matrix];
|
62
64
|
|
63
|
-
|
65
|
+
--- for (int i = 0; i < Place.GetLength(0); i++)
|
64
66
|
|
65
|
-
|
67
|
+
--- {
|
66
68
|
|
67
|
-
|
69
|
+
--- for (int j = 0; j < Place.GetLength(1); j++)
|
68
70
|
|
69
|
-
|
71
|
+
--- {
|
70
72
|
|
71
|
-
|
73
|
+
--- Place[i, j] = Blank;
|
72
74
|
|
73
|
-
|
75
|
+
--- }
|
74
76
|
|
75
|
-
|
77
|
+
--- }
|
76
78
|
|
77
|
-
|
79
|
+
--- Place[(Matrix / 2) - 1, (Matrix / 2) - 1] = Color[0];
|
78
80
|
|
79
|
-
|
81
|
+
--- Place[Matrix / 2, Matrix / 2] = Color[0];
|
80
82
|
|
81
|
-
|
83
|
+
--- Place[(Matrix / 2) - 1, Matrix / 2] = Color[1];
|
82
84
|
|
83
|
-
|
85
|
+
--- Place[Matrix / 2, (Matrix / 2) - 1] = Color[1];
|
84
86
|
|
85
|
-
|
87
|
+
--- }
|
86
88
|
|
87
|
-
|
89
|
+
---
|
88
90
|
|
89
|
-
|
91
|
+
--- public void Put(int x, int y, int player)
|
90
92
|
|
91
|
-
|
93
|
+
--- {
|
92
94
|
|
93
|
-
|
95
|
+
--- Place[y, x] = Color[player];
|
94
96
|
|
97
|
+
--- }
|
95
98
|
|
99
|
+
---
|
96
100
|
|
97
|
-
public void
|
101
|
+
--- public void Reverse(int x, int y, int player)
|
98
102
|
|
99
|
-
{
|
103
|
+
--- {
|
100
104
|
|
101
|
-
|
105
|
+
--- //右
|
102
106
|
|
103
|
-
|
107
|
+
--- for (int i = 1; x + i < Place.GetLength(1); i++)
|
104
108
|
|
109
|
+
--- {
|
105
110
|
|
111
|
+
--- if (Place[y, x + i] == Blank)
|
106
112
|
|
107
|
-
|
113
|
+
--- {
|
108
114
|
|
109
|
-
|
115
|
+
--- break;
|
110
116
|
|
111
|
-
|
117
|
+
--- }
|
112
118
|
|
113
|
-
|
119
|
+
--- else if (Place[y, x + i] == Color[player])
|
114
120
|
|
115
|
-
{
|
121
|
+
--- {
|
116
122
|
|
117
|
-
|
123
|
+
--- for (int j = 1; j < i; j++)
|
118
124
|
|
119
|
-
{
|
125
|
+
--- {
|
120
126
|
|
121
|
-
|
127
|
+
--- Place[y, x + j] = Color[player];
|
122
128
|
|
123
|
-
}
|
129
|
+
--- }
|
124
130
|
|
125
|
-
|
131
|
+
--- break;
|
126
132
|
|
127
|
-
|
133
|
+
--- }
|
128
134
|
|
129
|
-
|
135
|
+
--- }
|
130
136
|
|
131
|
-
|
137
|
+
---
|
132
138
|
|
133
|
-
|
139
|
+
--- //右斜め上
|
134
140
|
|
135
|
-
|
141
|
+
--- for (int k = 1; y + k < Place.GetLength(0) && x + k < Place.GetLength(1); k++)
|
136
142
|
|
137
|
-
|
143
|
+
--- {
|
138
144
|
|
139
|
-
|
145
|
+
--- if (Place[y + k, x + k] == Blank)
|
140
146
|
|
141
|
-
|
147
|
+
--- {
|
142
148
|
|
143
|
-
|
149
|
+
--- break;
|
144
150
|
|
145
|
-
|
151
|
+
--- }
|
146
152
|
|
147
|
-
|
153
|
+
--- else if (Place[y + k, x + k] == Color[player])
|
148
154
|
|
149
|
-
|
155
|
+
--- {
|
150
156
|
|
151
|
-
|
157
|
+
--- for (int r = 1; r < k; r++)
|
152
158
|
|
153
|
-
|
159
|
+
--- {
|
154
160
|
|
155
|
-
|
161
|
+
--- Place[y + r, x + r] = Color[player];
|
156
162
|
|
157
|
-
|
163
|
+
--- }
|
158
164
|
|
159
|
-
|
165
|
+
--- break;
|
160
166
|
|
161
|
-
|
167
|
+
--- }
|
162
168
|
|
163
|
-
|
169
|
+
--- }
|
164
170
|
|
165
|
-
|
171
|
+
--- }
|
166
172
|
|
167
|
-
}
|
168
|
-
|
169
|
-
|
173
|
+
--- }
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
//上
|
176
|
-
|
177
|
-
for (int i = 1; y + i < Place.GetLength(0); i++)
|
178
|
-
|
179
|
-
{
|
180
|
-
|
181
|
-
if (Place[y + i, x] == Blank)
|
182
|
-
|
183
|
-
{
|
184
|
-
|
185
|
-
break;
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
else if (Place[y + i, x] == Color[player])
|
190
|
-
|
191
|
-
{
|
192
|
-
|
193
|
-
for (int j = 1; j < i; j++)
|
194
|
-
|
195
|
-
{
|
196
|
-
|
197
|
-
Place[y + j, x] = Color[player];
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
break;
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
//下
|
208
|
-
|
209
|
-
for (int i = 1; y - i >= 0; i++)
|
210
|
-
|
211
|
-
{
|
212
|
-
|
213
|
-
if (Place[y - i, x] == Blank)
|
214
|
-
|
215
|
-
{
|
216
|
-
|
217
|
-
break;
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
else if (Place[y - i, x] == Color[player])
|
222
|
-
|
223
|
-
{
|
224
|
-
|
225
|
-
for (int j = 1; j < i; j++)
|
226
|
-
|
227
|
-
{
|
228
|
-
|
229
|
-
Place[y - j, x] = Color[player];
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
break;
|
234
|
-
|
235
|
-
}
|
236
|
-
|
237
|
-
}
|
238
|
-
|
239
|
-
//右斜め上
|
240
|
-
|
241
|
-
for (int k = 1; y + k < Place.GetLength(0) && x + k < Place.GetLength(1); k++)
|
242
|
-
|
243
|
-
{
|
244
|
-
|
245
|
-
if (Place[y + k, x + k] == Blank)
|
246
|
-
|
247
|
-
{
|
248
|
-
|
249
|
-
break;
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
else if (Place[y + k, x + k] == Color[player])
|
254
|
-
|
255
|
-
{
|
256
|
-
|
257
|
-
for (int r = 1; r < k; r++)
|
258
|
-
|
259
|
-
{
|
260
|
-
|
261
|
-
Place[y + r, x + r] = Color[player];
|
262
|
-
|
263
|
-
}
|
264
|
-
|
265
|
-
break;
|
266
|
-
|
267
|
-
}
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
//左斜め下
|
276
|
-
|
277
|
-
for (int k = 1; y - k >= 0 && x - k >= 0; k++)
|
278
|
-
|
279
|
-
{
|
280
|
-
|
281
|
-
if (Place[y - k, x - k] == Blank)
|
282
|
-
|
283
|
-
{
|
284
|
-
|
285
|
-
break;
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
else if (Place[y - k, x - k] == Color[player])
|
290
|
-
|
291
|
-
{
|
292
|
-
|
293
|
-
for (int r = 1; r < k; r++)
|
294
|
-
|
295
|
-
{
|
296
|
-
|
297
|
-
Place[y - r, x - r] = Color[player];
|
298
|
-
|
299
|
-
}
|
300
|
-
|
301
|
-
break;
|
302
|
-
|
303
|
-
}
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
//左斜め上
|
308
|
-
|
309
|
-
for (int k = 1; y + k < Place.GetLength(0) && x - k >= 0; k++)
|
310
|
-
|
311
|
-
{
|
312
|
-
|
313
|
-
if (Place[y + k, x - k] == Blank)
|
314
|
-
|
315
|
-
{
|
316
|
-
|
317
|
-
break;
|
318
|
-
|
319
|
-
}
|
320
|
-
|
321
|
-
else if (Place[y + k, x - k] == Color[player])
|
322
|
-
|
323
|
-
{
|
324
|
-
|
325
|
-
for (int r = 1; r < k; r++)
|
326
|
-
|
327
|
-
{
|
328
|
-
|
329
|
-
Place[y + r, x - r] = Color[player];
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
break;
|
334
|
-
|
335
|
-
}
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
//右斜め下
|
340
|
-
|
341
|
-
for (int k = 1; y - k >= 0 && x + k < Place.GetLength(1); k++)
|
342
|
-
|
343
|
-
{
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
if (Place[y - k, x + k] == Blank)
|
348
|
-
|
349
|
-
{
|
350
|
-
|
351
|
-
break;
|
352
|
-
|
353
|
-
}
|
354
|
-
|
355
|
-
else if (Place[y - k, x + k] == Color[player])
|
356
|
-
|
357
|
-
{
|
358
|
-
|
359
|
-
for (int r = 1; r < k; r++)
|
360
|
-
|
361
|
-
{
|
362
|
-
|
363
|
-
Place[y - r, x + r] = Color[player];
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
break;
|
368
|
-
|
369
|
-
}
|
370
|
-
|
371
|
-
}
|
372
|
-
|
373
|
-
}
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
public int ReverseCounter(int x, int y, int player)
|
378
|
-
|
379
|
-
{
|
380
|
-
|
381
|
-
int counter = 0;
|
382
|
-
|
383
|
-
//右
|
384
|
-
|
385
|
-
for (int i = 1; x + i < Place.GetLength(1); i++)
|
386
|
-
|
387
|
-
{
|
388
|
-
|
389
|
-
if (Place[y, x + i] == Blank)
|
390
|
-
|
391
|
-
{
|
392
|
-
|
393
|
-
break;
|
394
|
-
|
395
|
-
}
|
396
|
-
|
397
|
-
else if (Place[y, x + i] == Color[player])
|
398
|
-
|
399
|
-
{
|
400
|
-
|
401
|
-
for (int j = 1; j < i; j++)
|
402
|
-
|
403
|
-
{
|
404
|
-
|
405
|
-
counter++;
|
406
|
-
|
407
|
-
}
|
408
|
-
|
409
|
-
break;
|
410
|
-
|
411
|
-
}
|
412
|
-
|
413
|
-
}
|
414
|
-
|
415
|
-
//左
|
416
|
-
|
417
|
-
for (int i = 1; x - i >= 0; i++)
|
418
|
-
|
419
|
-
{
|
420
|
-
|
421
|
-
if (Place[y, x - i] == Blank)
|
422
|
-
|
423
|
-
{
|
424
|
-
|
425
|
-
break;
|
426
|
-
|
427
|
-
}
|
428
|
-
|
429
|
-
else if (Place[y, x - i] == Color[player])
|
430
|
-
|
431
|
-
{
|
432
|
-
|
433
|
-
for (int j = 1; j < i; j++)
|
434
|
-
|
435
|
-
{
|
436
|
-
|
437
|
-
counter++;
|
438
|
-
|
439
|
-
}
|
440
|
-
|
441
|
-
break;
|
442
|
-
|
443
|
-
}
|
444
|
-
|
445
|
-
}
|
446
|
-
|
447
|
-
//上
|
448
|
-
|
449
|
-
for (int i = 1; y + i < Place.GetLength(0); i++)
|
450
|
-
|
451
|
-
{
|
452
|
-
|
453
|
-
if (Place[y + i, x] == Blank)
|
454
|
-
|
455
|
-
{
|
456
|
-
|
457
|
-
break;
|
458
|
-
|
459
|
-
}
|
460
|
-
|
461
|
-
else if (Place[y + i, x] == Color[player])
|
462
|
-
|
463
|
-
{
|
464
|
-
|
465
|
-
for (int j = 1; j < i; j++)
|
466
|
-
|
467
|
-
{
|
468
|
-
|
469
|
-
counter++;
|
470
|
-
|
471
|
-
}
|
472
|
-
|
473
|
-
break;
|
474
|
-
|
475
|
-
}
|
476
|
-
|
477
|
-
}
|
478
|
-
|
479
|
-
//下
|
480
|
-
|
481
|
-
for (int i = 1; y - i >= 0; i++)
|
482
|
-
|
483
|
-
{
|
484
|
-
|
485
|
-
if (Place[y - i, x] == Blank)
|
486
|
-
|
487
|
-
{
|
488
|
-
|
489
|
-
break;
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
|
-
else if (Place[y - i, x] == Color[player])
|
494
|
-
|
495
|
-
{
|
496
|
-
|
497
|
-
for (int j = 1; j < i; j++)
|
498
|
-
|
499
|
-
{
|
500
|
-
|
501
|
-
counter++;
|
502
|
-
|
503
|
-
}
|
504
|
-
|
505
|
-
break;
|
506
|
-
|
507
|
-
}
|
508
|
-
|
509
|
-
}
|
510
|
-
|
511
|
-
//右斜め上
|
512
|
-
|
513
|
-
for (int k = 1; y + k < Place.GetLength(0) && x + k < Place.GetLength(1); k++)
|
514
|
-
|
515
|
-
{
|
516
|
-
|
517
|
-
if (Place[y + k, x + k] == Blank)
|
518
|
-
|
519
|
-
{
|
520
|
-
|
521
|
-
break;
|
522
|
-
|
523
|
-
}
|
524
|
-
|
525
|
-
else if (Place[y + k, x + k] == Color[player])
|
526
|
-
|
527
|
-
{
|
528
|
-
|
529
|
-
for (int r = 1; r < k; r++)
|
530
|
-
|
531
|
-
{
|
532
|
-
|
533
|
-
counter++;
|
534
|
-
|
535
|
-
}
|
536
|
-
|
537
|
-
break;
|
538
|
-
|
539
|
-
}
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
}
|
546
|
-
|
547
|
-
//左斜め下
|
548
|
-
|
549
|
-
for (int k = 1; y - k >= 0 && x - k >= 0; k++)
|
550
|
-
|
551
|
-
{
|
552
|
-
|
553
|
-
if (Place[y - k, x - k] == Blank)
|
554
|
-
|
555
|
-
{
|
556
|
-
|
557
|
-
break;
|
558
|
-
|
559
|
-
}
|
560
|
-
|
561
|
-
else if (Place[y - k, x - k] == Color[player])
|
562
|
-
|
563
|
-
{
|
564
|
-
|
565
|
-
for (int r = 1; r < k; r++)
|
566
|
-
|
567
|
-
{
|
568
|
-
|
569
|
-
counter++;
|
570
|
-
|
571
|
-
}
|
572
|
-
|
573
|
-
break;
|
574
|
-
|
575
|
-
}
|
576
|
-
|
577
|
-
}
|
578
|
-
|
579
|
-
//左斜め上
|
580
|
-
|
581
|
-
for (int k = 1; y + k < Place.GetLength(0) && x - k >= 0; k++)
|
582
|
-
|
583
|
-
{
|
584
|
-
|
585
|
-
if (Place[y + k, x - k] == Blank)
|
586
|
-
|
587
|
-
{
|
588
|
-
|
589
|
-
break;
|
590
|
-
|
591
|
-
}
|
592
|
-
|
593
|
-
else if (Place[y + k, x - k] == Color[player])
|
594
|
-
|
595
|
-
{
|
596
|
-
|
597
|
-
for (int r = 1; r < k; r++)
|
598
|
-
|
599
|
-
{
|
600
|
-
|
601
|
-
counter++;
|
602
|
-
|
603
|
-
}
|
604
|
-
|
605
|
-
break;
|
606
|
-
|
607
|
-
}
|
608
|
-
|
609
|
-
}
|
610
|
-
|
611
|
-
//右斜め下
|
612
|
-
|
613
|
-
for (int k = 1; y - k >= 0 && x + k < Place.GetLength(1); k++)
|
614
|
-
|
615
|
-
{
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
if (Place[y - k, x + k] == Blank)
|
620
|
-
|
621
|
-
{
|
622
|
-
|
623
|
-
break;
|
624
|
-
|
625
|
-
}
|
626
|
-
|
627
|
-
else if (Place[y - k, x + k] == Color[player])
|
628
|
-
|
629
|
-
{
|
630
|
-
|
631
|
-
for (int r = 1; r < k; r++)
|
632
|
-
|
633
|
-
{
|
634
|
-
|
635
|
-
counter++;
|
636
|
-
|
637
|
-
}
|
638
|
-
|
639
|
-
break;
|
640
|
-
|
641
|
-
}
|
642
|
-
|
643
|
-
}
|
644
|
-
|
645
|
-
return counter;
|
646
|
-
|
647
|
-
}
|
648
|
-
|
649
|
-
}
|
1
誤字など修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
そろそろ入門レベルから次のステップに行こうと考えているのですが、
|
5
|
+
そろそろ入門レベルから次のステップに行こうと考えているのですが、自粛の影響であっちこっち行って書籍を確認する事も難しい上に値段も相当張るので中々決めかねています。
|
6
|
+
|
7
|
+
(若干前回の質問と重複していますが、デザイン設計は私にはまだ早いと結論付けました)
|
8
|
+
|
9
|
+
|
6
10
|
|
7
11
|
目星をつけているのは
|
8
12
|
|
@@ -22,11 +26,11 @@
|
|
22
26
|
|
23
27
|
|
24
28
|
|
25
|
-
*完全に独学故、自分のレベルもよく分かってないので下記に自分が0から書いたコードを載せておきます。
|
29
|
+
*完全に独学故、自分のレベルもよく分かってないので下記に自分が0から書いたコードを載せておきます。
|
26
30
|
|
27
31
|
```ここに言語を入力
|
28
32
|
|
29
|
-
オセロプログラムで使ったメソッドです。他にも2048というゲームも作りました。
|
33
|
+
オセロプログラムで使った諸メソッドの一部です。他にも2048というゲームも作りました。
|
30
34
|
|
31
35
|
```using System;
|
32
36
|
|