-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
611 lines (532 loc) · 30.7 KB
/
Form1.vb
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
Public Class frmLvl1
Private oRoom As New Collection
Private oABrain As New Collection
Public oAgent As cAgent
Public closecellenable As Boolean
Public pEntityType As Integer
Public ZombieCount As Integer
Public ChemCount As Integer
Public GoalCount As Integer
Public GOALplaced As Boolean
Public Filepath As String
Public OpenedOnce As Boolean
Public WroteOnce As Boolean
Public riskfactor As Integer
'initializing steps----------------------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim splashcancell As Integer
splashcancell = MsgBox( _
"objective:" & vbCrLf & _
vbCrLf & _
"design an environment by placing two (2) zombies and/or one (1) chemicalX canister to prevent the agent from reaching the exit/door, which you will also place." & vbCrLf & _
vbCrLf & _
"to do this, click the [edit] button. select an entity type to place." & vbCrLf & _
vbCrLf & _
"contine with game?", MsgBoxStyle.OkCancel, "Zombie Survivor")
If splashcancell = 2 Then End
RoomMaker()
Agent()
pEntityType = 0
oAgent.Position(1, 1) : oAgent.Ammo = 1
End Sub
Sub RoomMaker() 'creates the collection of oCells and adds them to oRoom and enables cell pictures
Dim oCell As cCell
For i = 0 To 6
For j = 0 To 6
oCell = New cCell : oCell.CellValue(i, j, False, False, False)
oRoom.Add(oCell, i & j)
Next
Next
End Sub
Sub Agent()
'defines the agent as a new object, with a position and ammo for gun function
oAgent = New cAgent
oAgent.Position(1, 1)
oAgent.Ammo = 1
'DEFINES the Agents brain, originally with no information, but large enough to store
'information about the entire room, once reasoned or learned
Dim C As String : C = "cell" 'used for dynamic image controlling via Me.Controls
Dim oABCell As cABrainCell 'Defines the Agentss brain cells (cPCell) to be added to the collection named Brain (oABrain)
For i = 0 To 6
For j = 0 To 6
oABCell = New cABrainCell
oABCell.CellInfo(i, j, 0, 0, 0, 0, 0, 0)
oABrain.Add(oABCell, i & j)
Next
Next
End Sub
'/initializing steps---------------------------------------------------------------------------
'editing section-------------------------------------------------------------------------------
Private Sub cmdEDIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEDIT.Click
Dim C As String : C = "cell"
Dim iCell As Object
If rZombie.Enabled = False Then
'enables radio buttons
cmdClear.Enabled = True
rZombie.Enabled = True
rChem.Enabled = True
rGOAL.Enabled = True
scrlSafety.Enabled = True
lblRisk.Enabled = True
lblSafe.Enabled = True
lblSave.Enabled = True
txtSave.Enabled = True
cmdFind.Enabled = True
'enables cells for clicking
For i = 0 To 6
For j = 0 To 6
iCell = C & i & j
If 0 < i And i < 6 And 0 < j And j < 6 Then iCell = C & i & j : Me.Controls(iCell).Enabled = True
Next
Next
Else
'diables radio buttons
cmdClear.Enabled = False
rZombie.Enabled = False
rChem.Enabled = False
rGOAL.Enabled = False
scrlSafety.Enabled = False
lblRisk.Enabled = False
lblSafe.Enabled = False
lblSave.Enabled = False
txtSave.Enabled = False
cmdFind.Enabled = False
'disables cells for clicking
For i = 0 To 6
For j = 0 To 6
iCell = C & i & j
If 0 < i And i < 6 And 0 < j And j < 6 Then iCell = C & i & j : Me.Controls(iCell).Enabled = False
Next
Next
End If
End Sub
Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
Dim C As String : C = "cell"
Dim oCell As Object
For i = 1 To 5
For j = 1 To 5
oRoom(i & j).CellValue(i, j, False, False, False)
oRoom(i & j).ZSmell = False : oRoom(i & j).CFumes = False : oRoom(i & j).GDayli = False
oCell = C & i & j
Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
Next
Next
cell11.ImageLocation = "@\..\iconset\agent.png"
cell12.ImageLocation = "@\..\iconset\floorD.png"
cell22.ImageLocation = "@\..\iconset\floorD.png"
cell21.ImageLocation = "@\..\iconset\floorD.png"
ZombieCount = 0 : ChemCount = 0 : GoalCount = 0 : GOALplaced = False
End Sub
'radio buttons for editing
Private Sub rZombie_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rZombie.CheckedChanged
pEntityType = 1
End Sub
Private Sub rChem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rChem.CheckedChanged
pEntityType = 2
End Sub
Private Sub rGOAL_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rGOAL.CheckedChanged
pEntityType = 3
End Sub
Sub EntityPlacement(ByVal A, ByVal B, ByVal Etype)
Dim C As String : C = "cell"
Dim oCell As Object
oCell = C & A & B
'Defines Up, Down, Left, and Right cell coordinates
Dim U As Integer : U = B + 1
Dim D As Integer : D = B - 1
Dim L As Integer : L = A - 1
Dim R As Integer : R = A + 1
If Etype = 1 And ZombieCount < 2 And oRoom(A & B).IsZomb = False Then
Me.Controls(oCell).imagelocation = "@\..\iconset\zombie.png"
ZombieCount = ZombieCount + 1
lblOUT.Text = "you have placed " & ZombieCount & "/2 Zombie(s)."
oRoom(A & B).cellvalue(A, B, True, False, False)
'creates Zombie Smell in current and adjacent cells
oRoom(A & U).cellattributes(True, , )
oRoom(A & D).cellattributes(True, , )
oRoom(L & B).cellattributes(True, , )
oRoom(R & B).cellattributes(True, , )
ElseIf Etype = 2 And ChemCount < 1 Then
Me.Controls(oCell).imagelocation = "@\..\iconset\chemx.png"
ChemCount = ChemCount + 1
lblOUT.Text = "you have placed " & ChemCount & "/1 ChemicalX containers(s)."
oRoom(A & B).cellvalue(A, B, False, True, False)
'creates Hole Breeze in current and adjacent cells
oRoom(A & U).cellattributes(, True, )
oRoom(A & D).cellattributes(, True, )
oRoom(L & B).cellattributes(, True, )
oRoom(R & B).cellattributes(, True, )
ElseIf Etype = 3 And GoalCount < 1 Then
Me.Controls(oCell).imagelocation = "@\..\iconset\door.png"
oRoom(A & B).cellvalue(A, B, False, False, True)
oRoom(A & B).cellattributes(, , True)
GoalCount = GoalCount + 1
lblOUT.Text = "you have placed " & GoalCount & "/1 Goal(s)."
GOALplaced = True
ElseIf Etype = 0 Then
lblOUT.Text = "place an entity."
Else : MsgBox("you have reached entity limit for this level.")
End If
End Sub
Private Sub cmdFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFind.Click
FolderBrowserDialog1.ShowDialog()
Filepath = FolderBrowserDialog1.SelectedPath
txtSave.Text = Filepath
End Sub
'/editing section------------------------------------------------------------------------------
'Agent Stuff-----------------------------------------------------------------------------------
Private Sub cmdAgentRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAgentRun.Click
runwalk(1)
End Sub
Private Sub cmdAgentStep_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAgentStep.Click
runwalk(0)
End Sub
Sub runwalk(ByVal rw)
If GOALplaced = True Then
If txtSave.Text <> "" Then
riskfactor = scrlSafety.Value / 100
Filepath = txtSave.Text
If closecellenable = False Then
cell12.ImageLocation = "@\..\iconset\floor.png"
cell22.ImageLocation = "@\..\iconset\floor.png"
cell21.ImageLocation = "@\..\iconset\floor.png"
closecellenable = True
End If
If rw = 0 Then
AgentMovement()
Else
For i = 0 To 500 'loops until goal state is found or steps are up
AgentMovement()
Next
MsgBox("agent did not find the goal in alloted number of steps.")
End If
Else : MsgBox("enter a filepath to save room and agent information.")
End If
ElseIf rZombie.Enabled = True Then : MsgBox("to finish editing, press the [Edit} button again.")
Else : MsgBox("you must place a DOOR for the simulation to start.")
End If
End Sub
Private Sub AgentMovement()
cmdEDIT.Enabled = False
cmdClear.Enabled = False
rZombie.Enabled = False
rChem.Enabled = False
rGOAL.Enabled = False
'WRITES user designed room to a text file
WriteRoom()
'DEFINE Agent position
Dim A As Integer : A = oAgent.X
Dim B As Integer : B = oAgent.Y
'Potential Movemnts Up (U), Down (D), Left (L), & Right (R)
Dim U As Integer : U = B + 1
Dim D As Integer : D = B - 1
Dim L As Integer : L = A - 1
Dim R As Integer : R = A + 1
'TELL, REASON, AND RECORD--------------------------------------------------------------
'DEFINITE existance of entities------
Dim Zo As Integer : If oRoom(A & B).IsZomb = True Then Zo = 3 : oABrain(A & B).pZomb = 3
'If Agent is in the same cell as a zombie
If Zo = 3 Then
oAgent.UseGun(1)
oRoom(A & B).IsZomb = False
oRoom(A & U).Zsmell = False
oRoom(A & D).Zsmell = False
oRoom(L & B).zsmell = False
oRoom(R & B).zSmell = False
End If
'If Agent walks into a cell with a chemicalX canister
Dim cX As Integer : If oRoom(A & B).IsChem = True Then cX = 3 : oABrain(A & B).pChem = 3
If cX = 3 Then
PrintToText(A, B, oABrain(A & B).pZomb, oABrain(A & B).pChem, oABrain(A & B).pGoal, oABrain(A & B).pSmel, oABrain(A & B).pFume, oABrain(A & B).pDayl, " MOVE")
MsgBox("Agent: the chemicalX canister made me a zombie ... game over.")
End
End If
'If Agent walks into a cell with GOAL
Dim Go As Integer : If oRoom(A & B).IsGoal = True Then Go = 3 : oABrain(A & B).pGoal = 3
'/DEFINITE existance of entities-----
'DEFINITE existance of attributes
Dim Sm As Integer : If oRoom(A & B).ZSmell = True Then Sm = 3 : oABrain(A & B).pSmel = 3
Dim Fu As Integer : If oRoom(A & B).CFumes = True Then Fu = 3 : oABrain(A & B).pFume = 3
Dim Dl As Integer : If oRoom(A & B).GDayli = True Then Dl = 3 : oABrain(A & B).pDayl = 3
'GOAL check: if Agent has reached the GOAL then he wins and Ends execution
If Dl = 3 Then MsgBox("Agent: I escaped the zombies.") : oABrain(A & B).pGoal = 3 : oABrain(A & B).pDayl = 3 : End
'WRITES current position, potential existance of any Entities and any Attributes
PrintToText("X", "Y", "PZomb", "PHole", "PGoal", "PSmel", "PBrez", "PDayl", "LOGIC/MOVE")
PrintToText(A, B, oABrain(A & B).pZomb, oABrain(A & B).pChem, oABrain(A & B).pGoal, oABrain(A & B).pSmel, oABrain(A & B).pfume, oABrain(A & B).pDayl, " MOVE")
PrintToText("-", "-", "-", "-", "-", "-", "-", "-", "-")
'REASONING---------------------------
'if it smells here then maybe there is a zombie near, else there is not
If Sm = 3 Then
oABrain(A & U).cellinfo(A, U, 1, 0, 0, 0, 0, 0) : PrintToText(A, U, oABrain(A & U).pZomb, oABrain(A & U).pChem, oABrain(A & U).pGoal, oABrain(A & U).pSmel, oABrain(A & U).pFume, oABrain(A & U).pDayl, "LOGIC")
oABrain(A & D).cellinfo(A, D, 1, 0, 0, 0, 0, 0) : PrintToText(A, D, oABrain(A & D).pZomb, oABrain(A & D).pChem, oABrain(A & D).pGoal, oABrain(A & D).pSmel, oABrain(A & D).pFume, oABrain(A & D).pDayl, "LOGIC")
oABrain(L & B).cellinfo(L, B, 1, 0, 0, 0, 0, 0) : PrintToText(L, B, oABrain(L & B).pZomb, oABrain(L & B).pChem, oABrain(L & B).pGoal, oABrain(L & B).pSmel, oABrain(L & B).pFume, oABrain(L & B).pDayl, "LOGIC")
oABrain(R & B).cellinfo(R, B, 1, 0, 0, 0, 0, 0) : PrintToText(R, B, oABrain(R & B).pZomb, oABrain(R & B).pChem, oABrain(R & B).pGoal, oABrain(R & B).pSmel, oABrain(R & B).pFume, oABrain(R & B).pDayl, "LOGIC")
PrintToText("-", "-", "-", "-", "-", "-", "-", "-", "-")
Else
oABrain(A & U).cellinfo(A, U, 2, 0, 0, 0, 0, 0) : PrintToText(A, U, oABrain(A & U).pZomb, oABrain(A & U).pChem, oABrain(A & U).pGoal, oABrain(A & U).pSmel, oABrain(A & U).pFume, oABrain(A & U).pDayl, "LOGIC")
oABrain(A & D).cellinfo(A, D, 2, 0, 0, 0, 0, 0) : PrintToText(A, D, oABrain(A & D).pZomb, oABrain(A & D).pChem, oABrain(A & D).pGoal, oABrain(A & D).pSmel, oABrain(A & D).pFume, oABrain(A & D).pDayl, "LOGIC")
oABrain(L & B).cellinfo(L, B, 2, 0, 0, 0, 0, 0) : PrintToText(L, B, oABrain(L & B).pZomb, oABrain(L & B).pChem, oABrain(L & B).pGoal, oABrain(L & B).pSmel, oABrain(L & B).pFume, oABrain(L & B).pDayl, "LOGIC")
oABrain(R & B).cellinfo(R, B, 2, 0, 0, 0, 0, 0) : PrintToText(R, B, oABrain(R & B).pZomb, oABrain(R & B).pChem, oABrain(R & B).pGoal, oABrain(R & B).pSmel, oABrain(R & B).pFume, oABrain(R & B).pDayl, "LOGIC")
PrintToText("-", "-", "-", "-", "-", "-", "-", "-", "-")
End If
'if it breezes here then maybe there is a hole near if not, there is not
If Fu = 3 Then
oABrain(A & U).cellinfo(A, U, 0, 1, 0, 0, 0, 0) : PrintToText(A, U, oABrain(A & U).pZomb, oABrain(A & U).pChem, oABrain(A & U).pGoal, oABrain(A & U).pSmel, oABrain(A & U).pFume, oABrain(A & U).pDayl, "LOGIC")
oABrain(A & D).cellinfo(A, D, 0, 1, 0, 0, 0, 0) : PrintToText(A, D, oABrain(A & D).pZomb, oABrain(A & D).pChem, oABrain(A & D).pGoal, oABrain(A & D).pSmel, oABrain(A & D).pFume, oABrain(A & D).pDayl, "LOGIC")
oABrain(L & B).cellinfo(L, B, 0, 1, 0, 0, 0, 0) : PrintToText(L, B, oABrain(L & B).pZomb, oABrain(L & B).pChem, oABrain(L & B).pGoal, oABrain(L & B).pSmel, oABrain(L & B).pFume, oABrain(L & B).pDayl, "LOGIC")
oABrain(R & B).cellinfo(R, B, 0, 1, 0, 0, 0, 0) : PrintToText(R, B, oABrain(R & B).pZomb, oABrain(R & B).pChem, oABrain(R & B).pGoal, oABrain(R & B).pSmel, oABrain(R & B).pFume, oABrain(R & B).pDayl, "LOGIC")
PrintToText("-", "-", "-", "-", "-", "-", "-", "-", "-")
Else
oABrain(A & U).cellinfo(A, U, 0, 2, 0, 0, 0, 0) : PrintToText(A, U, oABrain(A & U).pZomb, oABrain(A & U).pChem, oABrain(A & U).pGoal, oABrain(A & U).pSmel, oABrain(A & U).pFume, oABrain(A & U).pDayl, "LOGIC")
oABrain(A & D).cellinfo(A, D, 0, 2, 0, 0, 0, 0) : PrintToText(A, D, oABrain(A & D).pZomb, oABrain(A & D).pChem, oABrain(A & D).pGoal, oABrain(A & D).pSmel, oABrain(A & D).pFume, oABrain(A & D).pDayl, "LOGIC")
oABrain(L & B).cellinfo(L, B, 0, 2, 0, 0, 0, 0) : PrintToText(L, B, oABrain(L & B).pZomb, oABrain(L & B).pChem, oABrain(L & B).pGoal, oABrain(L & B).pSmel, oABrain(L & B).pFume, oABrain(L & B).pDayl, "LOGIC")
oABrain(R & B).cellinfo(R, B, 0, 2, 0, 0, 0, 0) : PrintToText(R, B, oABrain(R & B).pZomb, oABrain(R & B).pChem, oABrain(R & B).pGoal, oABrain(R & B).pSmel, oABrain(R & B).pFume, oABrain(R & B).pDayl, "LOGIC")
PrintToText("-", "-", "-", "-", "-", "-", "-", "-", "-")
End If
'if the Agent believes there may be a Zombie in a cell and any two adjacent squares smell then
'say that there is a zombie in that cell
Dim Smcount As Integer : Smcount = 0
Dim NScount As Integer : NScount = 0
Dim cXcount As Integer : cXcount = 0
Dim NHcount As Integer : NHcount = 0
For i = 1 To 5
For j = 1 To 5
If oABrain(i & j).Pzomb = 1 Then
If oABrain(i & j + 1).Psmel = 3 Then Smcount = Smcount + 1
If oABrain(i & j - 1).Psmel = 3 Then Smcount = Smcount + 1
If oABrain(i - 1 & j).Psmel = 3 Then Smcount = Smcount + 1
If oABrain(i + 1 & j).Psmel = 3 Then Smcount = Smcount + 1
If Smcount >= 2 Then
oABrain(i & j).PZomb = 3
MsgBox("Agent: I reason that there is a zombie in cell (" & i & "," & j & ")")
End If
Smcount = 0
End If
Next
Next
'if the Agent believes there may be a ChemicalX canister in a cell and any two adjacent squares have fumes then
'say that there is a Hole in that cell
For m = 1 To 5
For n = 1 To 5
If oABrain(m & n).Pchem = 1 Then
If oABrain(m & n + 1).Pfume = 3 Then cXcount = cXcount + 1
If oABrain(m & n - 1).Pfume = 3 Then cXcount = cXcount + 1
If oABrain(m - 1 & n).Pfume = 3 Then cXcount = cXcount + 1
If oABrain(m + 1 & n).Pfume = 3 Then cXcount = cXcount + 1
If cXcount >= 2 Then
oABrain(m & n).Pchem = 3
MsgBox("Agent: I reason that there is a chemicalX canister in cell (" & m & "," & n & ")")
End If
cXcount = 0
End If
Next
Next
Dim C As String : C = "cell"
Dim oCell As Object
1: Dim dir As Integer : dir = Math.Floor(4 * Rnd()) 'random direction generator
'/TELL, REASON, AND RECORD-------------------------------------------------------------
'AGENT MOVEMENT SECTION----------------------------------------------------------------
If dir = 0 Then
If U < 6 Then 'as long as up is within bounds
If (oABrain(A & U).pZomb = 2 And oABrain(A & U).pChem = 2) Then
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(A, U) 'records new position
oCell = C & A & U : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf oABrain(A & U).pZomb <= 1 And oABrain(A & U).pChem <= 1 And riskfactor < Rnd() Then
'risk factor (to avoid getting stuck)
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(A, U) 'records new position
oCell = C & A & U : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf (oABrain(A & U).pZomb = 3 And oAgent.Ammo > 0 And 1 - riskfactor < Rnd()) Then
'risk factor (to try to kill a zombie)
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(A, U) 'records new position
oCell = C & A & U : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
Else
GoTo 1
End If
Else
GoTo 1
End If
ElseIf dir = 1 Then
If 0 < D Then 'as long as up is within bounds
If (oABrain(A & D).pzomb = 2 And oABrain(A & D).pChem = 2) Then
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(A, D) 'records new position
oCell = C & A & D : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf oABrain(A & D).pzomb <= 1 And oABrain(A & U).pChem <= 1 And riskfactor < Rnd() Then
'risk factor (to avoid getting stuck)
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(A, D) 'records new position
oCell = C & A & D : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf (oABrain(A & D).pZomb = 3 And oAgent.Ammo > 0 And 1 - riskfactor < Rnd()) Then
'risk factor (to try to kill a zombie)
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(A, D) 'records new position
oCell = C & A & D : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
Else
GoTo 1
End If
Else
GoTo 1
End If
ElseIf dir = 2 Then
If 0 < L Then 'as long as up is within bounds
If (oABrain(L & B).pzomb = 2 And oABrain(L & B).pChem = 2) Then
'move from A&B to L&B
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(L, B) 'records new(position)
oCell = C & L & B : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf oABrain(L & B).pZomb <= 1 And oABrain(L & U).pChem <= 1 And riskfactor < Rnd() Then
'risk factor (to avoid getting stuck)
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(L, B) 'records new(position)
oCell = C & L & B : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf (oABrain(L & B).Pzomb = 3 And oAgent.Ammo > 0 And 1 - riskfactor < Rnd()) Then
'risk factor (to try to kill a zombie)
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(L, B) 'records new(position)
oCell = C & L & B : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
Else
GoTo 1
End If
Else
GoTo 1
End If
ElseIf dir = 3 Then
If R < 6 Then 'as long as up is within bounds
If (oABrain(R & B).pzomb = 2 And oABrain(R & B).pChem = 2) Then
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(R, B) 'records new position
oCell = C & R & B : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf oABrain(R & B).pZomb <= 1 And oABrain(R & B).pChem <= 1 And riskfactor < Rnd() Then
'risk factor (to avoid getting stuck)
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(A, U) 'records new position
oCell = C & A & U : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
ElseIf (oABrain(R & B).PZomb = 3 And oAgent.Ammo > 0 And 1 - riskfactor < Rnd()) Then
'risk factor (to try to kill a zombie)
'move from A&B to A&U
oCell = C & A & B : Me.Controls(oCell).imagelocation = "@\..\iconset\floor.png"
oAgent.Position(R, B) 'records new position
oCell = C & R & B : Me.Controls(oCell).imagelocation = "@\..\iconset\agent.png"
Else
GoTo 1
End If
Else
GoTo 1
End If
End If
'/AGENT MOVEMENT SECTION---------------------------------------------------------------
End Sub
'/Agent Stuff----------------------------------------------------------------------------------
'ON CLICK cell commands------------------------------------------------------------------------
Private Sub cell11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell11.Click
lblOUT.Text = ("you cannot place an entity here.") 'EntityPlacement(1, 1, pEntityType)
End Sub
Private Sub cell21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell21.Click
lblOUT.Text = ("you cannot place an entity here.") 'EntityPlacement(2, 1, pEntityType)
End Sub
Private Sub cell31_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell31.Click
EntityPlacement(3, 1, pEntityType)
End Sub
Private Sub cell41_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell41.Click
EntityPlacement(4, 1, pEntityType)
End Sub
Private Sub cell51_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell51.Click
EntityPlacement(5, 1, pEntityType)
End Sub
Private Sub cell12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell12.Click
lblOUT.Text = ("you cannot place an entity here.") 'EntityPlacement(1, 2, pEntityType)
End Sub
Private Sub cell22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell22.Click
lblOUT.Text = ("you cannot place an entity here.") 'EntityPlacement(2, 2, pEntityType)
End Sub
Private Sub cell32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell32.Click
EntityPlacement(3, 2, pEntityType)
End Sub
Private Sub cell42_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell42.Click
EntityPlacement(4, 2, pEntityType)
End Sub
Private Sub cell52_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell52.Click
EntityPlacement(5, 2, pEntityType)
End Sub
Private Sub cell13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell13.Click
EntityPlacement(1, 3, pEntityType)
End Sub
Private Sub cell23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell23.Click
EntityPlacement(2, 3, pEntityType)
End Sub
Private Sub cell33_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell33.Click
EntityPlacement(3, 3, pEntityType)
End Sub
Private Sub cell43_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell43.Click
EntityPlacement(4, 3, pEntityType)
End Sub
Private Sub cell53_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell53.Click
EntityPlacement(5, 3, pEntityType)
End Sub
Private Sub cell14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell14.Click
EntityPlacement(1, 4, pEntityType)
End Sub
Private Sub cell24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell24.Click
EntityPlacement(2, 4, pEntityType)
End Sub
Private Sub cell34_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell34.Click
EntityPlacement(3, 4, pEntityType)
End Sub
Private Sub cell44_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell44.Click
EntityPlacement(4, 4, pEntityType)
End Sub
Private Sub cell54_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell54.Click
EntityPlacement(5, 4, pEntityType)
End Sub
Private Sub cell15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell15.Click
EntityPlacement(1, 5, pEntityType)
End Sub
Private Sub cell25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell25.Click
EntityPlacement(2, 5, pEntityType)
End Sub
Private Sub cell35_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell35.Click
EntityPlacement(3, 5, pEntityType)
End Sub
Private Sub cell45_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell45.Click
EntityPlacement(4, 5, pEntityType)
End Sub
Private Sub cell55_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cell55.Click
EntityPlacement(5, 5, pEntityType)
End Sub
'/ON CLICK cell commands-----------------------------------------------------------------------
'WRITE to files--------------------------------------------------------------------------------
Private Sub WriteRoom()
If WroteOnce = False Then
FileOpen(1, Filepath & "\RoomInfo.txt", OpenMode.Output) ' Open file for output.
Print(1, "XY", TAB(4), "IsZomb", TAB(12), "IsChem", TAB(20), "IsGoal", TAB(28), "ZSmell", TAB(36), "CFumes", TAB(44), "GDayli", TAB(0))
For i = 1 To 5
For j = 1 To 5
Print(1, i & j, TAB(4), oRoom(i & j).isZomb, TAB(12), oRoom(i & j).IsChem, TAB(20), oRoom(i & j).IsGoal, TAB(28), oRoom(i & j).ZSmell, TAB(36), oRoom(i & j).CFumes, TAB(44), oRoom(i & j).GDayli, TAB(0))
Next
Next
FileClose(1)
WroteOnce = True
End If
End Sub
Private Sub PrintToText(ByVal a, ByVal b, ByVal z, ByVal c, ByVal g, ByVal s, ByVal e, ByVal d, Optional ByVal logic = "")
If OpenedOnce = False Then
FileOpen(1, Filepath & "\AgentBrain.txt", OpenMode.Output) ' Open file for output.
Print(1, "XY", TAB(4), "PZomb", TAB(12), "PChem", TAB(20), "PGoal", TAB(28), "PSmel", TAB(36), "PFume", TAB(44), "PDayl", TAB(52), "LOGIC/MOVE", TAB(0))
OpenedOnce = True
Else
Print(1, a & b, TAB(4), z, TAB(12), c, TAB(20), g, TAB(28), s, TAB(36), e, TAB(44), d, TAB(52), logic, TAB(0))
End If
End Sub
'/WRITE to files-------------------------------------------------------------------------------
End Class