Commit 5c2ded6ecd68b79a5e5a2e6fa4a0d378babc0146

Authored by Carlos Picanco
1 parent f174c320
Exists in master

experiment runner - load and save configuration files

units/game_actors.pas
... ... @@ -96,18 +96,19 @@ type
96 96 FAppendiceLossSingular,
97 97 FAppendiceEarnPlural,
98 98 FAppendiceEarnSingular,
99   - FNicname: string;
  99 + FPrepend: string;
100 100 FStyle : TConsequenceStyle;
101 101 FP : TGamePoint;
102 102 FTimer : TTimer;
103 103 FMessage : TPopupNotifier;
  104 + function GetCsqString: string;
104 105 function GetShouldPublishMessage: Boolean;
105 106 protected
106 107 FConsequenceByPlayerID : TStringList;
107 108 procedure StopTimer(Sender:TObject;var ACloseAction:TCloseAction);
108 109 procedure SelfDestroy(Sender:TOBject);virtual;
109 110 public
110   - constructor Create(AOwner:TComponent; ACsqString, ANicname,
  111 + constructor Create(AOwner:TComponent; ACsqString, APrepend,
111 112 APrependLoss,AAppendiceLossSingular,AAppendiceLossPlural,
112 113 APrependEarn,AAppendiceEarnSingular,AAppendiceEarnPlural,AAppendiceZero:string);overload;
113 114 constructor Create(AOwner:TComponent; AP:integer; AStyle: TConsequenceStyle; AMessage:array of string);overload;
... ... @@ -120,7 +121,7 @@ type
120 121 procedure PresentPoints(A, B, I, G : TLabel);
121 122 procedure PresentPoints(APlayerBox: TPlayerBox; G: TLabel); overload;
122 123 property ShouldPublishMessage : Boolean read GetShouldPublishMessage;
123   - property PlayerNicname : string read FNicname write FNicname;
  124 + property Prepend : string read FPrepend;
124 125 property AppendiceLossSingular : string read FAppendiceLossSingular;
125 126 property AppendiceLossPlural : string read FAppendiceLossPlural;
126 127 property AppendiceEarnSingular : string read FAppendiceEarnSingular;
... ... @@ -128,6 +129,7 @@ type
128 129 property AppendiceZero : string read FAppendiceZero;
129 130 property PrependLoss : string read FPrependLoss;
130 131 property PrependEarn : string read FPrependEarn;
  132 + property CsqString : string read GetCsqString;
131 133 property Style : TConsequenceStyle read FStyle;
132 134 property ConsequenseByPlayerID : TStringList read FConsequenceByPlayerID;
133 135 end;
... ... @@ -184,6 +186,7 @@ type
184 186 procedure Clean;override;
185 187 property Question: string read FPromptMessage;
186 188 property PromptResult:string read FResult;
  189 + property PromptStyle : TPromptStyle read FPromptStyle;
187 190  
188 191 end;
189 192  
... ... @@ -582,7 +585,7 @@ end;
582 585  
583 586 { TConsequence }
584 587  
585   -constructor TConsequence.Create(AOwner: TComponent; ACsqString, ANicname,
  588 +constructor TConsequence.Create(AOwner: TComponent; ACsqString, APrepend,
586 589 APrependLoss, AAppendiceLossSingular, AAppendiceLossPlural, APrependEarn,
587 590 AAppendiceEarnSingular, AAppendiceEarnPlural, AAppendiceZero: string);
588 591 var
... ... @@ -591,7 +594,7 @@ begin
591 594 inherited Create(AOwner);
592 595  
593 596 // custom message
594   - FNicname:=ANicname;
  597 + FPrepend:=APrepend;
595 598 FPrependLoss:=APrependLoss;
596 599 FAppendiceLossSingular:=AAppendiceLossSingular;
597 600 FAppendiceLossPlural:=AAppendiceLossPlural;
... ... @@ -619,7 +622,7 @@ begin
619 622 inherited Create(AOwner);
620 623 FP := TGamePoint.Create(AOwner,AP);
621 624 FStyle:=AStyle;
622   - FNicname:=AMessage[0];
  625 + FPrepend:=AMessage[0];
623 626 FPrependLoss:=AMessage[1];
624 627 FAppendiceLossSingular:=AMessage[2];
625 628 FAppendiceLossPlural:=AMessage[3];
... ... @@ -637,7 +640,7 @@ begin
637 640 inherited Create(AOwner);
638 641 FP := TGamePoint.Create(AOwner,ExtractDelimited(1,AConsequenceString,['|']));
639 642 FStyle:=GetConsequenceStyleFromString(ExtractDelimited(2,AConsequenceString,['|']));
640   - FNicname:=ExtractDelimited(3,AConsequenceString,['|']);
  643 + FPrepend:=ExtractDelimited(3,AConsequenceString,['|']);
641 644 FPrependLoss:=ExtractDelimited(4,AConsequenceString,['|']);
642 645 FAppendiceLossSingular:=ExtractDelimited(5,AConsequenceString,['|']);
643 646 FAppendiceLossPlural:=ExtractDelimited(6,AConsequenceString,['|']);
... ... @@ -664,7 +667,7 @@ function TConsequence.AsString(AID: string): string;
664 667 begin
665 668 Result := IntToStr(FP.ValueWithVariation) + '|';
666 669 Result += GetConsequenceStyleString(FStyle)+'|';
667   - Result += FNicname +'|';
  670 + Result += FPrepend +'|';
668 671 Result += FPrependLoss + '|';
669 672 Result += FAppendiceLossSingular + '|';
670 673 Result += FAppendiceLossPlural + '|';
... ... @@ -678,7 +681,7 @@ end;
678 681  
679 682 function TConsequence.GenerateMessage(ForGroup: Boolean): string;
680 683 begin
681   - Result := FP.PointMessage(FNicname,FPrependLoss,FAppendiceLossSingular,FAppendiceLossPlural,
  684 + Result := FP.PointMessage(FPrepend,FPrependLoss,FAppendiceLossSingular,FAppendiceLossPlural,
682 685 FPrependEarn,FAppendiceEarnSingular,FAppendiceEarnPlural,FAppendiceZero, ForGroup);
683 686 FMessage.Text := Result;
684 687 end;
... ... @@ -738,6 +741,12 @@ begin
738 741 Result := gscBroadcastMessage in FStyle;
739 742 end;
740 743  
  744 +function TConsequence.GetCsqString: string;
  745 +begin
  746 + Result := IntToStr(FP.Value)+','+IntToStr(FP.Variation) + '|';
  747 + Result += GetConsequenceStyleString(FStyle);
  748 +end;
  749 +
741 750 procedure TConsequence.StopTimer(Sender: TObject; var ACloseAction: TCloseAction
742 751 );
743 752 begin
... ...
units/game_actors_point.pas
... ... @@ -35,7 +35,8 @@ type
35 35 function PointMessage(APrepend, APrependLoss, AAppendiceLossSingular,AAppendiceLossPlural,
36 36 APrependEarn,AAppendiceEarnSingular,AAppendiceEarnPlural,AAppendiceZero: string; IsGroupPoint: Boolean) : string;
37 37 property ValueWithVariation : integer read GetValue write FValue;
38   - property Variation : integer read FVariation write FVariation;
  38 + property Value : integer read FValue;
  39 + property Variation : integer read FVariation;
39 40 property AsString : string read GetResultAsString;
40 41 property ResultAsInteger : integer read GetResult;
41 42 end;
... ...
units/game_experiment.pas
... ... @@ -46,7 +46,7 @@ type
46 46 FShowChat: Boolean;
47 47 FMatrixType: TGameMatrixType;
48 48 private
49   - FAppPath,
  49 + FExperimentPath,
50 50 FLastReportColNames : string;
51 51 FRegData : TRegData;
52 52 FRegChat : TRegData;
... ... @@ -719,7 +719,7 @@ var
719 719 c,i: integer;
720 720 LRow : string;
721 721 begin
722   - if Assigned(FRegData) then
  722 + if Assigned(FRegData) and Assigned(Condition[c].Prompt) then
723 723 begin
724 724 c := CurrentCondition;
725 725 LRow := '';
... ... @@ -750,15 +750,13 @@ constructor TExperiment.Create(AOwner: TComponent);
750 750 begin
751 751 inherited Create(AOwner);
752 752 FTurnsRandom := TStringList.Create;
753   - LoadExperimentFromResource(Self);
754   - CheckNeedForRandomTurns;
755 753 end;
756 754  
757 755 constructor TExperiment.Create(AOwner: TComponent;AppPath:string);
758 756 var LDataPath : string;
759 757 begin
760 758 inherited Create(AOwner);
761   - FAppPath := AppPath;
  759 + FExperimentPath := AppPath;
762 760 FTurnsRandom := TStringList.Create;
763 761 //LoadExperimentFromResource(Self);
764 762 //LDataPath := AppPath+VAL_RESEARCHER+'es'+PathDelim+Researcher+PathDelim+ExperimentName+PathDelim;
... ... @@ -804,8 +802,8 @@ begin
804 802 if Result then
805 803 FFilename := AFilename
806 804 else Exit;
807   -
808   - LDataPath := FAppPath+VAL_RESEARCHER+'es'+PathDelim+Researcher+PathDelim+ExperimentName+PathDelim;
  805 + FExperimentPath := ExtractFilePath(FFilename);
  806 + LDataPath := FExperimentPath+ExperimentName+PathDelim;
809 807  
810 808 SetTargetInterlockingEvent;
811 809 SetContingenciesEvents;
... ... @@ -816,7 +814,7 @@ begin
816 814 FReportReader.UseRange:=True;
817 815 FReportReader.SetXLastRows(Condition[CurrentCondition].EndCriterium.LastCycles);
818 816  
819   - FRegData := TRegData.Create(Self, LDataPath+'000.dat');
  817 + FRegData := TRegData.Create(Self, LDataPath+'000.data');
820 818 FRegChat := TRegData.Create(Self, LDataPath+'000.chat');
821 819 WriteReportHeader;
822 820 end;
... ... @@ -943,7 +941,8 @@ begin
943 941 for i := 0 to ContingenciesCount[c]-1 do
944 942 Contingency[c,i].Clean;
945 943  
946   - Condition[c].Prompt.Clean;
  944 + if Assigned(Condition[c].Prompt) then
  945 + Condition[c].Prompt.Clean;
947 946  
948 947 FRegData.CloseAndOpen;
949 948 end;
... ...
units/game_file_methods.pas
... ... @@ -20,7 +20,7 @@ uses
20 20  
21 21  
22 22 function LoadExperimentFromResource(var AExperiment: TExperiment):Boolean;
23   - function LoadExperimentFromFile(var AExperiment: TExperiment; AFilename : string):Boolean;
  23 + function LoadExperimentFromFile(AExperiment: TExperiment; AFilename : string):Boolean;
24 24 procedure SaveExperimentToFile(AExperiment: TExperiment; AFilename : string);
25 25  
26 26 resourcestring
... ... @@ -145,7 +145,7 @@ begin
145 145 end;
146 146 end;
147 147  
148   -function LoadExperimentFromFile(var AExperiment: TExperiment; AFilename: string):Boolean;
  148 +function LoadExperimentFromFile(AExperiment: TExperiment; AFilename: string):Boolean;
149 149 var
150 150 LIniFile : TIniFile;
151 151 i: Integer;
... ... @@ -181,67 +181,76 @@ var
181 181 end;
182 182 end;
183 183  
184   - procedure ReadContingencies(ACondition:integer;IsMeta : Boolean);
  184 + function ReadContingenciesCount(ACondition: integer;LC_KEY:String):integer;
185 185 var
186   - i : integer;
187   - LS,LCK : string;
188   - LConsequence : TConsequence;
189   - LCriteria:TCriteria;
190   -
191   - procedure SetLCK(i:integer);
192   - begin
193   - if IsMeta then
194   - LCK := KEY_METACONTINGENCY+IntToStr(i+1)
195   - else
196   - LCK := KEY_CONTINGENCY+IntToStr(i+1);
197   - end;
  186 + LCK, LS: String;
198 187 begin
  188 + Result := 0;
199 189 LS := SEC_CONDITION+IntToStr(ACondition+1);
200   - i := AExperiment.AppendContingency(ACondition);
201   - SetLCK(i);
  190 + LCK := LC_KEY+IntToStr(Result+1);
202 191 with LIniFile do
203   - while ValueExists(LS, LCK+KEY_CONSEQUE) and ValueExists(LS, LCK+KEY_CRITERIA)do
  192 + while ValueExists(LS, LCK+KEY_CONT_NAME) and ValueExists(LS, LCK+KEY_CONSEQUE) and ValueExists(LS, LCK+KEY_CRITERIA)do
204 193 begin
205   - AExperiment.Condition[ACondition].Contingencies[i].ContingencyName := ReadString(LS, LCK+KEY_CONT_NAME, '');
206   - ReadString(LS, LCK+KEY_CONSEQUE, '');
207   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_PREPEND,'');
208   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_PREPEND_LOSS,'');
209   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_LOSS_S,'');
210   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_LOSS_P,'');
211   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_PREPEND_EARN,'');
212   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_EARN_S,'');
213   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_EARN_P,'');
214   - ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_ZERO, '');
215   -
216   -
217   - LConsequence := TConsequence.Create(AExperiment,
218   - ReadString(LS,LCK+KEY_CONSEQUE,DEF_CONSEQUENCE));
219   - LCriteria := GetCriteriaFromString(ReadString(LS, LCK+KEY_CRITERIA, ''));
220   - AExperiment.Condition[ACondition].Contingencies[i] := TContingency.Create(AExperiment,LConsequence,LCriteria,IsMeta);
221   - i := AExperiment.AppendContingency(ACondition);
222   - SetLCK(i);
  194 + Inc(Result);
  195 + LCK := LC_KEY+IntToStr(Result+1);
