Commit 15518a428a79a1d489f2e00f49219287c5ef526a

Authored by Carlos Picanco
1 parent f214aa24
Exists in master

change compilation rule, bug fixes and improvements

- need to investigate why we getting Runtime 216 errors when compiling with optimization 3
- fix harcoded value on function TGameControl.ShouldAskQuestion
- increase system messages time to 15000 ms
- show system message on start turn
- add 'KEY_CHAT_FOR_PLAYERS' key for disabling chat for players and admins on Runner, need to update Designer
- add fullscreen on player login
- fix bug on loading key 'KEY_CYCLES_GEN'
- need to test save, resume and cancel experiment
experiment_runner/experiment_runner.lpi
... ... @@ -14,7 +14,11 @@
14 14 <EnableI18N LFM="False"/>
15 15 </i18n>
16 16 <VersionInfo>
17   - <StringTable ProductVersion=""/>
  17 + <UseVersionInfo Value="True"/>
  18 + <AutoIncrementBuild Value="True"/>
  19 + <MinorVersionNr Value="1"/>
  20 + <Language Value="0416"/>
  21 + <StringTable Comments="https://github.com/lacs-ufpa/free-mtrix" CompanyName="Laboratório de Comportamento Social e Seleção Cultural" FileDescription="Experimentos livres de seleção cultural e comportamento social." LegalCopyright="Copyright (C) Carlos Rafael Fernandes Picanço, Universidade Federal do Pará." OriginalFilename="experiment_runner" ProductName="Free-mtrix" ProductVersion="0.1.0"/>
18 22 </VersionInfo>
19 23 <BuildModes Count="4">
20 24 <Item1 Name="Linux 64 Debug" Default="True"/>
... ... @@ -30,18 +34,10 @@
30 34 <OtherUnitFiles Value="units;../dependencies/delphizmq"/>
31 35 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
32 36 </SearchPaths>
33   - <CodeGeneration>
34   - <SmartLinkUnit Value="True"/>
35   - <Optimizations>
36   - <OptimizationLevel Value="3"/>
37   - </Optimizations>
38   - </CodeGeneration>
39 37 <Linking>
40 38 <Debugging>
41   - <GenerateDebugInfo Value="False"/>
42   - <StripSymbols Value="True"/>
  39 + <UseExternalDbgSyms Value="True"/>
43 40 </Debugging>
44   - <LinkSmart Value="True"/>
45 41 <Options>
46 42 <Win32>
47 43 <GraphicApplication Value="True"/>
... ... @@ -86,18 +82,10 @@
86 82 <OtherUnitFiles Value="units;../dependencies/delphizmq"/>
87 83 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
88 84 </SearchPaths>
89   - <CodeGeneration>
90   - <SmartLinkUnit Value="True"/>
91   - <Optimizations>
92   - <OptimizationLevel Value="4"/>
93   - </Optimizations>
94   - </CodeGeneration>
95 85 <Linking>
96 86 <Debugging>
97   - <GenerateDebugInfo Value="False"/>
98   - <StripSymbols Value="True"/>
  87 + <UseExternalDbgSyms Value="True"/>
99 88 </Debugging>
100   - <LinkSmart Value="True"/>
101 89 <Options>
102 90 <Win32>
103 91 <GraphicApplication Value="True"/>
... ...
experiment_runner/form_matrixgame.lfm
... ... @@ -7,7 +7,7 @@ object FormMatrixGame: TFormMatrixGame
7 7 VertScrollBar.Page = 542
8 8 AutoScroll = True
9 9 Caption = 'Matrix'
10   - ClientHeight = 609
  10 + ClientHeight = 616
11 11 ClientWidth = 1167
12 12 Font.Name = 'Monospace'
13 13 OnActivate = FormActivate
... ... @@ -16,24 +16,24 @@ object FormMatrixGame: TFormMatrixGame
16 16 AnchorSideLeft.Control = GBIndividualAB
17 17 AnchorSideTop.Control = GBIndividualAB
18 18 Left = 800
19   - Height = 131
  19 + Height = 122
20 20 Top = 8
21   - Width = 162
  21 + Width = 170
22 22 AutoSize = True
23 23 Caption = 'Pontuação Individual'
24 24 ChildSizing.LeftRightSpacing = 35
25 25 ChildSizing.TopBottomSpacing = 45
26 26 ChildSizing.Layout = cclLeftToRightThenTopToBottom
27 27 ChildSizing.ControlsPerLine = 1
28   - ClientHeight = 108
29   - ClientWidth = 158
  28 + ClientHeight = 105
  29 + ClientWidth = 166
30 30 TabOrder = 7
31 31 Visible = False
32 32 object LabelIndCount: TLabel
33 33 Left = 35
34   - Height = 18
  34 + Height = 15
35 35 Top = 45
36   - Width = 88
  36 + Width = 96
37 37 Align = alClient
38 38 Alignment = taCenter
39 39 AutoSize = False
... ... @@ -71,9 +71,9 @@ object FormMatrixGame: TFormMatrixGame
71 71 end
72 72 object GBIndividualAB: TGroupBox
73 73 Left = 800
74   - Height = 135
  74 + Height = 122
75 75 Top = 8
76   - Width = 162
  76 + Width = 170
