-
Notifications
You must be signed in to change notification settings - Fork 3
/
SimGameLog.pas
644 lines (609 loc) · 19 KB
/
SimGameLog.pas
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
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
unit SimGameLog;
{$MODE Delphi}
interface
uses
LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Globals, ComCtrls, ExtCtrls, StdCtrls, Buttons, Grids{, JvExGrids,
JvStringGrid};
type
TPlayerStats = record
Name: string; // name
Army, // total armies when game ended
Territ, // number of owned territories when game ended
LastTurn, // last turn played by the player
Points, // points in the game
Rank: integer; // rank at the end of the game
end;
TGameStats = record
GameEnd: TSimStatus; // termination type
GameDate: TDateTime; // date+time the simulation ended
GameTime, // duration of the game in seconds
GameTurns, // duration of the game in turns
NumPl: integer; // number of players
aPStats: array [0 .. MAXPLAYERS] of TPlayerStats; // players' stats
end;
TPlayerSummary = record
Name: string; // name
Games, // number of games played
Better, // number of games the player was better than the reference player
Worse, // number of games the player was worse than the reference player
Won, // number of games won
Rank, // sum of the ranks
RefRank, // sum of the ranks of the reference player
TurnsPlayed, // sum of turns of played games
TurnsToWin, // sum of turns of won games
Armies, // sum of armies at the end of won games
Points: integer; // sum of the points
end;
TfSimGameLog = class(TForm)
pgcLog: TPageControl;
tbsGames: TTabSheet;
lstGames: TListView;
Panel1: TPanel;
lstPlayers: TListView;
tbsRanking: TTabSheet;
grdRanking: TStringGrid;
tbsAnalysis: TTabSheet;
cboPlayer: TComboBox;
Label1: TLabel;
grdAnalysis: TStringGrid;
function SplitStr(var theString: string; delimiter: string): string;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure lstGamesSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
procedure FormCreate(Sender: TObject);
procedure grdRankingCaptionClick(Sender: TStringGrid;
AColumn, ARow: integer);
procedure grdRankingCompareCells(Sender: TObject; ACol, ARow, BCol, BRow: Integer; var Result: integer);
procedure grdRankingDrawCell(Sender: TObject; ACol, ARow: integer;
Rect: TRect; State: TGridDrawState);
procedure grdAnalysisCaptionClick(Sender: TStringGrid;
AColumn, ARow: integer);
procedure grdAnalysisCompareCells(Sender: TObject; ACol, ARow, BCol, BRow: Integer; var Result: integer);
procedure grdAnalysisDrawCell(Sender: TObject; ACol, ARow: integer;
Rect: TRect; State: TGridDrawState);
procedure cboPlayerSelect(Sender: TObject);
private
aGameStats: array of TGameStats;
aPlaySum: array of TPlayerSummary;
iSortCol, // ranking grid sort column
iSortCol2, // analysis grid sort column
iPlayCount, // number of players in aPlaySum
iTotGames: integer; // number of games in the log file
procedure LoadLogFile;
procedure PopulateGamesList;
procedure PopulateAnalysisGrid(const sPlayer: string);
procedure PopulateRankingGrid;
function DecodeGameEnd(uEnd: TSimStatus): string;
procedure SummarizePlayers(const sPlayer: string);
public
sLogFileName: string;
end;
var
fSimGameLog: TfSimGameLog;
implementation
{$R *.lfm}
{uses StdPas;}
function TfSimGameLog.SplitStr(var theString: string; delimiter: string): string;
var
i: integer;
begin
Result:= '';
if theString <> '' then
begin
i:= Pos(delimiter, theString);
if i > 0 then
begin
Result:= Copy(theString, 1, i-1);
theString:= Copy(theString, i+Length(delimiter), maxLongInt);
end
else
begin
Result:= theString;
theString:= '';
end;
end;
end;
procedure TfSimGameLog.FormCreate(Sender: TObject);
begin
with grdRanking do begin
RowCount := 1;
ColCount := 10;
Cells[0, 0] := 'Player';
Cells[1, 0] := 'Games';
Cells[2, 0] := 'Won';
Cells[3, 0] := '% Won';
Cells[4, 0] := 'Points';
Cells[5, 0] := 'Pts/Game';
Cells[6, 0] := 'Avg Rank';
Cells[7, 0] := 'Turns/Game';
Cells[8, 0] := 'Turns to win';
Cells[9, 0] := 'Final armies';
ColWidths[0] := 70;
ColWidths[1] := 50;
ColWidths[2] := 50;
ColWidths[3] := 50;
ColWidths[4] := 50;
ColWidths[5] := 70;
ColWidths[6] := 70;
ColWidths[7] := 80;
ColWidths[8] := 80;
ColWidths[9] := 80;
end;
iSortCol := 0;
with grdAnalysis do begin
RowCount := 1;
ColCount := 7;
Cells[0, 0] := 'Competitor';
Cells[1, 0] := 'Games';
Cells[2, 0] := 'Better';
Cells[3, 0] := 'Worse';
Cells[4, 0] := '% Better';
Cells[5, 0] := '% Worse';
Cells[6, 0] := 'Rank diff.';
ColWidths[0] := 70;
ColWidths[1] := 50;
ColWidths[2] := 50;
ColWidths[3] := 50;
ColWidths[4] := 70;
ColWidths[5] := 70;
ColWidths[6] := 70;
end;
iSortCol2 := 0;
end;
procedure TfSimGameLog.FormShow(Sender: TObject);
begin
Caption := 'Game log analysis: ' + sLogFileName;
LoadLogFile;
PopulateGamesList;
PopulateRankingGrid;
pgcLog.ActivePage := tbsGames;
end;
procedure TfSimGameLog.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfSimGameLog.FormDestroy(Sender: TObject);
begin
fSimGameLog := nil;
end;
procedure TfSimGameLog.grdAnalysisCaptionClick(Sender: TStringGrid;
AColumn, ARow: integer);
begin
Screen.Cursor := crHourGlass;
{ with (Sender as TStringGrid) do begin
iSortCol2 := AColumn;
case AColumn of
0:
SortGrid(0, true);
6:
SortGrid(AColumn, true, false, stNumeric, false);
else
SortGrid(AColumn, false, false, stNumeric, false);
end;
if RowCount > 0 then
Row := 1
else
Row := 0;
end; }
Screen.Cursor := crDefault;
end;
procedure TfSimGameLog.grdAnalysisCompareCells(Sender: TObject; ACol, ARow, BCol, BRow: Integer; var Result: integer);
begin
// Result will be either <0, =0, or >0 for normal order.
if (ACol >= 1) and (ACol <= 3) then begin
result := StrToIntDef(grdAnalysis.Cells[ACol,ARow],0)-StrToIntDef(grdAnalysis.Cells[BCol,BRow],0);
end
else if (ACol >= 4) and (ACol <= 5) then begin
result := round((StrToFloatDef(StringReplace(grdAnalysis.Cells[ACol,ARow],'%','',[rfReplaceAll,rfIgnoreCase]),0)-StrToFloatDef(StringReplace(grdAnalysis.Cells[BCol,BRow],'%','',[rfReplaceAll,rfIgnoreCase]),0))*10);
end
else if ACol = 6 then begin
result := round((StrToFloatDef(grdAnalysis.Cells[ACol,ARow],0)-StrToFloatDef(grdAnalysis.Cells[BCol,BRow],0))*10);
end;
// For inverse order, just negate the result (eg. based on grid's SortOrder).
if grdAnalysis.SortOrder = soDescending then
result := -result;
end;
procedure TfSimGameLog.grdAnalysisDrawCell(Sender: TObject;
ACol, ARow: integer; Rect: TRect; State: TGridDrawState);
begin
with grdAnalysis.Canvas do begin
if ARow = 0 then begin
Brush.color := clBtnFace;
Font.color := clBlack;
Font.Style := [fsBold];
FillRect(Rect);
end
else begin
if ACol = iSortCol2 then
Brush.color := clCream
else
Brush.color := clWhite;
Font.color := clBlack;
Font.Style := [];
FillRect(Rect);
end;
if ACol = 0 then begin
TextOut(Rect.Left + 1, Rect.Top + 1, grdAnalysis.Cells[ACol, ARow]);
end
else begin
TextOut(Rect.Right - TextWidth(grdAnalysis.Cells[ACol, ARow]) - 3,
Rect.Top + 1, grdAnalysis.Cells[ACol, ARow]);
end;
end;
end;
procedure TfSimGameLog.grdRankingCaptionClick(Sender: TStringGrid;
AColumn, ARow: integer);
begin
Screen.Cursor := crHourGlass;
{ with (Sender as TStringGrid) do begin
iSortCol := AColumn;
case AColumn of
0:
SortGrid(0, true);
6:
SortGrid(AColumn, true, false, stNumeric, false);
else
SortGrid(AColumn, false, false, stNumeric, false);
end;
if RowCount > 0 then
Row := 1
else
Row := 0;
end; }
Screen.Cursor := crDefault;
end;
procedure TfSimGameLog.grdRankingCompareCells(Sender: TObject; ACol, ARow, BCol, BRow: Integer; var Result: integer);
begin
// Result will be either <0, =0, or >0 for normal order.
case ACol of
3: // Percent
result := round((StrToFloatDef(StringReplace(grdRanking.Cells[ACol,ARow],'%','',[rfReplaceAll,rfIgnoreCase]),0)-StrToFloatDef(StringReplace(grdRanking.Cells[BCol,BRow],'%','',[rfReplaceAll,rfIgnoreCase]),0))*10);
5: // Float
result := round((StrToFloatDef(grdRanking.Cells[ACol,ARow],0)-StrToFloatDef(grdRanking.Cells[BCol,BRow],0))*10);
6: // Float
result := round((StrToFloatDef(grdRanking.Cells[ACol,ARow],0)-StrToFloatDef(grdRanking.Cells[BCol,BRow],0))*10);
else
result := StrToIntDef(grdRanking.Cells[ACol,ARow],0)-StrToIntDef(grdRanking.Cells[BCol,BRow],0);
end;
// For inverse order, just negate the result (eg. based on grid's SortOrder).
if grdRanking.SortOrder = soDescending then
result := -result;
end;
procedure TfSimGameLog.grdRankingDrawCell(Sender: TObject; ACol, ARow: integer;
Rect: TRect; State: TGridDrawState);
begin
with grdRanking.Canvas do begin
if ARow = 0 then begin
Brush.color := clBtnFace;
Font.color := clBlack;
Font.Style := [fsBold];
FillRect(Rect);
end
else begin
if ACol = iSortCol then
Brush.color := clCream
else
Brush.color := clWhite;
Font.color := clBlack;
Font.Style := [];
FillRect(Rect);
end;
if ACol = 0 then begin
TextOut(Rect.Left + 1, Rect.Top + 1, grdRanking.Cells[ACol, ARow]);
end
else begin
TextOut(Rect.Right - TextWidth(grdRanking.Cells[ACol, ARow]) - 3,
Rect.Top + 1, grdRanking.Cells[ACol, ARow]);
end;
end;
end;
procedure TfSimGameLog.lstGamesSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
var
iP: integer;
begin
lstPlayers.Clear;
if lstGames.ItemIndex < 0 then begin
exit;
end;
// populate player's list
with aGameStats[lstGames.ItemIndex] do begin
for iP := 1 to NumPl do begin
with lstPlayers.Items.Add do begin
if GameEnd = ssComplete then
Caption := IntToStr(aPStats[iP].Rank)
else
Caption := '-';
SubItems.Add(aPStats[iP].Name);
SubItems.Add(IntToStr(aPStats[iP].LastTurn));
SubItems.Add(IntToStr(aPStats[iP].Army));
SubItems.Add(IntToStr(aPStats[iP].Territ));
end;
end;
end;
end;
procedure TfSimGameLog.cboPlayerSelect(Sender: TObject);
begin
PopulateAnalysisGrid(cboPlayer.Text);
end;
procedure TfSimGameLog.LoadLogFile;
const
ARRAY_INCR = 100;
var
fHistory: textfile;
iG, iP: integer;
sRec, sTmp: string;
begin
iTotGames := 0;
// open history file
if not FileExists(sG_AppPath + sLogFileName) then begin
ShowMessage('Log file "' + sLogFileName + '" not found.');
exit;
end;
AssignFile(fHistory, sG_AppPath + sLogFileName);
Reset(fHistory);
// prepare array
SetLength(aGameStats, ARRAY_INCR);
// load list
try
// read history file into array
while not Eof(fHistory) do begin
Readln(fHistory, sRec);
inc(iTotGames);
if iTotGames > length(aGameStats) then begin
SetLength(aGameStats, length(aGameStats) + ARRAY_INCR);
end;
iG := iTotGames - 1;
with aGameStats[iG] do begin
// date
sTmp := SplitStr(sRec, ',');
GameDate := EncodeDate(StrToInt(copy(sTmp, 1, 4)),
StrToInt(copy(sTmp, 5, 2)), StrToInt(copy(sTmp, 7, 2)));
// time
sTmp := SplitStr(sRec, ',');
GameDate := GameDate + EncodeTime(StrToInt(copy(sTmp, 1, 2)),
StrToInt(copy(sTmp, 3, 2)), StrToInt(copy(sTmp, 5, 2)), 0);
// termination type
sTmp := SplitStr(sRec, ',');
GameEnd := TSimStatus(StrToInt(sTmp));
// time
sTmp := SplitStr(sRec, ',');
GameTime := StrToInt(sTmp);
// turns
sTmp := SplitStr(sRec, ',');
GameTurns := StrToInt(sTmp);
// number of players
sTmp := SplitStr(sRec, ',');
NumPl := StrToInt(sTmp);
// list item
for iP := 1 to NumPl do begin
// player's name
sTmp := lowercase(SplitStr(sRec, ','));
aPStats[iP].Name := sTmp;
// player's last turn
sTmp := SplitStr(sRec, ',');
aPStats[iP].LastTurn := StrToInt(sTmp);
// player's army
sTmp := SplitStr(sRec, ',');
aPStats[iP].Army := StrToInt(sTmp);
// player's territories
sTmp := SplitStr(sRec, ',');
aPStats[iP].Territ := StrToInt(sTmp);
// rank & points
if GameEnd = ssComplete then begin
aPStats[iP].Rank := iP;
aPStats[iP].Points := NumPl + 1 - iP;
end
else begin
aPStats[iP].Rank := 0;
aPStats[iP].Points := 0;
end;
end;
end;
end;
finally
CloseFile(fHistory);
end;
end;
procedure TfSimGameLog.PopulateGamesList;
var
i: integer;
begin
lstGames.Clear;
for i := 0 to iTotGames - 1 do begin
with lstGames.Items.Add do begin
Caption := IntToStr(i + 1);
SubItems.Add(FormatDateTime('c', aGameStats[i].GameDate));
SubItems.Add(DecodeGameEnd(aGameStats[i].GameEnd));
SubItems.Add(IntToStr(aGameStats[i].GameTime));
SubItems.Add(IntToStr(aGameStats[i].GameTurns));
if aGameStats[i].GameEnd = ssComplete then begin
SubItems.Add(aGameStats[i].aPStats[1].Name);
end
end;
end;
end;
procedure TfSimGameLog.PopulateRankingGrid;
var
iL: integer;
begin
// summarize players
SummarizePlayers('');
// load ranking grid
with grdRanking do begin
RowCount := iPlayCount + 1;
for iL := 0 to iPlayCount - 1 do begin
with aPlaySum[iL] do begin
Cells[0, iL + 1] := Name;
Cells[1, iL + 1] := FormatFloat('#,##0', Games);
Cells[2, iL + 1] := FormatFloat('#,##0', Won);
Cells[4, iL + 1] := FormatFloat('#,##0', Points);
if Games > 0 then begin
Cells[3, iL + 1] := FormatFloat('0.0"%"', (100.0 * Won) / Games);
Cells[5, iL + 1] := FormatFloat('0.0', Points / Games);
Cells[6, iL + 1] := FormatFloat('0.0', Rank / Games);
Cells[7, iL + 1] := FormatFloat('0', TurnsPlayed / Games);
end
else begin
Cells[3, iL + 1] := '-';
Cells[5, iL + 1] := '-';
Cells[6, iL + 1] := '-';
Cells[7, iL + 1] := '-';
end;
if Won > 0 then begin
Cells[8, iL + 1] := FormatFloat('0', TurnsToWin / Won);
Cells[9, iL + 1] := FormatFloat('0', Armies / Won);
end
else begin
Cells[8, iL + 1] := '-';
Cells[9, iL + 1] := '-';
end;
end;
end;
if RowCount > 1 then
FixedRows := 1;
{SortGrid(0, true); }
iSortCol := 0;
end;
// populate player's combo
with cboPlayer do begin
Clear;
for iL := 0 to iPlayCount - 1 do begin
Items.Add(aPlaySum[iL].Name);
end;
end;
end;
procedure TfSimGameLog.PopulateAnalysisGrid(const sPlayer: string);
var
iL, iP: integer;
begin
// summarize players
SummarizePlayers(sPlayer);
// load grid
with grdAnalysis do begin
RowCount := iPlayCount;
iL := 0;
for iP := 0 to iPlayCount - 1 do begin
with aPlaySum[iP] do begin
if SameText(sPlayer, Name) then
continue; // skip analysed player
inc(iL);
Cells[0, iL] := Name;
Cells[1, iL] := FormatFloat('#,##0', Games);
Cells[2, iL] := FormatFloat('#,##0', Better);
Cells[3, iL] := FormatFloat('#,##0', Worse);
if Games > 0 then begin
Cells[4, iL] := FormatFloat('0.0"%"', (100.0 * Better) / Games);
Cells[5, iL] := FormatFloat('0.0"%"', (100.0 * Worse) / Games);
Cells[6, iL] := FormatFloat('0.0', (Rank - RefRank) / Games);
end
else begin
Cells[4, iL] := '-';
Cells[5, iL] := '-';
Cells[6, iL] := '-';
end;
end;
end;
if RowCount > 1 then
FixedRows := 1;
{SortGrid(0, true); }
iSortCol2 := 0;
end;
end;
procedure TfSimGameLog.SummarizePlayers(const sPlayer: string);
var
iG, iP, iPS, iRefRank: integer;
bFound: Boolean;
begin
SetLength(aPlaySum, 100);
iPlayCount := 0;
for iG := 0 to iTotGames - 1 do begin
// skip uncompleted games
if aGameStats[iG].GameEnd <> ssComplete then
continue;
// if a player is specified, skip games that do not contain that player
if sPlayer > '' then begin
bFound := false;
for iP := 1 to aGameStats[iG].NumPl do begin
if SameText(sPlayer, aGameStats[iG].aPStats[iP].Name) then begin
bFound := true;
iRefRank := aGameStats[iG].aPStats[iP].Rank;
break;
end;
end;
if not bFound then
continue;
end;
// account players' stats
for iP := 1 to aGameStats[iG].NumPl do begin
// search player in summary array
bFound := false;
for iPS := 0 to iPlayCount - 1 do begin
if SameText(aGameStats[iG].aPStats[iP].Name, aPlaySum[iPS].Name) then
begin
bFound := true;
break;
end;
end;
// if not found, add it to the array
if not bFound then begin
inc(iPlayCount);
if iPlayCount > length(aPlaySum) then
SetLength(aPlaySum, length(aPlaySum) + 100);
iPS := iPlayCount - 1;
aPlaySum[iPS].Name := aGameStats[iG].aPStats[iP].Name;
aPlaySum[iPS].Games := 0;
aPlaySum[iPS].Better := 0;
aPlaySum[iPS].Worse := 0;
aPlaySum[iPS].Won := 0;
aPlaySum[iPS].Rank := 0;
aPlaySum[iPS].RefRank := 0;
aPlaySum[iPS].Points := 0;
aPlaySum[iPS].TurnsPlayed := 0;
aPlaySum[iPS].TurnsToWin := 0;
aPlaySum[iPS].Armies := 0;
end;
// update stats
inc(aPlaySum[iPS].Games);
aPlaySum[iPS].TurnsPlayed := aPlaySum[iPS].TurnsPlayed + aGameStats[iG]
.aPStats[iP].LastTurn;
if aGameStats[iG].aPStats[iP].Rank = 1 then begin
inc(aPlaySum[iPS].Won);
aPlaySum[iPS].TurnsToWin := aPlaySum[iPS].TurnsToWin + aGameStats[iG]
.aPStats[iP].LastTurn;
aPlaySum[iPS].Armies := aPlaySum[iPS].Armies + aGameStats[iG]
.aPStats[iP].Army;
end;
aPlaySum[iPS].Rank := aPlaySum[iPS].Rank + aGameStats[iG].aPStats[iP]
.Rank;
aPlaySum[iPS].Points := aPlaySum[iPS].Points + aGameStats[iG]
.NumPl + 1 - aGameStats[iG].aPStats[iP].Rank;
if sPlayer > '' then begin
aPlaySum[iPS].RefRank := aPlaySum[iPS].RefRank + iRefRank;
if aGameStats[iG].aPStats[iP].Rank < iRefRank then
inc(aPlaySum[iPS].Better);
if aGameStats[iG].aPStats[iP].Rank > iRefRank then
inc(aPlaySum[iPS].Worse);
end;
end;
end;
end;
function TfSimGameLog.DecodeGameEnd(uEnd: TSimStatus): string;
begin
case uEnd of
ssComplete:
result := 'completed';
ssError:
result := 'TRP error';
ssTurnLimit:
result := 'turn limit';
ssTimeLimit:
result := 'time limit';
ssAbort:
result := 'aborted';
end;
end;
end.