223 196 end;
224 197 end;
225 198  
  199 + function ReadContingency(AConditionIndex:integer; LCK:string) : TContingency;
  200 + var
  201 + LS : string;
  202 + LConsequence : TConsequence;
  203 + LCriteria:TCriteria;
  204 +
  205 + begin
  206 + LS := SEC_CONDITION+IntToStr(AConditionIndex+1);
  207 + with LIniFile do
  208 + begin
  209 + LConsequence := TConsequence.Create(AExperiment,
  210 + ReadString(LS, LCK+KEY_CONSEQUE, ''),
  211 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_PREPEND,''),
  212 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_PREPEND_LOSS,''),
  213 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_LOSS_S,''),
  214 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_LOSS_P,''),
  215 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_PREPEND_EARN,''),
  216 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_EARN_S,''),
  217 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_EARN_P,''),
  218 + ReadString(LS, LCK+KEY_CONSEQUE_MESSAGE_APPEND_ZERO, '')
  219 + );
  220 +
  221 + LCriteria := GetCriteriaFromString(ReadString(LS, LCK+KEY_CRITERIA, ''));
  222 + end;
  223 + Result := TContingency.Create(AExperiment,LConsequence,LCriteria,Pos(KEY_METACONTINGENCY,LCK)>0);
  224 + end;
  225 +