77 77 AutoSize = True
78 78 Caption = 'Pontuação Individual'
79 79 ChildSizing.LeftRightSpacing = 10
... ... @@ -83,14 +83,14 @@ object FormMatrixGame: TFormMatrixGame
83 83 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
84 84 ChildSizing.Layout = cclLeftToRightThenTopToBottom
85 85 ChildSizing.ControlsPerLine = 2
86   - ClientHeight = 112
87   - ClientWidth = 158
  86 + ClientHeight = 105
  87 + ClientWidth = 166
88 88 TabOrder = 1
89 89 object LabelIndA: TLabel
90 90 Left = 10
91   - Height = 19
  91 + Height = 15
92 92 Top = 30
93   - Width = 59
  93 + Width = 63
94 94 Alignment = taCenter
95 95 AutoSize = False
96 96 Caption = 'A'
... ... @@ -103,10 +103,10 @@ object FormMatrixGame: TFormMatrixGame
103 103 Transparent = False
104 104 end
105 105 object LabelIndB: TLabel
106   - Left = 89
107   - Height = 19
  106 + Left = 93
  107 + Height = 15
108 108 Top = 30
109   - Width = 59
  109 + Width = 63
110 110 Alignment = taCenter
111 111 AutoSize = False
112 112 Caption = 'B'
... ... @@ -120,9 +120,9 @@ object FormMatrixGame: TFormMatrixGame
120 120 end
121 121 object LabelIndACount: TLabel
122 122 Left = 10
123   - Height = 18
124   - Top = 64
125   - Width = 59
  123 + Height = 15
  124 + Top = 60
  125 + Width = 63
126 126 Alignment = taCenter
127 127 AutoSize = False
128 128 Caption = '0'
... ... @@ -131,10 +131,10 @@ object FormMatrixGame: TFormMatrixGame
131 131 Transparent = False
132 132 end
133 133 object LabelIndBCount: TLabel
134   - Left = 89
135   - Height = 18
136   - Top = 64
137   - Width = 59
  134 + Left = 93
  135 + Height = 15
  136 + Top = 60
  137 + Width = 63
138 138 Alignment = taCenter
139 139 AutoSize = False
140 140 Caption = '0'
... ... @@ -147,10 +147,10 @@ object FormMatrixGame: TFormMatrixGame
147 147 AnchorSideLeft.Control = GBIndividualAB
148 148 AnchorSideLeft.Side = asrBottom
149 149 AnchorSideTop.Control = GBIndividualAB
150   - Left = 972
151   - Height = 131
  150 + Left = 980
  151 + Height = 122
152 152 Top = 8
153   - Width = 171
  153 + Width = 170
154 154 AutoSize = True
155 155 BorderSpacing.Left = 10
156 156 Caption = ' Pontuação do Grupo '
... ... @@ -158,14 +158,14 @@ object FormMatrixGame: TFormMatrixGame
158 158 ChildSizing.TopBottomSpacing = 45
159 159 ChildSizing.Layout = cclLeftToRightThenTopToBottom
160 160 ChildSizing.ControlsPerLine = 1
161   - ClientHeight = 108
162   - ClientWidth = 167
  161 + ClientHeight = 105
  162 + ClientWidth = 166
163 163 TabOrder = 2
164 164 object LabelGroupCount: TLabel
165 165 Left = 35
166   - Height = 18
  166 + Height = 15
167 167 Top = 45
168   - Width = 97
  168 + Width = 96
169 169 Align = alClient
170 170 Alignment = taCenter
171 171 AutoSize = False
... ... @@ -183,9 +183,9 @@ object FormMatrixGame: TFormMatrixGame
183 183 AnchorSideBottom.Control = Owner
184 184 AnchorSideBottom.Side = asrBottom
185 185 Left = 0
186   - Height = 22
187   - Top = 587
188   - Width = 1625
  186 + Height = 17
  187 + Top = 599
  188 + Width = 1632
189 189 Anchors = [akLeft, akRight, akBottom]
190 190 AutoSize = True
191 191 Caption = 'Escolhas na última jogada'
... ... @@ -200,21 +200,21 @@ object FormMatrixGame: TFormMatrixGame
200 200 AnchorSideLeft.Control = GBGrupo
201 201 AnchorSideLeft.Side = asrBottom
202 202 AnchorSideTop.Control = GBGrupo
203   - Left = 1153
  203 + Left = 1160
204 204 Height = 486
205 205 Top = 8
206 206 Width = 472
207 207 BorderSpacing.Left = 10
208 208 Caption = 'Pesquisador'
209   - ClientHeight = 463
  209 + ClientHeight = 469
210 210 ClientWidth = 468
211 211 TabOrder = 4
212 212 Visible = False
213 213 object GBExperiment: TGroupBox
214 214 Left = 16
215   - Height = 221
  215 + Height = 197
216 216 Top = 60
217   - Width = 220
  217 + Width = 228
218 218 AutoSize = True
219 219 Caption = 'Experimento'
220 220 ChildSizing.LeftRightSpacing = 10
... ... @@ -224,102 +224,102 @@ object FormMatrixGame: TFormMatrixGame
224 224 ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
225 225 ChildSizing.Layout = cclLeftToRightThenTopToBottom
226 226 ChildSizing.ControlsPerLine = 2
227   - ClientHeight = 198
228   - ClientWidth = 216
  227 + ClientHeight = 180
  228 + ClientWidth = 224
