-
Notifications
You must be signed in to change notification settings - Fork 3
/
MainModel.cs
444 lines (366 loc) · 14.8 KB
/
MainModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
using Reactive.Bindings;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;
using System.Xml;
namespace TanukiColiseum
{
/// <summary>
/// 設定項目を保持するモデルクラス
/// </summary>
[DataContract]
public class MainModel : INotifyPropertyChanged
{
[DataMember]
public ReactiveProperty<string> Engine1FilePath { get; set; } = new ReactiveProperty<string>("");
[DataMember]
public ReactiveProperty<string> Engine2FilePath { get; set; } = new ReactiveProperty<string>("");
[DataMember]
public ReactiveProperty<string> Eval1FolderPath { get; set; } = new ReactiveProperty<string>("eval");
[DataMember]
public ReactiveProperty<string> Eval2FolderPath { get; set; } = new ReactiveProperty<string>("eval");
[DataMember]
public ReactiveProperty<int> NumConcurrentGames { get; set; } = new ReactiveProperty<int>(1);
[DataMember]
public ReactiveProperty<int> NumGames { get; set; } = new ReactiveProperty<int>(1000);
[DataMember]
public ReactiveProperty<int> HashMb { get; set; } = new ReactiveProperty<int>(16);
[DataMember]
public ReactiveProperty<int> NumBookMoves1 { get; set; } = new ReactiveProperty<int>(16);
[DataMember]
public ReactiveProperty<int> NumBookMoves2 { get; set; } = new ReactiveProperty<int>(16);
[DataMember]
public ReactiveProperty<string> BookFileName1 { get; set; } = new ReactiveProperty<string>("standard_book.db");
[DataMember]
public ReactiveProperty<string> BookFileName2 { get; set; } = new ReactiveProperty<string>("standard_book.db");
[DataMember]
public ReactiveProperty<int> NumBookMoves { get; set; } = new ReactiveProperty<int>(24);
[DataMember]
public ReactiveProperty<int> MaxMovesToDraw { get; set; } = new ReactiveProperty<int>(320);
[DataMember]
public ReactiveProperty<string> SfenFilePath { get; set; } = new ReactiveProperty<string>("records2016_10818.sfen");
/// <summary>
/// 思考エンジン1に渡す思考ノード数。
/// <para>0が渡された場合、ノード数を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Nodes1 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考エンジン2に渡す思考ノード数。
/// <para>0が渡された場合、ノード数を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Nodes2 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考ノード数に加える乱数(%)。
/// <para>0が渡されたとき、思考ノード数に乱数を加えない</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> NodesRandomPercent1 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考ノード数に加える乱数(%)。
/// <para>0が渡されたとき、思考ノード数に乱数を加えない</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> NodesRandomPercent2 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考ノード数の乱数を1手毎に変化させる。
/// <para>falseの場合、1局を通して同じ値を加える</para>
/// </summary>
[DataMember]
public ReactiveProperty<bool> NodesRandomEveryMove1 { get; set; } = new ReactiveProperty<bool>(true);
/// <summary>
/// 思考ノード数の乱数を1手毎に変化させる。
/// <para>falseの場合、1局を通して同じ値を加える</para>
/// </summary>
[DataMember]
public ReactiveProperty<bool> NodesRandomEveryMove2 { get; set; } = new ReactiveProperty<bool>(true);
/// <summary>
/// 思考エンジン1に渡す持ち時間。
/// <para>0が渡された場合、持ち時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Time1 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考エンジン2に渡す持ち時間。
/// <para>0が渡された場合、持ち時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Time2 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考エンジン1に渡す秒読み時間。
/// <para>0が渡された場合、秒読み時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Byoyomi1 { get; set; } = new ReactiveProperty<int>(1000);
/// <summary>
/// 思考エンジン2に渡す秒読み時間。
/// <para>0が渡された場合、秒読み時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Byoyomi2 { get; set; } = new ReactiveProperty<int>(1000);
/// <summary>
/// 思考エンジン1に渡す加算時間。
/// <para>0が渡された場合、加算時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Inc1 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考エンジン2に渡す加算時間。
/// <para>0が渡された場合、加算時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Inc2 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考エンジン1に渡す乱数付き思考時間。
/// <para>0が渡された場合、乱数付き思考時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Rtime1 { get; set; } = new ReactiveProperty<int>(0);
/// <summary>
/// 思考エンジン2に渡す乱数付き思考時間。
/// <para>0が渡された場合、乱数付き思考時間を指定しない。</para>
/// </summary>
[DataMember]
public ReactiveProperty<int> Rtime2 { get; set; } = new ReactiveProperty<int>(0);
[DataMember]
public ReactiveProperty<int> NumNumaNodes { get; set; } = new ReactiveProperty<int>(1);
[DataMember]
public ReactiveProperty<int> ProgressIntervalMs { get; set; } = new ReactiveProperty<int>(1);
[DataMember]
public ReactiveProperty<int> NumThreads1 { get; set; } = new ReactiveProperty<int>(1);
[DataMember]
public ReactiveProperty<int> NumThreads2 { get; set; } = new ReactiveProperty<int>(1);
[DataMember]
public ReactiveProperty<int> BookEvalDiff1 { get; set; } = new ReactiveProperty<int>(30);
[DataMember]
public ReactiveProperty<int> BookEvalDiff2 { get; set; } = new ReactiveProperty<int>(30);
[DataMember]
public ReactiveProperty<string> ConsiderBookMoveCount1 { get; set; } = new ReactiveProperty<string>("false");
[DataMember]
public ReactiveProperty<string> ConsiderBookMoveCount2 { get; set; } = new ReactiveProperty<string>("false");
[DataMember]
public ReactiveProperty<string> IgnoreBookPly1 { get; set; } = new ReactiveProperty<string>("false");
[DataMember]
public ReactiveProperty<string> IgnoreBookPly2 { get; set; } = new ReactiveProperty<string>("false");
[DataMember]
public ReactiveProperty<int> SlowMover1 { get; set; } = new ReactiveProperty<int>(100);
[DataMember]
public ReactiveProperty<int> SlowMover2 { get; set; } = new ReactiveProperty<int>(100);
[DataMember]
public ReactiveProperty<int> DrawValue1 { get; set; } = new ReactiveProperty<int>(-2);
[DataMember]
public ReactiveProperty<int> DrawValue2 { get; set; } = new ReactiveProperty<int>(-2);
[DataMember]
public ReactiveProperty<int> BookEvalBlackLimit1 { get; set; } = new ReactiveProperty<int>(0);
[DataMember]
public ReactiveProperty<int> BookEvalBlackLimit2 { get; set; } = new ReactiveProperty<int>(0);
[DataMember]
public ReactiveProperty<int> BookEvalWhiteLimit1 { get; set; } = new ReactiveProperty<int>(-140);
[DataMember]
public ReactiveProperty<int> BookEvalWhiteLimit2 { get; set; } = new ReactiveProperty<int>(-140);
[DataMember]
public ReactiveProperty<int> FVScale1 { get; set; } = new ReactiveProperty<int>(16);
[DataMember]
public ReactiveProperty<int> FVScale2 { get; set; } = new ReactiveProperty<int>(16);
[DataMember]
public ReactiveProperty<int> Depth1 { get; set; } = new ReactiveProperty<int>(0);
[DataMember]
public ReactiveProperty<int> Depth2 { get; set; } = new ReactiveProperty<int>(0);
[DataMember]
public ReactiveProperty<int> MinimumThinkingTime1 { get; set; } = new ReactiveProperty<int>(0);
[DataMember]
public ReactiveProperty<int> MinimumThinkingTime2 { get; set; } = new ReactiveProperty<int>(0);
public event PropertyChangedEventHandler PropertyChanged;
public void Save(string filePath)
{
string folderPath = Path.GetDirectoryName(filePath);
// ファイル名だけが渡された場合、FolderPathが空になる。
// GUI画面から測定開始できない · Issue #11 · nodchip/TanukiColiseum https://github.com/nodchip/TanukiColiseum/issues/11
if (folderPath.Length != 0)
{
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
}
var serializer = new DataContractSerializer(typeof(MainModel));
using (var writer = new FileStream(filePath, FileMode.Create))
{
serializer.WriteObject(writer, this);
}
}
public void Load(string filePath)
{
MainModel model;
var serializer = new DataContractSerializer(typeof(MainModel));
using (var reader = new FileStream(filePath, FileMode.Open))
{
try
{
model = (MainModel)serializer.ReadObject(reader);
}
catch (XmlException)
{
// 設定ファイルがxmlとして読み込めなかった場合は、デフォルトの値をロードする。
// 自動保存の設定ファイルが壊れているとGUIが起動できない · Issue #12 · nodchip/TanukiColiseum https://github.com/nodchip/TanukiColiseum/issues/12
model = new MainModel();
}
}
// 過去のデータ形式において保存されなかった値の担保
if (model.Byoyomi1 == null)
{
model.Byoyomi1 = new ReactiveProperty<int>(1000);
}
if (model.Byoyomi2 == null)
{
model.Byoyomi2 = new ReactiveProperty<int>(1000);
}
if (model.Inc1 == null)
{
model.Inc1 = new ReactiveProperty<int>(0);
}
if (model.Inc2 == null)
{
model.Inc2 = new ReactiveProperty<int>(0);
}
if (model.Rtime1 == null)
{
model.Rtime1 = new ReactiveProperty<int>(0);
}
if (model.Rtime2 == null)
{
model.Rtime2 = new ReactiveProperty<int>(0);
}
if (model.NodesRandomPercent1 == null)
{
model.NodesRandomPercent1 = new ReactiveProperty<int>(0);
}
if (model.NodesRandomPercent2 == null)
{
model.NodesRandomPercent2 = new ReactiveProperty<int>(0);
}
if (model.NodesRandomEveryMove1 == null)
{
model.NodesRandomEveryMove1 = new ReactiveProperty<bool>(true);
}
if (model.NodesRandomEveryMove2 == null)
{
model.NodesRandomEveryMove2 = new ReactiveProperty<bool>(true);
}
if (model.MaxMovesToDraw == null)
{
model.MaxMovesToDraw = new ReactiveProperty<int>(320);
}
if (model.SlowMover1 == null)
{
model.SlowMover1 = new ReactiveProperty<int>(100);
}
if (model.SlowMover2 == null)
{
model.SlowMover2 = new ReactiveProperty<int>(100);
}
if (model.DrawValue1 == null)
{
model.DrawValue1 = new ReactiveProperty<int>(-2);
}
if (model.DrawValue2 == null)
{
model.DrawValue2 = new ReactiveProperty<int>(-2);
}
if (model.BookEvalBlackLimit1 == null)
{
model.BookEvalBlackLimit1 = new ReactiveProperty<int>(0);
}
if (model.BookEvalBlackLimit2 == null)
{
model.BookEvalBlackLimit2 = new ReactiveProperty<int>(0);
}
if (model.BookEvalWhiteLimit1 == null)
{
model.BookEvalWhiteLimit1 = new ReactiveProperty<int>(-140);
}
if (model.BookEvalWhiteLimit2 == null)
{
model.BookEvalWhiteLimit2 = new ReactiveProperty<int>(-140);
}
if (model.FVScale1 == null)
{
model.FVScale1 = new ReactiveProperty<int>(16);
}
if (model.FVScale2 == null)
{
model.FVScale2 = new ReactiveProperty<int>(16);
}
if (model.Depth1 == null)
{
model.Depth1 = new ReactiveProperty<int>(0);
}
if (model.Depth2 == null)
{
model.Depth2 = new ReactiveProperty<int>(0);
}
if (model.MinimumThinkingTime1 == null)
{
model.MinimumThinkingTime1 = new ReactiveProperty<int>(0);
}
if (model.MinimumThinkingTime2 == null)
{
model.MinimumThinkingTime2 = new ReactiveProperty<int>(0);
}
CopyFrom(model);
}
public void CopyFrom(MainModel model)
{
Engine1FilePath.Value = model.Engine1FilePath.Value;
Engine2FilePath.Value = model.Engine2FilePath.Value;
Eval1FolderPath.Value = model.Eval1FolderPath.Value;
Eval2FolderPath.Value = model.Eval2FolderPath.Value;
NumConcurrentGames.Value = model.NumConcurrentGames.Value;
NumGames.Value = model.NumGames.Value;
HashMb.Value = model.HashMb.Value;
NumBookMoves1.Value = model.NumBookMoves1.Value;
NumBookMoves2.Value = model.NumBookMoves2.Value;
BookFileName1.Value = model.BookFileName1.Value;
BookFileName2.Value = model.BookFileName2.Value;
NumBookMoves.Value = model.NumBookMoves.Value;
MaxMovesToDraw.Value = model.MaxMovesToDraw.Value;
SfenFilePath.Value = model.SfenFilePath.Value;
Nodes1.Value = model.Nodes1.Value;
Nodes2.Value = model.Nodes2.Value;
NodesRandomPercent1.Value = model.NodesRandomPercent1.Value;
NodesRandomPercent2.Value = model.NodesRandomPercent2.Value;
NodesRandomEveryMove1.Value = model.NodesRandomEveryMove1.Value;
NodesRandomEveryMove2.Value = model.NodesRandomEveryMove2.Value;
Time1.Value = model.Time1.Value;
Time2.Value = model.Time2.Value;
Byoyomi1.Value = model.Byoyomi1.Value;
Byoyomi2.Value = model.Byoyomi2.Value;
Inc1.Value = model.Inc1.Value;
Inc2.Value = model.Inc2.Value;
Rtime1.Value = model.Rtime1.Value;
Rtime2.Value = model.Rtime2.Value;
NumNumaNodes.Value = model.NumNumaNodes.Value;
ProgressIntervalMs.Value = model.ProgressIntervalMs.Value;
NumThreads1.Value = model.NumThreads1.Value;
NumThreads2.Value = model.NumThreads2.Value;
BookEvalDiff1.Value = model.BookEvalDiff1.Value;
BookEvalDiff2.Value = model.BookEvalDiff2.Value;
ConsiderBookMoveCount1.Value = model.ConsiderBookMoveCount1.Value;
ConsiderBookMoveCount2.Value = model.ConsiderBookMoveCount2.Value;
IgnoreBookPly1.Value = model.IgnoreBookPly1.Value;
IgnoreBookPly2.Value = model.IgnoreBookPly2.Value;
SlowMover1.Value = model.SlowMover1.Value;
SlowMover2.Value = model.SlowMover2.Value;
DrawValue1.Value = model.DrawValue1.Value;
DrawValue2.Value = model.DrawValue2.Value;
BookEvalBlackLimit1.Value = model.BookEvalBlackLimit1.Value;
BookEvalBlackLimit2.Value = model.BookEvalBlackLimit2.Value;
BookEvalWhiteLimit1.Value = model.BookEvalWhiteLimit1.Value;
BookEvalWhiteLimit2.Value = model.BookEvalWhiteLimit2.Value;
FVScale1.Value = model.FVScale1.Value;
FVScale2.Value = model.FVScale2.Value;
Depth1.Value = model.Depth1.Value;
Depth2.Value = model.Depth2.Value;
MinimumThinkingTime1.Value = model.MinimumThinkingTime1.Value;
MinimumThinkingTime2.Value = model.MinimumThinkingTime2.Value;
}
}
}