226 226 procedure ReadConditions;
227 227 var
228   - s1, LS : string;
229   - i : integer;
  228 + s1, LS , LPromptStyle, LPromptMessa: string;
  229 + i,j , LContingenciesCount, LMetaContingenCount: integer;
230 230 C :TCondition;
231 231 begin
232   - //i := 0;
233   - i := AExperiment.AppendCondition;
  232 + i := 0;
234 233 LS := SEC_CONDITION+IntToStr(i+1);
235 234 with LIniFile do
236 235 while SectionExists(LS) do
237 236 begin
238   - //if i = 0 then
239   - // i := AExperiment.AppendCondition;
240 237 with C do
241 238 begin
242 239 ConditionName := ReadString(LS,KEY_COND_NAME,LS);
243 240 Points.Count := GetPointsFromString(ReadString(LS, KEY_POINTS_COUNT,DEF_POINTS));
244   - Points.OnStart := GetPointsFromString(ReadString(LS, KEY_POINTS_ONSTART,DEF_POINTS));
  241 +
  242 + if AExperiment.ABPoints then
  243 + begin
  244 + Points.OnStart.A := ReadInteger(LS, KEY_POINTS_ONSTART_A,0);
  245 + Points.OnStart.B := ReadInteger(LS, KEY_POINTS_ONSTART_B,0);
  246 + Points.OnStart.G := ReadInteger(LS, KEY_POINTS_ONSTART_G,0);
  247 + end
  248 + else
  249 + begin
  250 + Points.OnStart.A := ReadInteger(LS, KEY_POINTS_ONSTART_I,0);
  251 + Points.OnStart.G := ReadInteger(LS, KEY_POINTS_ONSTART_G,0);
  252 + end;
  253 +