229 229 TabOrder = 0
230 230 object LabelExpCond: TLabel
231 231 Left = 10
232   - Height = 18
  232 + Height = 15
233 233 Top = 20
234   - Width = 154
  234 + Width = 168
235 235 Caption = 'Condição:'
236 236 ParentColor = False
237 237 end
238 238 object LabelExpCountCondition: TLabel
239   - Left = 184
240   - Height = 18
  239 + Left = 198
  240 + Height = 15
241 241 Top = 20
242   - Width = 22
  242 + Width = 16
243 243 Caption = 'NA'
244 244 ParentColor = False
245 245 end
246 246 object LabelExpGen: TLabel
247 247 Left = 10
248   - Height = 18
249   - Top = 48
250   - Width = 154
  248 + Height = 15
  249 + Top = 45
  250 + Width = 168
251 251 Caption = 'Geração:'
252 252 ParentColor = False
253 253 end
254 254 object LabelExpCountGeneration: TLabel
255   - Left = 184
256   - Height = 18
257   - Top = 48
258   - Width = 22
  255 + Left = 198
  256 + Height = 15
  257 + Top = 45
  258 + Width = 16
259 259 Caption = 'NA'
260 260 ParentColor = False
261 261 end
262 262 object LabelExpCycle: TLabel
263 263 Left = 10
264   - Height = 18
265   - Top = 76
266   - Width = 154
  264 + Height = 15
  265 + Top = 70
  266 + Width = 168
267 267 Caption = 'Ciclo:'
268 268 ParentColor = False
269 269 end
270 270 object LabelExpCountCycle: TLabel
271   - Left = 184
272   - Height = 18
273   - Top = 76
274   - Width = 22
  271 + Left = 198
  272 + Height = 15
  273 + Top = 70
  274 + Width = 16
275 275 Caption = 'NA'
276 276 ParentColor = False
277 277 end
278 278 object LabelExpTurn: TLabel
279 279 Left = 10
280   - Height = 18
281   - Top = 104
282   - Width = 154
  280 + Height = 15
  281 + Top = 95
  282 + Width = 168
283 283 Caption = 'Turno:'
284 284 ParentColor = False
285 285 end
286 286 object LabelExpCountTurn: TLabel
287   - Left = 184
288   - Height = 18
289   - Top = 104
290   - Width = 22
  287 + Left = 198
  288 + Height = 15
  289 + Top = 95
  290 + Width = 16
291 291 Caption = 'NA'
292 292 ParentColor = False
293 293 end
294 294 object LabelExpInterlocks: TLabel
295 295 Left = 10
296   - Height = 18
297   - Top = 132
298   - Width = 154
  296 + Height = 15
  297 + Top = 120
  298 + Width = 168
299 299 Caption = 'Entrelaçamentos:'
300 300 ParentColor = False
301 301 end
302 302 object LabelExpCountInterlocks: TLabel
303   - Left = 184
304   - Height = 18
305   - Top = 132
306   - Width = 22
  303 + Left = 198
  304 + Height = 15
  305 + Top = 120
  306 + Width = 16
307 307 Caption = 'NA'
308 308 ParentColor = False
309 309 end
310 310 object LabelExpTInterlocks: TLabel
311 311 Left = 10
312   - Height = 18
313   - Top = 160
314   - Width = 154
  312 + Height = 15
  313 + Top = 145
  314 + Width = 168
315 315 Caption = 'Entrelaçamentos Alvo:'
316 316 ParentColor = False
317 317 end
318 318 object LabelExpCountTInterlocks: TLabel
319   - Left = 184
320   - Height = 18
321   - Top = 160
322   - Width = 22
  319 + Left = 198
  320 + Height = 15
  321 + Top = 145
  322 + Width = 16
323 323 Caption = 'NA'
324 324 ParentColor = False
325 325 end
... ... @@ -372,19 +372,19 @@ object FormMatrixGame: TFormMatrixGame
372 372 AnchorSideRight.Side = asrBottom
373 373 Left = 800
374 374 Height = 354
375   - Top = 153
376   - Width = 343
  375 + Top = 140
  376 + Width = 350
377 377 Anchors = [akTop, akLeft, akRight]
378 378 BorderSpacing.Top = 10
379 379 ClientHeight = 354
380   - ClientWidth = 343
  380 + ClientWidth = 350
381 381 TabOrder = 6
382 382 object ChatMemoRecv: TMemo
383 383 AnchorSideBottom.Control = ChatSplitter
384 384 Left = 6
385 385 Height = 221
386 386 Top = 6
387   - Width = 331
  387 + Width = 338
388 388 Align = alTop
389 389 Anchors = [akTop, akLeft, akRight, akBottom]
390 390 BorderSpacing.Left = 5
... ... @@ -405,7 +405,7 @@ object FormMatrixGame: TFormMatrixGame
405 405 Left = 0
406 406 Height = 5
407 407 Top = 232
408   - Width = 341
  408 + Width = 348
409 409 Align = alNone
410 410 Anchors = [akLeft, akRight]
411 411 ResizeAnchor = akTop
... ... @@ -416,7 +416,7 @@ object FormMatrixGame: TFormMatrixGame
416 416 Left = 6
417 417 Height = 106
418 418 Top = 242
419   - Width = 331
  419 + Width = 338
