-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChessPerdict.vb
2212 lines (2082 loc) · 123 KB
/
ChessPerdict.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
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
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports System.IO
Imports System.Threading
Imports System.Drawing
Imports System.Text
Imports System.Linq
Imports System.Collections.Generic
Imports System
'********************************************************************************************
' * tring to predictative orderly movments.****************************************************
' * Ramin Edjlal*******************************************************************************
' * This Class should Predict the Validity Movements Of Current Order an Enemy of Current Order*(_)
' * Predict Not Working************************************************************************(+)
' * Chess Predict Taking AAllDraw Lot Of Time********************************************************RS*****0.12**4**Managements and Cuation Programing**(+)
' * Chess Prediction Caused to Initial AllDraw Method in Achmaz state not Working.************RS*****0.12**4**Managements and Cuation Programing**(+)
' * 'Kish' Achmaz Attacker by Gray Minister to Brown 'King' Not Removed by Brown Soldier******RS*****0.12**4**Managements and Cuation Programing**(+)
' * The State of Soldier Supporter By Soldier Brown Doesn’t Detected.*************************RS*****0.12**4**Managements and Cuation Programing**(+)
' * Chess Predict Doesn’t Act The Supporter of Soldier****************************************RS*****0.12**4**Managements and Cuation Programing**(+)
' * Chess Predict Supporter Successful For Kishing 'Alice' by Person**************************RS*****0.12**4**Managements and Cuation Programing**(+)
' * Chess 'Alice' By 'Bob' Supporter Misleading***********************************************RS*****0.12**4**Managements and Cuation Programing**(+)
' * Chess Predict at Tow Level Taking a lot of time.******************************************RS*****0.12**4**Managements and Cuation Programing**(+)
' * Chess Predict Not Working*****************************************************************RS*****0.12**4**Managements and Cuation Programing**(+)
' * **********************************************************************************************************************************************(+:Sum(10)) (_:Sum(1))
Namespace Refrigtz
Class ChessPerdict
'Initiate Global Variables.
Private APredict As ChessPerdict = Nothing
Private OrderDummy As Integer = 0
'bool KishHuristic = false;
'bool KishG = false, KishB = false;
Public Shared SodierValue As Integer = 1
Public Shared ElefantValue As Integer = 2
Public Shared HourseValue As Integer = 3
Public Shared BridgeValue As Integer = 5
Public Shared MinisterValue As Integer = 7
Public Shared KingValue As Integer = 10
Private RW As Integer = 0
Private CL As Integer = 0
Private Ki As Integer = 0
Public Shared LoopHuristicIndex As Integer = 0
Shared RWList As New List(Of Integer)()
Shared ClList As New List(Of Integer)()
Shared KiList As New List(Of Integer)()
Public Shared TableListAction As New List(Of Integer(,))()
Public Move As Integer = 0
Public Shared MouseClick As Integer = 0
Private DeptIndex As Integer() = New Integer(20) {}
'int DeptIndexVlue = 0;
Public AAllDraw As List(Of AllDraw) = Nothing
Public TableList As New List(Of Integer(,))()
Public Dept As Integer = 0
Public SolderesOnTable As DrawSoldier() = Nothing
Public ElephantOnTable As DrawElefant() = Nothing
Public HoursesOnTable As DrawHourse() = Nothing
Public BridgesOnTable As DrawBridge() = Nothing
Public MinisterOnTable As DrawMinister() = Nothing
Public KingOnTable As DrawKing() = Nothing
Private THIS As FormRefrigtz
Shared Sub Log(ex As Exception)
Try
Dim stackTrace As String = ex.ToString()
' path of file where stack trace will be stored.
File.AppendAllText("ErrorProgramRun.txt", stackTrace + ": On" + DateTime.Now.ToString())
Catch t As Exception
Log(t)
End Try
End Sub
'Constructor.
Public Sub New(ByRef Th As FormRefrigtz)
'Initiate Global Variable By Local Parameters.
Dim i As Integer
THIS = Th
AAllDraw = New List(Of AllDraw)()
SolderesOnTable = New DrawSoldier(AllDraw.SodierHigh) {}
i = 0
While i < AllDraw.SodierHigh
SolderesOnTable(i) = New DrawSoldier()
i += 1
End While
ElephantOnTable = New DrawElefant(AllDraw.ElefantHigh) {}
i = 0
While i < AllDraw.ElefantHigh
ElephantOnTable(i) = New DrawElefant()
i += 1
End While
HoursesOnTable = New DrawHourse(AllDraw.HourseHight) {}
i = 0
While i < AllDraw.HourseHight
HoursesOnTable(i) = New DrawHourse()
i += 1
End While
BridgesOnTable = New DrawBridge(AllDraw.BridgeHigh) {}
i = 0
While i < AllDraw.BridgeHigh
BridgesOnTable(i) = New DrawBridge()
i += 1
End While
MinisterOnTable = New DrawMinister(AllDraw.MinisterHigh) {}
i = 0
While i < AllDraw.MinisterHigh
MinisterOnTable(i) = New DrawMinister()
i += 1
End While
KingOnTable = New DrawKing(AllDraw.KingHigh) {}
i = 0
While i < AllDraw.KingHigh
KingOnTable(i) = New DrawKing()
i += 1
End While
End Sub
'Determination of Current Thinking Operations Thread Finished His Worke.
Public Function AllCurrentDeptThinkingFinished(Dum As AllDraw, i As Integer, j As Integer, Kind As Integer) As Boolean
'Initiate Local Variables.
Dim Finished As Boolean = False
'Soldeir Kind.
If Kind = 1 Then
'Wait For Flag Become Valid.
If Dum.SolderesOnTable(i).SoldierThinking(j).ThinkingFinished Then
Return True
End If
'Elephant Kind.
ElseIf Kind = 2 Then
'Wait For Flag Become Valid.
If Dum.ElephantOnTable(i).ElefantThinking(j).ThinkingFinished Then
Return True
End If
'Hourse Kind.
ElseIf Kind = 3 Then
'Wait For Flag Become Valid.
If Dum.HoursesOnTable(i).HourseThinking(j).ThinkingFinished Then
Return True
End If
'Bridges Kind.
ElseIf Kind = 4 Then
'Wait For Flag Become Valid.
If Dum.BridgesOnTable(i).BridgeThinking(j).ThinkingFinished Then
Return True
End If
'Minister Kind.
ElseIf Kind = 5 Then
'Wait For Flag Become Valid.
If Dum.MinisterOnTable(i).MinisterThinking(j).ThinkingFinished Then
Return True
End If
'King Kind.
ElseIf Kind = 6 Then
'Wait For Flag Become Valid.
If Dum.KingOnTable(i).KingThinking(j).ThinkingFinished Then
Return True
End If
End If
'Return Flag.
Return Finished
End Function
'Wait Method For Thinking Operation.
Sub Wait(Dum As AllDraw, i As Integer, j As Integer, Kind As Integer)
'Wait For All Thinking Operation Finished.
Do
THIS.SetBoxText(vbCr & vbLf & "Dept Predict :" + AllDraw.SyntaxToWrite)
THIS.RefreshBoxText()
Loop While Not AllCurrentDeptThinkingFinished(Dum, i, j, Kind)
End Sub
'Initiate For Every Initiation Objects.
Public Sub InitiateForEveryKindThingHome(DummyHA As AllDraw, ii As Integer, jj As Integer, a As Color, Table As Integer(,), Order As Integer,
TB As Boolean, [IN] As Integer)
'Order = Order * -1;
'ChessRules.CurrentOrder *= -1;
'Initiate Local Variables.
Dim i As Integer
Dim j As Integer
i = 0
j = 0
Dim Dummy As New AllDraw(THIS)
'Gray Order.
If Order = 1 Then
'For All Gray Soldiers.
i = 0
While i < AllDraw.SodierMidle
Try
'When Current Soldeir is Not Existing Continue Traversal Back.
If SolderesOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(SolderesOnTable(i).Row, Integer)
jj = CType(SolderesOnTable(i).Column, Integer)
'Construction of Thinking Solders Gray Object.
Dummy.SolderesOnTable(i) = New DrawSoldier(ii, jj, a, Table, Order, False,
i)
'For All Possible Movments.
j = 0
While j < AllDraw.SodierMovments
'Thinking Operations.
Dummy.SolderesOnTable(i).SoldierThinking(j).Table = SolderesOnTable(i).SoldierThinking(j).Table
Dummy.SolderesOnTable(i).SoldierThinking(j).ThinkingBegin = True
Dummy.SolderesOnTable(i).SoldierThinking(j).ThinkingFinished = False
Dummy.SolderesOnTable(i).SoldierThinking(j).t = New Thread(AddressOf Dummy.SolderesOnTable(i).SoldierThinking(j).Thinking)
Dummy.SolderesOnTable(i).SoldierThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 1)
j += 1
End While
Catch t As Exception
Dummy.SolderesOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Gray Elephant Objects.
i = 0
While i < AllDraw.ElefantMidle
Try
'When Gray Elephant Not Existing Continue Traversal Back.
If ElephantOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(ElephantOnTable(i).Row, Integer)
jj = CType(ElephantOnTable(i).Column, Integer)
'Construction of Gray Elepahnt Thinking Objectes.
Dummy.ElephantOnTable(i) = New DrawElefant(ii, jj, a, Table, Order, False,
i)
'For All Possible Movments.
j = 0
While j < AllDraw.ElefantMovments
'Elephant Gray Thinking Operations.
Dummy.ElephantOnTable(i).ElefantThinking(j).Table = ElephantOnTable(i).ElefantThinking(j).Table
Dummy.ElephantOnTable(i).ElefantThinking(j).ThinkingBegin = True
Dummy.ElephantOnTable(i).ElefantThinking(j).ThinkingFinished = False
Dummy.ElephantOnTable(i).ElefantThinking(j).t = New Thread(AddressOf Dummy.ElephantOnTable(i).ElefantThinking(j).Thinking)
Dummy.ElephantOnTable(i).ElefantThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 2)
j += 1
End While
Catch t As Exception
Dummy.ElephantOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Hourse Gray Objects.
i = 0
While i < AllDraw.HourseMidle
Try
'When Gray Hourses Not Exsisting Continue Traversal Back.
If HoursesOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(HoursesOnTable(i).Row, Integer)
jj = CType(HoursesOnTable(i).Column, Integer)
Dummy.HoursesOnTable(i) = New DrawHourse(ii, jj, a, Table, Order, False,
i)
'For All Possible Movments.
j = 0
While j < AllDraw.HourseMovments
'Hourse Thinking Gray Objects Operations.
Dummy.HoursesOnTable(i).HourseThinking(j).Table = HoursesOnTable(i).HourseThinking(j).Table
Dummy.HoursesOnTable(i).HourseThinking(j).ThinkingBegin = True
Dummy.HoursesOnTable(i).HourseThinking(j).ThinkingFinished = False
Dummy.HoursesOnTable(i).HourseThinking(j).t = New Thread(AddressOf Dummy.HoursesOnTable(i).HourseThinking(j).Thinking)
Dummy.HoursesOnTable(i).HourseThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 3)
j += 1
End While
Catch t As Exception
Dummy.HoursesOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Bridges Gray Objects.
i = 0
While i < AllDraw.BridgeMidle
Try
'When Gray Brideges Not Exsisting Traversal Back.
If BridgesOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(BridgesOnTable(i).Row, Integer)
jj = CType(BridgesOnTable(i).Column, Integer)
'Construction of Bridegs Gray With Local variables.
Dummy.BridgesOnTable(i) = New DrawBridge(ii, jj, a, Table, Order, False,
i)
j = 0
While j < 16
'Gray Bridges Thinking Operations.
Dummy.BridgesOnTable(i).BridgeThinking(j).Table = BridgesOnTable(i).BridgeThinking(j).Table
Dummy.BridgesOnTable(i).BridgeThinking(j).ThinkingBegin = True
Dummy.BridgesOnTable(i).BridgeThinking(j).ThinkingFinished = False
Dummy.BridgesOnTable(i).BridgeThinking(j).t = New Thread(AddressOf Dummy.BridgesOnTable(i).BridgeThinking(j).Thinking)
Dummy.BridgesOnTable(i).BridgeThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 4)
j += 1
End While
Catch t As Exception
Dummy.BridgesOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Minister Objets.
i = 0
While i < AllDraw.MinisterMidle
Try
'Whe Gray Minister Not Exsisting Continue Traversal back.
If MinisterOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(MinisterOnTable(i).Row, Integer)
jj = CType(MinisterOnTable(i).Column, Integer)
'Constructionof Ministerb Gray With Local Variables.
Dummy.MinisterOnTable(i) = New DrawMinister(ii, jj, a, Table, Order, False,
i)
'For All Possible Movments.
j = 0
While j < AllDraw.MinisterMovments
'Thinking Gray Ministers Operations.
Dummy.MinisterOnTable(i).MinisterThinking(j).Table = MinisterOnTable(i).MinisterThinking(j).Table
Dummy.MinisterOnTable(i).MinisterThinking(j).ThinkingBegin = True
Dummy.MinisterOnTable(i).MinisterThinking(j).ThinkingFinished = False
Dummy.MinisterOnTable(i).MinisterThinking(j).t = New Thread(AddressOf Dummy.MinisterOnTable(i).MinisterThinking(j).Thinking)
Dummy.MinisterOnTable(i).MinisterThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 5)
j += 1
End While
Catch t As Exception
Dummy.MinisterOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Possible Gray Kings.
i = 0
While i < AllDraw.KingMidle
Try
'When Gray King Not Exsisting Continue Traversal Back.
If KingOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(KingOnTable(i).Row, Integer)
jj = CType(KingOnTable(i).Column, Integer)
'Construction of Gray King With Local Variables.
Dummy.KingOnTable(i) = New DrawKing(ii, jj, a, Table, Order, False,
i)
'For All Possible Movements.
j = 0
While j < AllDraw.KingMovments
'Thinking Gray King Operatons.
Dummy.KingOnTable(i).KingThinking(j).Table = KingOnTable(i).KingThinking(j).Table
Dummy.KingOnTable(i).KingThinking(j).ThinkingBegin = True
Dummy.KingOnTable(i).KingThinking(j).ThinkingFinished = False
Dummy.KingOnTable(i).KingThinking(j).t = New Thread(AddressOf Dummy.KingOnTable(i).KingThinking(j).Thinking)
Dummy.KingOnTable(i).KingThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 6)
j += 1
End While
Catch t As Exception
Dummy.KingOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
Else
'Brown Order.
'For All Possible Brown Solders.
i = AllDraw.SodierMidle
While i < AllDraw.SodierHigh
Try
'Whn Not Existing Braown Solder Continue Traversal Back.
If SolderesOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(SolderesOnTable(i).Row, Integer)
jj = CType(SolderesOnTable(i).Column, Integer)
'Construction Of Brown Soldeir With Local Variables.
Dummy.SolderesOnTable(i) = New DrawSoldier(ii, jj, a, Table, Order, False,
i)
j = 0
While j < 4
'Thinking of Brown Soldiers Operations.
Dummy.SolderesOnTable(i).SoldierThinking(j).Table = SolderesOnTable(i).SoldierThinking(j).Table
Dummy.SolderesOnTable(i).SoldierThinking(j).ThinkingBegin = True
Dummy.SolderesOnTable(i).SoldierThinking(j).ThinkingFinished = False
Dummy.SolderesOnTable(i).SoldierThinking(j).t = New Thread(AddressOf Dummy.SolderesOnTable(i).SoldierThinking(j).Thinking)
Dummy.SolderesOnTable(i).SoldierThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 1)
j += 1
End While
Catch t As Exception
Dummy.SolderesOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Brwon elepahnt Objects.
i = AllDraw.ElefantMidle
While i < AllDraw.ElefantHigh
Try
'Continue Traversal Back Of Non Existing Objects.
If ElephantOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(ElephantOnTable(i).Row, Integer)
jj = CType(ElephantOnTable(i).Column, Integer)
'Construction of Brown Elephant Thinking Object.
Dummy.ElephantOnTable(i) = New DrawElefant(ii, jj, a, Table, Order, False,
i)
j = 0
While j < AllDraw.ElefantMovments
'Thinking Brown Elephant Operations.
Dummy.ElephantOnTable(i).ElefantThinking(j).Table = ElephantOnTable(i).ElefantThinking(j).Table
Dummy.ElephantOnTable(i).ElefantThinking(j).ThinkingBegin = True
Dummy.ElephantOnTable(i).ElefantThinking(j).ThinkingFinished = False
Dummy.ElephantOnTable(i).ElefantThinking(j).t = New Thread(AddressOf Dummy.ElephantOnTable(i).ElefantThinking(j).Thinking)
Dummy.ElephantOnTable(i).ElefantThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 2)
j += 1
End While
Catch t As Exception
Dummy.ElephantOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Possible Hourse Objects.
i = AllDraw.HourseMidle
While i < AllDraw.HourseHight
Try
'For Non Existing Brown Elephant Continue Traversal Back.
If HoursesOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(HoursesOnTable(i).Row, Integer)
jj = CType(HoursesOnTable(i).Column, Integer)
'Construction of Brown Hourse With Local Variables.
Dummy.HoursesOnTable(i) = New DrawHourse(ii, jj, a, Table, Order, False,
i)
'For All Possible Hourse Movments.
j = 0
While j < AllDraw.HourseMovments
'Thinking of Brwon Hourse Operations.
Dummy.HoursesOnTable(i).HourseThinking(j).Table = HoursesOnTable(i).HourseThinking(j).Table
Dummy.HoursesOnTable(i).HourseThinking(j).ThinkingBegin = True
Dummy.HoursesOnTable(i).HourseThinking(j).ThinkingFinished = False
Dummy.HoursesOnTable(i).HourseThinking(j).t = New Thread(AddressOf Dummy.HoursesOnTable(i).HourseThinking(j).Thinking)
Dummy.HoursesOnTable(i).HourseThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 3)
j += 1
End While
Catch t As Exception
Dummy.HoursesOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Bridesg Brwon Objects.
i = AllDraw.BridgeMidle
While i < AllDraw.BridgeHigh
Try
'When Brwon Bridges Non Existing Continue Traversal Back.
If BridgesOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(BridgesOnTable(i).Row, Integer)
jj = CType(BridgesOnTable(i).Column, Integer)
'Construction of Brwon Bridges With Local Variables.
Dummy.BridgesOnTable(i) = New DrawBridge(ii, jj, a, Table, Order, False,
i)
'For All Possible Bridges Movments.
j = 0
While j < AllDraw.BridgeMovments
'Thinking of Brwon Bridges Operations.
Dummy.BridgesOnTable(i).BridgeThinking(j).Table = BridgesOnTable(i).BridgeThinking(j).Table
Dummy.BridgesOnTable(i).BridgeThinking(j).ThinkingBegin = True
Dummy.BridgesOnTable(i).BridgeThinking(j).ThinkingFinished = False
Dummy.BridgesOnTable(i).BridgeThinking(j).t = New Thread(AddressOf Dummy.BridgesOnTable(i).BridgeThinking(j).Thinking)
Dummy.BridgesOnTable(i).BridgeThinking(j).t.Start()
'Wait For Thinking Finsishing.
Wait(Dummy, i, j, 4)
j += 1
End While
Catch t As Exception
Dummy.BridgesOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Possible Brown Minster Objects.
i = AllDraw.MinisterMidle
While i < AllDraw.MinisterHigh
Try
'When Brwon Minister Non Existing Continue Traversal Back.
If MinisterOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(MinisterOnTable(i).Row, Integer)
jj = CType(MinisterOnTable(i).Column, Integer)
'Construction of Brown Minister Thinking Objects.
Dummy.MinisterOnTable(i) = New DrawMinister(ii, jj, a, Table, Order, False,
i)
'For All Possible Minister Brown Movments.
j = 0
While j < AllDraw.MinisterMovments
'Brown Minister Thinking Operations.
Dummy.MinisterOnTable(i).MinisterThinking(j).Table = MinisterOnTable(i).MinisterThinking(j).Table
Dummy.MinisterOnTable(i).MinisterThinking(j).ThinkingBegin = True
Dummy.MinisterOnTable(i).MinisterThinking(j).ThinkingFinished = False
Dummy.MinisterOnTable(i).MinisterThinking(j).t = New Thread(AddressOf Dummy.MinisterOnTable(i).MinisterThinking(j).Thinking)
Dummy.MinisterOnTable(i).MinisterThinking(j).t.Start()
Wait(Dummy, i, j, 5)
j += 1
End While
Catch t As Exception
Dummy.MinisterOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
'For All Brown King Objects.
i = AllDraw.KingMidle
While i < AllDraw.KingHigh
Try
'When Brown King Non Existing Continue Traversal Back.
If KingOnTable(i) Is Nothing Then
i += 1
Continue While
End If
'Initiate Local Variables.
ii = CType(KingOnTable(i).Row, Integer)
jj = CType(KingOnTable(i).Column, Integer)
'Construction of Brown King Thinking Operation.
Dummy.KingOnTable(i) = New DrawKing(ii, jj, a, Table, Order, False,
i)
'For All Possible Brown King Movements.
j = 0
While j < AllDraw.KingMovments
'Thinking of Brown King Thinking Operations.
Dummy.KingOnTable(i).KingThinking(j).Table = KingOnTable(i).KingThinking(j).Table
Dummy.KingOnTable(i).KingThinking(j).ThinkingBegin = True
Dummy.KingOnTable(i).KingThinking(j).ThinkingFinished = False
Dummy.KingOnTable(i).KingThinking(j).t = New Thread(AddressOf Dummy.KingOnTable(i).KingThinking(j).Thinking)
Dummy.KingOnTable(i).KingThinking(j).t.Start()
'Wait For Thinking Finished.
Wait(Dummy, i, j, 6)
j += 1
End While
Catch t As Exception
Dummy.KingOnTable(i) = Nothing
Log(t)
End Try
i += 1
End While
End If
'AllDraw Store = new AllDraw();
'Dummy.Clone(ref Store);
'Add To List.
AAllDraw.Add(Dummy)
End Sub
'Rearrange AllDraw Object Content.
Public Sub SetRowColumn(index As Integer)
Try
Dim i As Integer
Move = 0
'Intiate Dummy Variables.
Dim So1 As Integer = 0
Dim So2 As Integer = AllDraw.SodierMidle
Dim El1 As Integer = 0
Dim El2 As Integer = AllDraw.ElefantMidle
Dim Ho1 As Integer = 0
Dim Ho2 As Integer = AllDraw.HourseMidle
Dim Br1 As Integer = 0
Dim Br2 As Integer = AllDraw.BridgeMidle
Dim Mi1 As Integer = 0
Dim Mi2 As Integer = AllDraw.MinisterMidle
Dim Ki1 As Integer = 0
Dim Ki2 As Integer = AllDraw.KingMidle
'When Conversion Occured.
'if (AllDraw.SodierConversionOcuured)
If True Then
'AAllDraw = new List<AllDraw>();
SolderesOnTable = New DrawSoldier(AllDraw.SodierHigh) {}
i = 0
While i < AllDraw.SodierHigh
SolderesOnTable(i) = New DrawSoldier()
i += 1
End While
ElephantOnTable = New DrawElefant(AllDraw.ElefantHigh) {}
i = 0
While i < AllDraw.ElefantHigh
ElephantOnTable(i) = New DrawElefant()
i += 1
End While
HoursesOnTable = New DrawHourse(AllDraw.HourseHight) {}
i = 0
While i < AllDraw.HourseHight
HoursesOnTable(i) = New DrawHourse()
i += 1
End While
BridgesOnTable = New DrawBridge(AllDraw.BridgeHigh) {}
i = 0
While i < AllDraw.BridgeHigh
BridgesOnTable(i) = New DrawBridge()
i += 1
End While
MinisterOnTable = New DrawMinister(AllDraw.MinisterHigh) {}
i = 0
While i < AllDraw.MinisterHigh
MinisterOnTable(i) = New DrawMinister()
i += 1
End While
KingOnTable = New DrawKing(AllDraw.KingHigh) {}
i = 0
While i < AllDraw.KingHigh
KingOnTable(i) = New DrawKing()
i += 1
End While
AllDraw.SodierConversionOcuured = False
End If
'When Table Exist.
If TableList.Count > 0 Then
'For Every Table Things.
Dim Column As Integer = 0
While Column < 8
Dim Row As Integer = 0
While Row < 8
'When Things are Soldiers.
If System.Math.Abs(Me.TableList(index)(Row, Column)) = 1 Then
'Determine Color
Dim a As Color
If Me.TableList(index)(Row, Column) > 0 Then
a = Color.Gray
Else
a = Color.Brown
End If
'When Color is Gray.
If a = Color.Gray Then
Try
'When Solders ate current location differs add move.
Try
If SolderesOnTable(So1).Row <> Row OrElse SolderesOnTable(So1).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construct Soder Gray.
SolderesOnTable(So1) = New DrawSoldier(Row, Column, a, Me.TableList(index), 1, False,
So1)
'Increase So1.
So1 += 1
If So1 > AllDraw.SodierMidle Then
AllDraw.SodierMidle += 1
AllDraw.SodierHigh += 1
End If
Catch t As Exception
Log(t)
End Try
Else
'When Color is Brown
Try
'When Solders ate current location differs add move.
Try
If SolderesOnTable(So2).Row <> Row OrElse SolderesOnTable(So2).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construct Soldeir Brown.
SolderesOnTable(So2) = New DrawSoldier(Row, Column, a, Me.TableList(index), -1, False,
So2)
'Increase So2.
So2 += 1
If So2 > AllDraw.SodierHigh Then
AllDraw.SodierHigh += 1
End If
Catch t As Exception
Log(t)
End Try
End If
'For Elephant Objects.
ElseIf System.Math.Abs(Me.TableList(index)(Row, Column)) = 2 Then
'Initiate Local Variables.
Dim a As Color
If Me.TableList(index)(Row, Column) > 0 Then
a = Color.Gray
Else
a = Color.Brown
End If
'If Gray Elepahnt
If a = Color.Gray Then
Try
Try
'Calculation of Movment Number.
If ElephantOnTable(El1).Row <> Row OrElse ElephantOnTable(El1).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction of Draw Object.
ElephantOnTable(El1) = New DrawElefant(Row, Column, a, Me.TableList(index), 1, False,
El1)
'Increament of Gray Index.
El1 += 1
'If New Object Increament Gray Objects.
If El1 > AllDraw.ElefantMidle Then
AllDraw.ElefantMidle += 1
AllDraw.ElefantHigh += 1
End If
Catch t As Exception
Log(t)
End Try
Else
'For Brown Elephant .Objects
Try
Try
'Calculation of Movments Numbers.
If ElephantOnTable(El2).Row <> Row OrElse ElephantOnTable(El2).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction of Draw Brown Elephant Object.
ElephantOnTable(El2) = New DrawElefant(Row, Column, a, Me.TableList(index), -1, False,
El2)
'Increament of Index.
El2 += 1
'When New Brown Elephant Object Increament of Index.
If El2 > AllDraw.ElefantHigh Then
AllDraw.ElefantHigh += 1
End If
Catch t As Exception
Log(t)
End Try
End If
'For Hourse Objects.
ElseIf System.Math.Abs(Me.TableList(index)(Row, Column)) = 3 Then
'Initiate Local Varibale and Color.
Dim a As Color
If Me.TableList(index)(Row, Column) > 0 Then
a = Color.Gray
Else
a = Color.Brown
End If
'If Gray Hourse.
If a = Color.Gray Then
Try
Try
'Calculation of Movments Number.
If HoursesOnTable(Ho1).Row <> Row OrElse HoursesOnTable(Ho1).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction of Draw Brwon Hourse.
HoursesOnTable(Ho1) = New DrawHourse(Row, Column, a, Me.TableList(index), 1, False,
Ho1)
'Increament of Index.
Ho1 += 1
'when There is New Gray Hourse Increase.
If Ho1 > AllDraw.HourseMidle Then
AllDraw.HourseMidle += 1
AllDraw.HourseHight += 1
End If
Catch t As Exception
Log(t)
End Try
Else
'For Brown Hourses.
Try
Try
'Calculation of Movments Number.
If HoursesOnTable(Ho2).Row <> Row Or HoursesOnTable(Ho2).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction of Draw Brown Hourse.
HoursesOnTable(Ho2) = New DrawHourse(Row, Column, a, Me.TableList(index), -1, False,
Ho2)
'Increament of Index.
Ho2 += 1
'When New Brown Hourse Exist Exist Index.
If Ho2 > AllDraw.HourseHight Then
AllDraw.HourseHight += 1
End If
Catch t As Exception
Log(t)
End Try
End If
'For Bridges Objects.
ElseIf System.Math.Abs(Me.TableList(index)(Row, Column)) = 4 Then
'Initiate of Local Variables.
Dim a As Color
If Me.TableList(index)(Row, Column) > 0 Then
a = Color.Gray
Else
a = Color.Brown
End If
'For Gray Color.
If a = Color.Gray Then
Try
Try
'Calculation of Movments Number.
If BridgesOnTable(Br1).Row <> Row OrElse BridgesOnTable(Br1).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction of New Draw Gray Bridges.
BridgesOnTable(Br1) = New DrawBridge(Row, Column, a, Me.TableList(index), 1, False,
Br1)
'Increamnt of Index.
Br1 += 1
'When New Gray Briges Increamnt Max Index.
If Br1 > AllDraw.BridgeMidle Then
AllDraw.BridgeMidle += 1
AllDraw.BridgeHigh += 1
End If
Catch t As Exception
Log(t)
End Try
Else
'For Brown Bridges.
Try
Try
'Calculation of Movments Number.
If BridgesOnTable(Br2).Row <> Row OrElse BridgesOnTable(Br2).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction Draw of New Brown Bridges.
BridgesOnTable(Br2) = New DrawBridge(Row, Column, a, Me.TableList(index), -1, False,
Br2)
'Increament of Index.
Br2 += 1
'wehn Brwon New Bridges Detected Increament Max Index.
If Br2 > AllDraw.BridgeHigh Then
AllDraw.BridgeHigh += 1
End If
Catch t As Exception
Log(t)
End Try
End If
'For Minister Objects.
ElseIf System.Math.Abs(Me.TableList(index)(Row, Column)) = 5 Then
'Initiate Local Color Varibales.
Dim a As Color
If Me.TableList(index)(Row, Column) > 0 Then
a = Color.Gray
Else
a = Color.Brown
End If
'For Gray Colors.
If a = Color.Gray Then
Try
Try
'Clculationb of Movments Number.
If MinisterOnTable(Mi1).Row <> Row OrElse MinisterOnTable(Mi1).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'construction of new draw Gray Minster.
MinisterOnTable(Mi1) = New DrawMinister(Row, Column, a, Me.TableList(index), 1, False,
Mi1)
'Increament of Index.
Mi1 += 1
'Wehn New Gray Minster Detected Increament Max Indexes.
If Mi1 > AllDraw.MinisterMidle Then
AllDraw.MinisterMidle += 1
AllDraw.MinisterHigh += 1
End If
Catch t As Exception
Log(t)
End Try
Else
'For Brwon Colors.
Try
Try
'Calculation of Movments Number.
If MinisterOnTable(Mi2).Row <> Row OrElse MinisterOnTable(Mi2).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction of New Draw Brwon Minster.
MinisterOnTable(Mi2) = New DrawMinister(Row, Column, a, Me.TableList(index), -1, False,
Mi2)
'Increament Index.
Mi2 += 1
'When New Brown Minister Detected Increament Max Index.
If Mi2 > AllDraw.MinisterHigh Then
AllDraw.MinisterHigh += 1
End If
Catch t As Exception
Log(t)
End Try
End If
'for King Objects.
ElseIf System.Math.Abs(Me.TableList(index)(Row, Column)) = 6 Then
'Initiate Of Color.
Dim a As Color
If Me.TableList(index)(Row, Column) > 0 Then
a = Color.Gray
Else
a = Color.Brown
End If
'Color consideration.
If a = Color.Gray Then
Try
Try
'Calculation of Movments Number.
If KingOnTable(Ki1).Row <> Row OrElse KingOnTable(Ki1).Column <> Column Then
Move += 1
End If
Catch t As Exception
Log(t)
End Try
'Construction of New Draw Gray King.
KingOnTable(Ki1) = New DrawKing(Row, Column, a, Me.TableList(index), 1, False,
Ki1)
'Increament of Index.
Ki1 += 1
'when New Draw Object Detected Increament Max Index.
If Ki1 > AllDraw.KingMidle Then
AllDraw.KingMidle += 1
AllDraw.KingHigh += 1