245 254 Turn.Count:= ReadInteger(LS, KEY_TURN_COUNT,0);
246 255 Turn.Value:= ReadInteger(LS, KEY_TURN_VALUE,2);
247 256 Turn.Random:= ReadBool(LS, KEY_TURN_RANDOM,False);
... ... @@ -254,19 +263,36 @@ var
254 263 EndCriterium.InterlockingPorcentage:= GetEndCriteriaPorcentageFromString(s1);
255 264 EndCriterium.LastCycles:= GetEndCriteriaLastCyclesFromString(s1);
256 265  
257   - ReadContingencies(i,True);
258   - ReadContingencies(i,False);
  266 + LContingenciesCount := ReadContingenciesCount(i,KEY_CONTINGENCY);
  267 + LMetaContingenCount := ReadContingenciesCount(i,KEY_METACONTINGENCY);
  268 +
  269 + if LContingenciesCount > 0 then
  270 + for j := 0 to LContingenciesCount-1 do
  271 + begin
  272 + SetLength(Contingencies,Length(Contingencies)+1);
  273 + Contingencies[Length(Contingencies)-1] := ReadContingency(i,KEY_CONTINGENCY+IntToStr(j+1));
  274 + end;
  275 +
  276 + if LMetaContingenCount > 0 then;
  277 + for j := 0 to LMetaContingenCount-1 do
  278 + begin
  279 + SetLength(Contingencies,Length(Contingencies)+1);
  280 + Contingencies[Length(Contingencies)-1] := ReadContingency(i,KEY_METACONTINGENCY+IntToStr(j+1));
  281 + end;