420 420 Align = alBottom
421 421 Anchors = [akTop, akLeft, akRight, akBottom]
422 422 BorderSpacing.Around = 5
... ... @@ -439,7 +439,7 @@ object FormMatrixGame: TFormMatrixGame
439 439 top = 360
440 440 end
441 441 object PopupNotifier: TPopupNotifier
442   - Color = clTeal
  442 + Color = clDefault
443 443 Icon.Data = {
444 444 07544269746D617000000000
445 445 }
... ...
experiment_runner/form_matrixgame.pas
... ... @@ -80,6 +80,7 @@ type
80 80 public
81 81 procedure SetID(S : string);
82 82 procedure SetGameActor(AValue: TGameActor);
  83 + procedure SetFullscreen;
83 84 property ID : string read FID;
84 85 end;
85 86  
... ... @@ -248,6 +249,17 @@ begin
248 249 end;
249 250 end;
250 251  
  252 +procedure TFormMatrixGame.SetFullscreen;
  253 +begin
  254 + BorderStyle:=bsNone;
  255 + {$IFDEF WINDOWS}
  256 + BoundsRect := Monitor.BoundsRect;
  257 + {$ENDIF}
  258 + Position:=poDesigned;
  259 + FormStyle:=fsNormal;
  260 + WindowState:=wsFullScreen;
  261 +end;
  262 +
251 263 procedure TFormMatrixGame.SetID(S: string);
252 264 begin
253 265 FID := S;
... ... @@ -256,6 +268,7 @@ end;
256 268  
257 269 procedure TFormMatrixGame.FormActivate(Sender: TObject);
258 270 begin
  271 + PopupNotifier.Icon.Assign(Application.Icon);
259 272 if not Assigned(FGameControl) then
260 273 begin
261 274 FormChooseActor := TFormChooseActor.Create(Self);
... ... @@ -319,15 +332,15 @@ begin
319 332 ButtonExpStart.Caption := CAPTION_START;
320 333 ButtonExpCancel.Enabled := not ButtonExpStart.Enabled;
321 334 ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
322   - //FGameControl.Experiment.SaveToFile(SaveDialog.FileName'.canceled');
323   - //FGameControl.Experiment.Clean;
  335 + FGameControl.Experiment.SaveToFile(OpenDialog.FileName+'.canceled');
  336 + FGameControl.SendMessage(K_END);
324 337 end;
325 338  
326 339 procedure TFormMatrixGame.ButtonExpPauseClick(Sender: TObject);
327 340 begin
328   - ButtonExpStart.Enabled := True;
329   - ButtonExpStart.Caption := CAPTION_RESUME;
330   - ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
  341 + //ButtonExpStart.Enabled := True;
  342 + //ButtonExpStart.Caption := CAPTION_RESUME;
  343 + //ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
331 344 //FGameControl.Pause;
332 345 end;
333 346  
... ... @@ -344,7 +357,7 @@ begin
344 357 ButtonExpStart.Caption := CAPTION_RUNNING;
345 358 ButtonExpCancel.Enabled := not ButtonExpStart.Enabled;
346 359 ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
347   -
  360 + ChatPanel.Visible := FGameControl.Experiment.ShowChat;
348 361 end;
349 362  
350 363 if ButtonExpStart.Caption = CAPTION_RESUME then
... ... @@ -353,7 +366,7 @@ begin
353 366 ButtonExpStart.Caption := CAPTION_RUNNING;
354 367 ButtonExpCancel.Enabled := not ButtonExpStart.Enabled;
355 368 ButtonExpPause.Enabled := not ButtonExpStart.Enabled;
356   - //FGameControl.Resume;
  369 + FGameControl.Resume;
357 370 end;
358 371 end;
359 372  
... ...
experiment_runner/lib/x86_64-linux/experiment_runner.compiled
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <CONFIG>
3 3 <Compiler Value="/usr/bin/fpc" Date="1449313866"/>
4   - <Params Value=" -MObjFPC -Scghi -CX -Cg -O3 -Xs -XX -l -vewnhibq -Fi/home/rafael/git/sc_split/experiment_runner/lib/x86_64-linux -Fl/usr/lib/gcc/x86_64-linux-gnu/4.9 -Fl/opt/gnome/lib -Fu/home/rafael/git/sc_split/experiment_runner/units -Fu/home/rafael/git/sc_split/dependencies/delphizmq -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.6.2/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.6.2/packager/units/x86_64-linux -Fu/home/rafael/git/sc_split/experiment_runner/ -FU/home/rafael/git/sc_split/experiment_runner/lib/x86_64-linux/ -dLCL -dLCLgtk2 -dUseCThreads experiment_runner.lpr"/>
  4 + <Params Value=" -MObjFPC -Scghi -Cg -O1 -g -gl -Xg -l -vewnhibq -Fi/home/rafael/git/sc_split/experiment_runner/lib/x86_64-linux -Fl/usr/lib/gcc/x86_64-linux-gnu/4.9 -Fl/opt/gnome/lib -Fu/home/rafael/git/sc_split/experiment_runner/units -Fu/home/rafael/git/sc_split/dependencies/delphizmq -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux/gtk2 -Fu/usr/share/lazarus/1.6.2/lcl/units/x86_64-linux -Fu/usr/share/lazarus/1.6.2/components/lazutils/lib/x86_64-linux -Fu/usr/share/lazarus/1.6.2/packager/units/x86_64-linux -Fu/home/rafael/git/sc_split/experiment_runner/ -FU/home/rafael/git/sc_split/experiment_runner/lib/x86_64-linux/ -dLCL -dLCLgtk2 -dUseCThreads experiment_runner.lpr"/>