259 282  
260   - Prompt := TPrompt.Create(
261   - AExperiment
262   - , GetPromptStyleFromString(ReadString(LS,KEY_PROMPT_STYLE,''))
263   - , Contingencies
264   - , ReadString(LS,KEY_PROMPT_MESSAGE,'')
265   - );
  283 + LPromptStyle := ReadString(LS,KEY_PROMPT_STYLE,'');
  284 + LPromptMessa := ReadString(LS,KEY_PROMPT_MESSAGE,'');
266 285  
  286 + if (LPromptMessa <> '') and (LPromptStyle <> '') then
  287 + Prompt := TPrompt.Create(
  288 + AExperiment
  289 + , GetPromptStyleFromString(LPromptStyle)
  290 + , Contingencies
  291 + , LPromptMessa
  292 + );
267 293 end;
268   - AExperiment.Condition[i]:= C;
269   - i := AExperiment.AppendCondition;
  294 + AExperiment.Condition[AExperiment.AppendCondition]:= C;
  295 + Inc(i);
270 296 LS := SEC_CONDITION+IntToStr(i+1);
271 297 end;
272 298 end;
... ... @@ -290,11 +316,10 @@ var
290 316 Choice := GetChoiceFromString(ReadString(LS,KEY_PLAYER_CHOICE_LAST,'0,NONE,'));
291 317 ID := ReadString(LS,KEY_PLAYER_ID,'ID');
292 318 Nicname := ReadString(LS,KEY_PLAYER_NICNAME,GenResourceName(i));
293   -
  319 + Points := GetPPointsFromString(ReadString(LS,KEY_PLAYER_POINTS,'0,0,'));
294 320 // currently not in use
295 321 //Login := ReadString(LS,KEY_PLAYER_LOGIN,'jogador'+IntToStr(i+1));
296 322 //Password := ReadString(LS,KEY_PLAYER_PASSWORD,'1234');
297   - //Points := GetPPointsFromString(ReadString(LS,KEY_PLAYER_POINTS,'0,0,'));
298 323 //Status := GetStatusFromString(ReadString(LS,KEY_PLAYER_STATUS,'esperando'));
299 324 //Data.Values[KEY_PLAYER_TEMP] := ReadString(LS,KEY_PLAYER_TEMP,'');
300 325 end;
... ... @@ -312,7 +337,6 @@ begin
312 337 with LIniFile do
313 338 if SectionExists(SEC_EXPERIMENT) then
314 339 begin
315   - AExperiment := TExperiment.Create(AExperiment.Owner);
316 340 ReadExperiment;
317 341 ReadConditions;
318 342 ReadPlayers;
... ... @@ -325,21 +349,21 @@ begin
325 349 else
326 350 begin
327 351 ShowMessage(ERROR_NO_CONTINGENCIES+SEC_CONDITION+IntToStr(i+1));
  352 + LIniFile.Free;
328 353 Exit;
329 354 end
330 355 else
331 356 begin
332 357 ShowMessage(ERROR_NO_CONDITIONS);
  358 + LIniFile.Free;
333 359 Exit;
334 360 end;
335   -
336 361 Result := True;
  362 + AExperiment.CurrentCondition:=0;
337 363 end
338 364 else
339   - begin
340   - ShowMessage(ERROR_SECTION_NOT_FOUND+SEC_EXPERIMENT);
341   - Exit;
342   - end;
  365 + ShowMessage(ERROR_SECTION_NOT_FOUND+SEC_EXPERIMENT);
  366 +
343 367 LIniFile.Free;
344 368 end
345 369 else
... ... @@ -348,7 +372,7 @@ end;
348 372  
349 373 procedure SaveExperimentToFile(AExperiment: TExperiment; AFilename: string);
350 374 var
351   - i,j : Integer;
  375 + i,j , MI, CI: Integer;
352 376 LWriter : TRegData;
353 377 LIniFile : TIniFile;
354 378 LC,
... ... @@ -362,34 +386,59 @@ begin
362 386 LIniFile.WriteString(SEC_EXPERIMENT,KEY_RESEARCHER,AExperiment.Researcher);
363 387  
364 388 with LIniFile do
365   - for i := 0 to AExperiment.ConditionsCount do
  389 + for i := 0 to AExperiment.ConditionsCount-1 do
366 390 begin
367 391 LC := SEC_CONDITION+IntToStr(i+1);
368 392 with AExperiment.Condition[i] do
369 393 begin
370 394 WriteString(LC,KEY_ENDCRITERIA,GetEndCriteriaString(EndCriterium));
371 395 WriteString(LC, KEY_POINTS_COUNT,GetPointsString(Points.Count));
372   - WriteString(LC, KEY_POINTS_ONSTART,GetPointsString(Points.OnStart));
  396 + if AExperiment.ABPoints then
  397 + begin
  398 + WriteInteger(LC, KEY_POINTS_ONSTART_A,Points.OnStart.A);
  399 + WriteInteger(LC, KEY_POINTS_ONSTART_B,Points.OnStart.B);
  400 + WriteInteger(LC, KEY_POINTS_ONSTART_G,Points.OnStart.G);
  401 + end
  402 + else
  403 + begin
  404 + WriteInteger(LC, KEY_POINTS_ONSTART_I,Points.OnStart.A);
  405 + WriteInteger(LC, KEY_POINTS_ONSTART_G,Points.OnStart.G);
  406 + end;
373 407 WriteInteger(LC, KEY_TURN_COUNT,Turn.Count);
374 408 WriteInteger(LC, KEY_TURN_VALUE,Turn.Value);
375 409 WriteBool(LC, KEY_TURN_RANDOM,Turn.Random);
376 410 WriteInteger(LC, KEY_CYCLES_COUNT,Cycles.Count);
377 411 WriteInteger(LC, KEY_CYCLES_VALUE,Cycles.Value);
378 412 WriteInteger(LC, KEY_CYCLES_GEN,Cycles.Generation);
379   - //WriteBool(LC, KEY_PROMPT_VALUE,Prompt.Value);
380   - //WriteString(LC, KEY_PROMPT_MESSAGE, Prompt.PromptMessage);
381   - //WriteString(LC, KEY_PROMPT_STYLE, GetPromptStyleString(Prompt.PromptStyle));
  413 + WriteString(LC, KEY_PROMPT_MESSAGE, Prompt.Question);
  414 + WriteString(LC, KEY_PROMPT_STYLE, GetPromptStyleString(Prompt.PromptStyle));
382 415  
  416 + MI := 0;
  417 + CI := 0;
383 418 for j := 0 to High(Contingencies) do
384 419 begin
385 420 if Contingencies[j].Meta then
386   - LCK := KEY_METACONTINGENCY+IntToStr(j+1)
  421 + begin
  422 + LCK := KEY_METACONTINGENCY+IntToStr(MI+1);
  423 + Inc(MI);
  424 + end