5 5 </CONFIG>
... ...
experiment_runner/units/game_actors.pas
... ... @@ -442,7 +442,7 @@ end;
442 442  
443 443 procedure TPrompt.ClearResponses;
444 444 begin
445   - FResponses := nil;
  445 + SetLength(FResponses,0);
446 446 end;
447 447  
448 448 constructor TPrompt.Create(AOwner: TComponent; APStyle: TPromptStyle;
... ... @@ -473,7 +473,7 @@ end;
473 473 procedure TPrompt.Clean;
474 474 begin
475 475 //inherited Clean;
476   - FResponses := nil;
  476 + SetLength(FResponses,0);
477 477 end;
478 478  
479 479 function TPrompt.AsString: TStringList;
... ...
experiment_runner/units/game_control.pas
... ... @@ -53,7 +53,7 @@ type
53 53 private
54 54 function AskQuestion(AQuestion:string):UTF8string;
55 55 function ShowConsequence(AID,S:string;ForGroup:Boolean;ShowPopUp : Boolean = True) : string;
56   - procedure ShowPopUp(AText:string;AInterval : integer = 5000);
  56 + procedure ShowPopUp(AText:string;AInterval : integer = 15000);
57 57 procedure DisableConfirmationButton;
58 58 procedure CleanMatrix(AEnabled : Boolean);
59 59 procedure NextConditionSetup(S : string);
... ... @@ -137,6 +137,7 @@ const
137 137 function GetRowColor(ARow: integer; ARowBase:integer): TColor;
138 138 var LRow : integer;
139 139 begin
  140 + Result := 0;
140 141 if ARowBase = 1 then
141 142 LRow := aRow -1
142 143 else LRow := aRow;
... ... @@ -179,7 +180,7 @@ end;
179 180  
180 181 function TGameControl.ShouldAskQuestion: Boolean;
181 182 begin
182   - Result := Assigned(FExperiment.Condition[FExperiment.CurrentCondition].Prompt) and FExperiment.Condition[FExperiment.CurrentCondition].Contingencies[3].Fired;
  183 + Result := Assigned(FExperiment.Condition[FExperiment.CurrentCondition].Prompt) and FExperiment.TargetIntelockingFired;
183 184 end;
184 185  
185 186 procedure TGameControl.EndExperiment(Sender: TObject);
... ... @@ -298,9 +299,8 @@ end;
298 299  
299 300 procedure TGameControl.Stop;
300 301 begin
301   - // Pause
302   -
303 302 // cleaning
  303 + FExperiment.Clean;
304 304 end;
305 305  
306 306 function TGameControl.GetPlayerBox(AID: UTF8string): TPlayerBox;
... ... @@ -317,6 +317,7 @@ end;
317 317  
318 318 function TGameControl.GetActorNicname(AID: UTF8string): UTF8string;
319 319 begin
  320 + Result := '';
320 321 case FActor of
321 322 gaPlayer: begin
322 323 Result := 'UNKNOWN';
... ... @@ -501,8 +502,8 @@ end;
501 502 procedure TGameControl.ShowPopUp(AText: string; AInterval: integer);
502 503 var PopUpPos : TPoint;
503 504 begin
504   - PopUpPos.X := FormMatrixGame.GBIndividualAB.Left-110;
505   - PopUpPos.Y := FormMatrixGame.GBIndividualAB.Top+FormMatrixGame.GBIndividual.Height-10;
  505 + PopUpPos.X := (FormMatrixGame.StringGridMatrix.Width div 2) - (FormMatrixGame.PopupNotifier.vNotifierForm.Width div 2);
  506 + PopUpPos.Y := (FormMatrixGame.StringGridMatrix.Height div 2) - (FormMatrixGame.PopupNotifier.vNotifierForm.Height div 2);
506 507 PopUpPos := FormMatrixGame.ClientToScreen(PopUpPos);
507 508 FormMatrixGame.PopupNotifier.Title:='';
508 509 FormMatrixGame.PopupNotifier.Text:=AText;
... ... @@ -609,7 +610,7 @@ begin
609 610 for P in FExperiment.Players do
610 611 begin
611 612 PB := GetPlayerBox(P.ID);
612   - A += StrToInt(PB.LabelPointsCount.Caption) + B;
  613 + A += StrToInt(PB.LabelPointsCount.Caption);
613 614 PB.LabelPointsCount.Caption := IntToStr(A);
614 615 end;
615 616 end;
... ... @@ -620,6 +621,9 @@ procedure TGameControl.EnablePlayerMatrix(AID:UTF8string; ATurn:integer; AEnable
620 621 begin
621 622 if FExperiment.PlayerFromID[AID].Turn = ATurn then
622 623 CleanMatrix(AEnabled);
  624 +
  625 + if AEnabled then
  626 + ShowPopUp('É sua vez! Clique sobre uma linha da matrix e confirme sua escolha.');
623 627 end;
624 628  
625 629 constructor TGameControl.Create(AOwner: TComponent;AppPath:string);
... ... @@ -681,6 +685,7 @@ var
681 685 M[i] := A[i];
682 686 end;
683 687 begin
  688 + SetLength(M,0);
684 689 case ARequest of
685 690 K_LOGIN :SetM([
686 691 FZMQActor.ID
... ... @@ -854,10 +859,7 @@ procedure TGameControl.ReceiveMessage(AMessage: TStringList);
854 859 case FActor of
855 860 gaPlayer:
856 861 if FExperiment.PlayerFromID[Self.ID].Turn = 0 then
857   - begin
858   - EnablePlayerMatrix(Self.ID, 0, True);
859   - ShowPopUp('É sua vez! Clique sobre uma linha da matrix e confirme sua escolha.');
860   - end
  862 + EnablePlayerMatrix(Self.ID, 0, True)
861 863 else
862 864 ShowPopUp('Começou! Aguarde sua vez.');
863 865  
... ... @@ -1055,7 +1057,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
1055 1057  
1056 1058 // check if we already know this player
1057 1059 i := FExperiment.PlayerIndexFromID[P.ID];
1058   - if i > -1then
  1060 + if i > -1 then
1059 1061 begin
1060 1062 // then load p data
1061 1063 P := FExperiment.Player[i]
... ... @@ -1105,11 +1107,16 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
1105 1107 // appen matrix type
1106 1108 ARequest.Append(FExperiment.MatrixTypeAsString); // COUNT-4
1107 1109  
1108   - // append chat data if allowed
1109   - if FExperiment.SendChatHistoryForNewPlayers then
1110   - ARequest.Append(FormMatrixGame.ChatMemoRecv.Lines.Text) // COUNT-3
  1110 + // append chat data
  1111 + if FExperiment.ShowChat then
  1112 + begin
  1113 + if FExperiment.SendChatHistoryForNewPlayers then
  1114 + ARequest.Append(FormMatrixGame.ChatMemoRecv.Lines.Text) // COUNT-3
  1115 + else
  1116 + ARequest.Append('[CHAT]'); // must append something to keep the message envelop with standard size
  1117 + end
1111 1118 else
1112   - ARequest.Append('[CHAT]'); // must append something to keep the message envelop standard
  1119 + ARequest.Append('[NOCHAT]'); // must append something to keep the message envelop with standard size
1113 1120  
1114 1121 // append global configs.
1115 1122 ARequest.Append(BoolToStr(FExperiment.ABPoints)); // COUNT-2
... ... @@ -1145,6 +1152,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
1145 1152 LEndCycle : Boolean;
1146 1153 LEndGeneration: string;
1147 1154 begin
  1155 + LConsequences := '';
1148 1156 {$IFDEF DEBUG}
1149 1157 WriteLn('Count:',FExperiment.Condition[FExperiment.CurrentCondition].Turn.Count, '<', FExperiment.Condition[FExperiment.CurrentCondition].Turn.Value);
1150 1158 {$ENDIF}
... ... @@ -1185,7 +1193,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
1185 1193 begin
1186 1194 ARequest.Append(#32); // 8
1187 1195 if Assigned(FExperiment.Condition[FExperiment.CurrentCondition].Prompt) then
1188   - FExperiment.WriteReportRowPrompt;
  1196 + FExperiment.WriteReportRowPrompt; //TODO: FIND WHY OPTIMIZATION 3 GENERATES BUG HERE
1189 1197 FExperiment.Clean;
1190 1198 end;
1191 1199  
... ... @@ -1223,7 +1231,6 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
1223 1231 // return to experiment and present the prompt consequence, if any
1224 1232 if FExperiment.Condition[FExperiment.CurrentCondition].Prompt.ResponsesCount = FExperiment.PlayersCount then
1225 1233 begin
1226   -
1227 1234 // generate messages
1228 1235 LPromptConsequences := FExperiment.Condition[FExperiment.CurrentCondition].Prompt.AsString;
1229 1236 SetLength(M, 3+LPromptConsequences.Count);
... ... @@ -1243,7 +1250,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
1243 1250 end
1244 1251 else;
1245 1252  
1246   - // send identified messages; each player takes only its own message and ignore the rest
  1253 + // send identified messages; each player takes only its own message and ignore the rest
1247 1254 FZMQActor.SendMessage(M);
1248 1255 FExperiment.WriteReportRowPrompt;
1249 1256 FExperiment.Clean;
... ... @@ -1263,7 +1270,7 @@ procedure TGameControl.ReceiveRequest(var ARequest: TStringList);
1263 1270 P.Nicname := InputBox
1264 1271 (
1265 1272 'Mudança de geração',
1266   - 'Um novo participante entrou no lugar do participante mais antigo.Qual o apelido do novo participante?',
  1273 + 'Um novo participante entrou no lugar do participante mais antigo. Qual o apelido do novo participante?',
1267 1274 GenResourceName(-1)
1268 1275 );
1269 1276  
... ... @@ -1312,9 +1319,15 @@ procedure TGameControl.ReceiveReply(AReply: TStringList);
1312 1319 // set matrix type/ stringgrid
1313 1320 FExperiment.MatrixTypeAsString:=AReply[AReply.Count-4];
1314 1321  
1315   - // add chat
1316   - FormMatrixGame.ChatMemoRecv.Lines.Clear;
1317   - FormMatrixGame.ChatMemoRecv.Lines.Add(AReply[AReply.Count-3]);
  1322 + // enable chat
  1323 + if AReply[AReply.Count-3] = '[NOCHAT]' then
  1324 + FormMatrixGame.ChatPanel.Visible := False
  1325 + else
  1326 + begin
  1327 + FormMatrixGame.ChatPanel.Visible := True;
  1328 + FormMatrixGame.ChatMemoRecv.Lines.Clear;
  1329 + FormMatrixGame.ChatMemoRecv.Lines.Append(AReply[AReply.Count-3]);
  1330 + end;
1318 1331  
1319 1332 // set global configs
1320 1333 FExperiment.ABPoints := StrToBool(AReply[AReply.Count-2]);
... ... @@ -1322,7 +1335,10 @@ procedure TGameControl.ReceiveReply(AReply: TStringList);
1322 1335 FormMatrixGame.GBIndividual.Visible:= not FormMatrixGame.GBIndividualAB.Visible;
1323 1336  
1324 1337 // set condition specific configurations
1325   - NextConditionSetup(AReply[AReply.Count-1])
  1338 + NextConditionSetup(AReply[AReply.Count-1]);
  1339 +
  1340 + // set fullscreen
  1341 + FormMatrixGame.SetFullscreen;
1326 1342 end
1327 1343 else
1328 1344 begin
... ...
experiment_runner/units/game_experiment.pas
... ... @@ -143,6 +143,7 @@ type
143 143 function AppendContingency(ACondition : integer;AContingency : TContingency) : integer;overload;
144 144 function AppendPlayer : integer;overload;
145 145 function AppendPlayer(APlayer : TPlayer) : integer; overload;
  146 + function TargetIntelockingFired : Boolean;
146 147 property Condition[I : Integer]: TCondition read GetCondition write SetCondition;
147 148 property ConditionsCount : integer read GetConditionsCount;
148 149 property CurrentCondition : integer read FCurrentCondition write FCurrentCondition;
... ... @@ -300,8 +301,19 @@ end;
300 301 function TExperiment.GetPlayer(AID: UTF8string): TPlayer;
301 302 var
302 303 i : integer;
303   -begin
304   - //Result.ID := '';
  304 + P : TPlayer = (
  305 + ID : '';
  306 + Nicname : '';
  307 + Login: '';
  308 + Password: '';
  309 + Status : gpsWaiting;
  310 + Data : nil;
  311 + Choice : (Row:grNone; Color:gcNone);
  312 + Points : (A:0; B:0);
  313 + Turn : -1;
  314 + );
  315 +begin
  316 + Result := P;
305 317 if PlayersCount > 0 then
306 318 for i:= 0 to PlayersCount -1 do
307 319 if FPlayers[i].ID = AID then
... ... @@ -746,7 +758,7 @@ begin
746 758 LRow += 'NA'+#9;
747 759  
748 760 FRegData.SaveData(LRow);
749   - FReportReader.Extend(LRow);
  761 + FReportReader.Extend(LRow); // Write, i.e, extend last row
750 762 end;
751 763 end;
752 764  
... ... @@ -886,6 +898,18 @@ begin
886 898 FPlayers[Result] := APlayer;
887 899 end;
888 900  
  901 +function TExperiment.TargetIntelockingFired: Boolean;
  902 +var i : integer;
  903 +begin
  904 + Result := False;
  905 + for i:= 0 to ContingenciesCount[CurrentCondition]-1 do
  906 + if Condition[CurrentCondition].Contingencies[i].Meta then
  907 + begin
  908 + Result := Condition[CurrentCondition].Contingencies[i].Fired;
  909 + Break;
  910 + end;
  911 +end;
  912 +
889 913 function TExperiment.ShouldEndCondition: Boolean;
890 914 var
891 915 LInterlocks: Real;
... ... @@ -960,7 +984,7 @@ begin
960 984 for i := 0 to ContingenciesCount[c]-1 do
961 985 Contingency[c,i].Clean;
962 986  
963   - if Assigned(Condition[c].Prompt) then
  987 + if Assigned(Condition[c].Prompt) then // TODO: FIND WHY OPTIMIZATION 3 GENERATES BUG HERE
964 988 Condition[c].Prompt.Clean;
965 989  
966 990 FRegData.CloseAndOpen;
... ...
experiment_runner/units/game_file_methods.pas
... ... @@ -35,6 +35,7 @@ implementation
35 35  
36 36 uses LCLIntf, game_resources, game_actors, game_actors_helpers, string_methods, regdata;
37 37  
  38 +// for dev only
38 39 function LoadExperimentFromResource(var AExperiment: TExperiment): Boolean;
39 40 var
40 41 C : TCondition;
... ... @@ -68,6 +69,7 @@ begin
68 69 begin
69 70 ExperimentName:='test_experiment';
70 71 ExperimentAim:='This is a test experiment.';
  72 + ShowChat := True;
71 73 Researcher := VAL_RESEARCHER;
72 74 ResearcherCanPlay:=False;
73 75 ResearcherCanChat:=True;
... ... @@ -169,6 +171,7 @@ var
169 171 AExperiment.ExperimentAim:=ReadString(SEC_EXPERIMENT, KEY_AIM,'');
170 172  
171 173 // general configs
  174 + AExperiment.ShowChat := ReadBool(SEC_EXPERIMENT, KEY_CHAT_FOR_PLAYERS, False);
172 175 AExperiment.ResearcherCanPlay := ReadBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANPLAY,False);
173 176 AExperiment.ResearcherCanChat := ReadBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANCHAT,False);
174 177 AExperiment.GenPlayersAsNeeded := ReadBool(SEC_EXPERIMENT, KEY_GEN_PLAYER_AS_NEEDED,False);
... ... @@ -177,7 +180,7 @@ var
177 180 AExperiment.MatrixType := GetMatrixTypeFromString(ReadString(SEC_EXPERIMENT,KEY_MATRIX_TYPE,DEF_MATRIX_TYPE));
178 181  
179 182 // used when loading from paused experiments
180   - AExperiment.CurrentCondition := ReadInteger(SEC_EXPERIMENT, KEY_CURRENT_CONDITION,0)-1; //zero based
  183 + AExperiment.CurrentCondition := ReadInteger(SEC_EXPERIMENT, KEY_CURRENT_CONDITION,0); //zero based
181 184 end;
182 185 end;
183 186  
... ... @@ -256,7 +259,7 @@ var
256 259 Turn.Random:= ReadBool(LS, KEY_TURN_RANDOM,False);
257 260 Cycles.Count:= ReadInteger(LS, KEY_CYCLES_COUNT,0);
258 261 Cycles.Value:= ReadInteger(LS, KEY_CYCLES_VALUE,10);
259   - Cycles.Generation:= ReadInteger(LS, KEY_CYCLES_GEN,5);
  262 + Cycles.Generation:= ReadInteger(LS, KEY_CYCLES_GEN,0);
260 263 EndCriterium.Style := GetEndCriteriaStyleFromString(ReadString(LS,KEY_ENDCRITERIA,DEF_END_CRITERIA_STYLE));
261 264 EndCriterium.AbsoluteCycles:=ReadInteger(LS,KEY_ENDCRITERIA_CYCLES,20);
262 265 s1 := ReadString(LS,KEY_ENDCRITERIA_PORCENTAGE,DEF_END_CRITERIA_PORCENTAGE);
... ... @@ -383,9 +386,23 @@ begin
383 386 LIniFile:= TIniFile.Create(LWriter.FileName);
384 387 LWriter.Free;
385 388  
386   - LIniFile.WriteString(SEC_EXPERIMENT,KEY_RESEARCHER,AExperiment.Researcher);
387   -
  389 + // write experiment
388 390 with LIniFile do
  391 + begin
  392 + WriteString(SEC_EXPERIMENT, KEY_RESEARCHER, AExperiment.Researcher);
  393 + WriteString(SEC_EXPERIMENT, KEY_NAME, AExperiment.ExperimentName);
  394 + WriteString(SEC_EXPERIMENT, KEY_AIM, AExperiment.ExperimentAim);
  395 + WriteBool(SEC_EXPERIMENT, KEY_CHAT_FOR_PLAYERS, AExperiment.ShowChat);
  396 + WriteBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANPLAY, AExperiment.ResearcherCanPlay);
  397 + WriteBool(SEC_EXPERIMENT, KEY_RESEARCHER_CANCHAT, AExperiment.ResearcherCanChat);
  398 + WriteBool(SEC_EXPERIMENT, KEY_GEN_PLAYER_AS_NEEDED, AExperiment.GenPlayersAsNeeded);
  399 + WriteBool(SEC_EXPERIMENT, KEY_CHAT_HISTORY_FOR_NEW_PLAYERS, AExperiment.SendChatHistoryForNewPlayers);
  400 + WriteBool(SEC_EXPERIMENT, KEY_POINTS_TYPE, AExperiment.ABPoints);
  401 + WriteString(SEC_EXPERIMENT,KEY_MATRIX_TYPE,GetMatrixTypeString(AExperiment.MatrixType));
  402 + WriteInteger(SEC_EXPERIMENT, KEY_CURRENT_CONDITION, AExperiment.CurrentCondition);
  403 + end;
  404 +
  405 + with LIniFile do // write conditions
389 406 for i := 0 to AExperiment.ConditionsCount-1 do
390 407 begin
391 408 LC := SEC_CONDITION+IntToStr(i+1);
... ... @@ -415,7 +432,7 @@ begin
415 432  
416 433 MI := 0;
417 434 CI := 0;
418   - for j := 0 to High(Contingencies) do
  435 + for j := 0 to High(Contingencies) do // write ocntingencies
419 436 begin
420 437 if Contingencies[j].Meta then
421 438 begin
... ...
experiment_runner/units/game_resources.pas
... ... @@ -28,6 +28,7 @@ resourcestring
28 28 KEY_RESEARCHER_CANCHAT = 'Pesquisador.BatePapo';
29 29 KEY_RESEARCHER_CANPLAY = 'Pesquisador.PodeJogar';
30 30 KEY_GEN_PLAYER_AS_NEEDED = 'Jogadores.GerarAutomaticamente';
  31 + KEY_CHAT_FOR_PLAYERS = 'Jogadores.BatePapo';
31 32 KEY_CHAT_HISTORY_FOR_NEW_PLAYERS = 'Jogadores.Novos.Enviar_Histórico_do_BatePapo';
32 33 KEY_CURRENT_CONDITION = 'ComeçarNaCondição';
33 34 KEY_MATRIX_TYPE= 'TipoDaMatrix';
... ...