387 425 else
388   - LCK := KEY_CONTINGENCY+IntToStr(j+1);
  426 + begin
  427 + LCK := KEY_CONTINGENCY+IntToStr(CI+1);
  428 + Inc(CI);
  429 + end;
389 430  
390 431 with Contingencies[j] do
391 432 begin
392   - WriteString(LC,LCK+KEY_CONSEQUE,Consequence.AsString(''));
  433 + WriteString(LC,LCK+KEY_CONSEQUE,Consequence.CsqString);
  434 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_PREPEND,Consequence.Prepend);
  435 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_PREPEND_LOSS,Consequence.PrependLoss);
  436 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_APPEND_LOSS_S,Consequence.AppendiceLossSingular);
  437 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_APPEND_LOSS_P,Consequence.AppendiceLossPlural);
  438 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_PREPEND_EARN,Consequence.PrependEarn);
  439 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_APPEND_EARN_S,Consequence.AppendiceEarnSingular);
  440 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_APPEND_EARN_P,Consequence.AppendiceEarnPlural);
  441 + WriteString(LC,LCK+KEY_CONSEQUE_MESSAGE_APPEND_ZERO, Consequence.AppendiceZero);
393 442 WriteString(LC,LCK+KEY_CRITERIA,CriteriaString);
394 443 end;
395 444 end;
... ... @@ -397,20 +446,21 @@ begin
397 446 end;
398 447  
399 448 with LIniFile do
400   - for i:=0 to AExperiment.PlayersCount do
401   - with AExperiment.Player[i] do
402   - begin
403   - LC := SEC_PLAYER+IntToStr(i+1);
404   - WriteInteger(LC,KEY_PLAYER_TURN,AExperiment.Player[i].Turn);
405   - WriteString(LC,KEY_PLAYER_CHOICE_LAST,GetChoiceString(AExperiment.Player[i].Choice));
406   - WriteString(LC,KEY_PLAYER_ID,AExperiment.Player[i].ID);
407   - WriteString(LC,KEY_PLAYER_NICNAME,AExperiment.Player[i].Nicname);
408   - WriteString(LC,KEY_PLAYER_LOGIN,AExperiment.Player[i].Login);
409   - WriteString(LC,KEY_PLAYER_PASSWORD,AExperiment.Player[i].Password);
410   - WriteString(LC,KEY_PLAYER_POINTS,GetPPointsString(AExperiment.Player[i].Points));
411   - WriteString(LC,KEY_PLAYER_STATUS,GetStatusString(AExperiment.Player[i].Status));
412   - WriteString(LC,KEY_PLAYER_TEMP,AExperiment.Player[i].Data.Values[KEY_PLAYER_TEMP]);
413   - end;
  449 + if AExperiment.PlayersCount > 0 then
  450 + for i:=0 to AExperiment.PlayersCount-1 do
  451 + with AExperiment.Player[i] do
  452 + begin
  453 + LC := SEC_PLAYER+IntToStr(i+1);
  454 + WriteString(LC,KEY_PLAYER_ID,AExperiment.Player[i].ID);
  455 + WriteString(LC,KEY_PLAYER_NICNAME,AExperiment.Player[i].Nicname);
  456 + WriteInteger(LC,KEY_PLAYER_TURN,AExperiment.Player[i].Turn);
  457 + WriteString(LC,KEY_PLAYER_CHOICE_LAST,GetChoiceString(AExperiment.Player[i].Choice));
  458 + WriteString(LC,KEY_PLAYER_POINTS,GetPPointsString(AExperiment.Player[i].Points));
  459 + //WriteString(LC,KEY_PLAYER_LOGIN,AExperiment.Player[i].Login);
  460 + //WriteString(LC,KEY_PLAYER_PASSWORD,AExperiment.Player[i].Password);
  461 + //WriteString(LC,KEY_PLAYER_STATUS,GetStatusString(AExperiment.Player[i].Status));
  462 + //WriteString(LC,KEY_PLAYER_TEMP,AExperiment.Player[i].Data.Values[KEY_PLAYER_TEMP]);
  463 + end;
414 464 end;
415 465  
416 466 end.
... ...