Check-in [61e704ab66]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: half files still need to be implemented, please try to go through the code play.jl so that you may know where to merege your files
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:61e704ab66bbae0a0ec43a6b4e589a384c730447
User & Date: hhammadu 2016-11-29 05:12:31
Context
2016-11-29
05:14
images of pieces check-in: 4d49120558 user: hhammadu tags: trunk
05:12
half files still need to be implemented, please try to go through the code play.jl so that you may know where to merege your files check-in: 61e704ab66 user: hhammadu tags: trunk
04:19
infrastructure of game check-in: 914c78945f user: hhammadu tags: trunk
Changes

Added GUI.jl.





























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
module GUI
push!(LOAD_PATH,pwd())

if Pkg.installed("Gtk") == nothing
    Pkg.add("Gtk")
end

if Pkg.installed("IJulia") == nothing
    Pkg.add("IJulia")
	Pkg.build("IJulia")
end

if Pkg.installed("ImageView") == nothing
    Pkg.add("ImageView")
end

if Pkg.installed("Images") == nothing
    Pkg.add("Images")
end

if Pkg.installed("Colors") == nothing
    Pkg.add("Colors")
end

if Pkg.installed("ImageMagick") == nothing
    Pkg.add("ImageMagick")
end

using Gtk.ShortNames
using IJulia
using ImageView, Images
using Colors
using ImageMagick
export Set_board
export put_piece
function Set_board(gamesize)
	s = gamesize
	if s == 12
		brown = imread("brown.png")
		Dbrown = imread("Dbrown.png")
	elseif s == 9
		brown = imread("brownS.png")
		Dbrown = imread("DbrownS.png")
	else 
		brown = imread("brownM.png")
		Dbrown = imread("DbrownM.png")
	end
	c = ImageView.canvasgrid(s,s)
	
	for i= 1:s
		for j=1:2:s
			if i%2 == 1
				ImageView.view(c[i,j],brown)
				if j+1 <= s
					ImageView.view(c[i,j+1],Dbrown)
				end
			else
				if j+1 <= s
					ImageView.view(c[i,j+1],brown)
				end
				ImageView.view(c[i,j],Dbrown)
			end
		end
	end
	return c
end

type chess
  x_axis::Int8
  y_axis::Int8
  status::Bool # status 1 for live / 0 for captured
  promotion::Bool # promotion = promotion status; 1 for active promotion
  view::Char #view = chess' view by char
  player::Int8 # 1 for player 1 / 0 for player 2
end

function put_piece(gamesize,board,c)
	sourcex = board.y_axis
	print(sourcex)
	
	sourcey = board.x_axis
	print(sourcey)
	promoted = board.promotion
	print(promoted)
	piece = board.view
	print(piece)
	if gamesize == 5
		if(board.player == 1) 
			if piece == 'k'
				ImageView.view(c[sourcex,sourcey], imread("BkingM.png"))

			elseif((piece == 'b') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PbishopBM.png"))
		              

			elseif((piece == 'p') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PpawnMB.png"))

			elseif((piece == 'r') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("ProokBM.png"))
		   
			elseif((piece == 's') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PsilverBM.png"))

			elseif(piece == 's')
				ImageView.view(c[sourcex,sourcey], imread("silverBM.png"))

			elseif(piece == 'b')
				ImageView.view(c[sourcex,sourcey], imread("bishopBM.png"))

			elseif(piece == 'g')
				ImageView.view(c[sourcex,sourcey], imread("goldBM.png"))
			
			elseif(piece == 'p')
				ImageView.view(c[sourcex,sourcey], imread("pawnMB.png"))

			elseif(piece == 'r')
				ImageView.view(c[sourcex,sourcey], imread("rookBM.png"))
			end
		end
		
		if(board.player == 0)                          

			if(piece == 'k')
				ImageView.view(c[sourcex,sourcey], imread("WkingM.png"))

			elseif((piece == 'b') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PbishopWM.png"))
		  

			elseif((piece == 'p') && (promoted == true))
				ImageView.view(c[sourcex,sourcey],imread("PpawnWM.png"))

			elseif(piece == 'p')
				ImageView.view(c[sourcex,sourcey], imread("pawnWM.png"))

			elseif((piece == 'r') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("ProokWM.png"))
       
			elseif((piece == 's') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PsilverWM.png"))

			elseif(piece == 's')
				ImageView.view(c[sourcex,sourcey], imread("silverWM.png"))

			elseif(piece == 'b')
				ImageView.view(c[sourcex,sourcey], imread("bishopWM.png"))

			elseif(piece == 'g')
				ImageView.view(c[sourcex,sourcey], imread("goldWM.png"))

			elseif(piece == 'r')
				ImageView.view(c[sourcex,sourcey], imread("rookWM.png"))
			end
		end
	elseif (gamesize == 9)
		if(board.player == 1)
			if piece == 'k'
				ImageView.view(c[sourcex,sourcey], imread("BkingS.png"))
			
			elseif((piece == 'b') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PbishopBS.png"))
			
			elseif((piece == 'p') && (promoted == true))
				ImageView.view(c[sourcex,sourcey],imread("PpawnBS.png"))
			
			elseif(piece == 'p')
				ImageView.view(c[sourcex,sourcey], imread("pawnBS.png"))
				
			elseif((piece == 'r') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("ProokBS.png"))
				
			elseif((piece == 's') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PsilverBS.png"))
			
			elseif(piece == 's')
				ImageView.view(c[sourcex,sourcey], imread("silverBS.png"))
			
			elseif(piece == 'b')
				ImageView.view(c[sourcex,sourcey], imread("bishopBS.png"))
				
			elseif(piece == 'g')
				ImageView.view(c[sourcex,sourcey], imread("goldBS.png"))
			
			elseif(piece == 'r')
				ImageView.view(c[sourcex,sourcey], imread("rookBS.png"))
			
			
			elseif((piece == 'l') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PlanceBS.png"))
			
			
			elseif(piece == 'l')
				ImageView.view(c[sourcex,sourcey], imread("lanceBS.png"))
			
			
			elseif((piece == 'n') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PknightBS.png"))
			
			
			elseif(piece == 'n')
				ImageView.view(c[sourcex,sourcey], imread("knightBS.png"))
			end
		end	
		if(board.player == 0)
			if piece == 'k'
				ImageView.view(c[sourcex,sourcey], imread("WkingS.png"))
			
			elseif((piece == 'b') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PbishopWS.png"))
			
			elseif((piece == 'p') && (promoted == true))
				ImageView.view(c[sourcex,sourcey],imread("PpawnWS.png"))
			
			elseif(piece == 'p')
				ImageView.view(c[sourcex,sourcey], imread("pawnWS.png"))
				
			elseif((piece == 'r') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("ProokWS.png"))
				
			elseif((piece == 's') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PsilverWS.png"))
			
			elseif(piece == 's')
				ImageView.view(c[sourcex,sourcey], imread("silverWS.png"))
			
			elseif(piece == 'b')
				ImageView.view(c[sourcex,sourcey], imread("bishopWS.png"))
				
			elseif(piece == 'g')
				ImageView.view(c[sourcex,sourcey], imread("goldWS.png"))
			
			elseif(piece == 'r')
				ImageView.view(c[sourcex,sourcey], imread("rookWS.png"))
			
			
			elseif((piece == 'l') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PlanceWS.png"))
			
			
			elseif(piece == 'l')
				ImageView.view(c[sourcex,sourcey], imread("lanceWS.png"))
			
			
			elseif((piece == 'n') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PknightWS.png"))
			
			
			elseif(piece == 'n')
				ImageView.view(c[sourcex,sourcey], imread("knightWS.png"))
			end
		end
	else
		if(board.player == 1)
			if piece == 'k'
				ImageView.view(c[sourcex,sourcey], imread("BkingC.png"))
			
			elseif((piece == 'b') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PbishopBC.png"))
			
			elseif((piece == 'p') && (promoted == true))
				ImageView.view(c[sourcex,sourcey],imread("PpawnBC.png"))
			
			elseif(piece == 'p')
				ImageView.view(c[sourcex,sourcey], imread("pawnBC.png"))
				
			elseif((piece == 'r') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("ProokBC.png"))
				
			elseif((piece == 's') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PsilverBC.png"))
			
			elseif(piece == 's')
				ImageView.view(c[sourcex,sourcey], imread("silverBC.png"))
			
			elseif(piece == 'b')
				ImageView.view(c[sourcex,sourcey], imread("bishopBC.png"))
				
			elseif(piece == 'g')
				ImageView.view(c[sourcex,sourcey], imread("goldBC.png"))
			
			elseif(piece == 'r')
				ImageView.view(c[sourcex,sourcey], imread("rookBC.png"))
			
			
			elseif((piece == 'l') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PlanceBC.png"))
			
			
			elseif(piece == 'l')
				ImageView.view(c[sourcex,sourcey], imread("lanceBC.png"))
			
			
			elseif((piece == 'n') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PknightBC.png"))
			
			
			elseif(piece == 'n')
				ImageView.view(c[sourcex,sourcey], imread("knightBC.png"))
			
			
		
			elseif(piece == 'f')
				ImageView.view(c[sourcex,sourcey], imread("fBC.png"))
			
			
			
			elseif(piece == 'c' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PcBC.png"))
			
			
			elseif(piece == 'c')
				ImageView.view(c[sourcex,sourcey], imread("cBC.png"))
			
			
			elseif(piece == 'e' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PeBC.png"))
			
			
			elseif(piece == 'e')
				ImageView.view(c[sourcex,sourcey], imread("eBC.png"))
			
			
			elseif(piece == 'a' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PaBC.png"))
			
			
			elseif(piece == 'a')
				ImageView.view(c[sourcex,sourcey], imread("aBC.png"))
			
			
			elseif(piece == 't' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PtBC.png"))
			
			
			elseif(piece == 't')
				ImageView.view(c[sourcex,sourcey], imread("tBC.png"))
			
			elseif(piece == 'm' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PmBC.png"))
			
			
			elseif(piece == 'm')
				ImageView.view(c[sourcex,sourcey], imread("mBC.png"))
			
			
			elseif(piece == 'x' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PxBC.png"))
			
			
			elseif(piece == 'x')
				ImageView.view(c[sourcex,sourcey], imread("xBC.png"))
			
			
			elseif(piece == 'v' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PvBC.png"))
			
			
			elseif(piece == 'v')
				ImageView.view(c[sourcex,sourcey], imread("vBC.png"))
			
			
			elseif(piece == 'h' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PhBC.png"))
			
			
			elseif(piece == 'h')
				ImageView.view(c[sourcex,sourcey], imread("hBC.png"))
			
			
			elseif(piece == 'd' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PdBC.png"))
			
			
			elseif(piece == 'd')
				ImageView.view(c[sourcex,sourcey], imread("dBC.png"))
			
			
			elseif(piece == 'o' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PoBC.png"))
			
			
			elseif(piece == 'o')
				ImageView.view(c[sourcex,sourcey], imread("oBC.png"))
			
			
			elseif(piece == 'q' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PqBC.png"))
			
			elseif(piece == 'q')
				ImageView.view(c[sourcex,sourcey], imread("qBC.png"))
			
			
			elseif(piece == 'i' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PiBC.png"))
			
			
			elseif(piece == 'i')
				ImageView.view(c[sourcex,sourcey], imread("iBC.png"))
			end
			
		end	
		if(board.player == 0)
			if piece == 'k'
				ImageView.view(c[sourcex,sourcey], imread("WkingC.png"))
			
			elseif((piece == 'b') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PbishopWC.png"))
			
			elseif((piece == 'p') && (promoted == true))
				ImageView.view(c[sourcex,sourcey],imread("PpawnWC.png"))
			
			elseif(piece == 'p')
				ImageView.view(c[sourcex,sourcey], imread("pawnWC.png"))
				
			elseif((piece == 'r') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("ProokWC.png"))
				
			elseif((piece == 's') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PsilverWC.png"))
			
			elseif(piece == 's')
				ImageView.view(c[sourcex,sourcey], imread("silverWC.png"))
			
			elseif(piece == 'b')
				ImageView.view(c[sourcex,sourcey], imread("bishopWC.png"))
				
			elseif(piece == 'g')
				ImageView.view(c[sourcex,sourcey], imread("goldWC.png"))
			
			elseif(piece == 'r')
				ImageView.view(c[sourcex,sourcey], imread("rookWC.png"))
			
			
			elseif((piece == 'l') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PlanceWC.png"))
		
			
			elseif(piece == 'l')
				ImageView.view(c[sourcex,sourcey], imread("lanceWC.png"))
			
			
			elseif((piece == 'n') && (promoted == true))
				ImageView.view(c[sourcex,sourcey], imread("PknightWC.png"))
			
			
			elseif(piece == 'n')
				ImageView.view(c[sourcex,sourcey], imread("knightWC.png"))
			
			
			elseif(piece == 'f')
				ImageView.view(c[sourcex,sourcey], imread("fWC.png"))
			
			
			
			elseif(piece == 'c' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PcWC.png"))
			
			
			elseif(piece == 'c')
				ImageView.view(c[sourcex,sourcey], imread("cWC.png"))
			
			
			elseif(piece == 'e' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PeWC.png"))
			
			
			elseif(piece == 'e')
				ImageView.view(c[sourcex,sourcey], imread("eWC.png"))
			
			
			elseif(piece == 'a' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PaWC.png"))
			
			
			elseif(piece == 'a')
				ImageView.view(c[sourcex,sourcey], imread("aWC.png"))
			
			
			elseif(piece == 't' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PtWC.png"))
			
			
			elseif(piece == 't')
				ImageView.view(c[sourcex,sourcey], imread("tWC.png"))
			
			
			elseif(piece == 'm' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PmWC.png"))
			
			
			elseif(piece == 'm')
				ImageView.view(c[sourcex,sourcey], imread("mWC.png"))
			
			
			elseif(piece == 'x' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PxWC.png"))
			
			
			elseif(piece == 'x')
				ImageView.view(c[sourcex,sourcey], imread("xWC.png"))
			
			
			elseif(piece == 'v' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PvWC.png"))
			
			
			elseif(piece == 'v')
				ImageView.view(c[sourcex,sourcey], imread("vBC.png"))
			
			
			elseif(piece == 'h' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PhWC.png"))
			
			
			elseif(piece == 'h')
				ImageView.view(c[sourcex,sourcey], imread("hWC.png"))
			
			
			elseif(piece == 'd' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PdWC.png"))
			
			
			elseif(piece == 'd')
				ImageView.view(c[sourcex,sourcey], imread("dWC.png"))
			
			
			elseif(piece == 'o' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PoWC.png"))
			
			
			elseif(piece == 'o')
				ImageView.view(c[sourcex,sourcey], imread("oWC.png"))
			
			
			elseif(piece == 'q' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PqWC.png"))
			
			
			elseif(piece == 'q')
				ImageView.view(c[sourcex,sourcey], imread("qWC.png"))
			
			
			elseif(piece == 'i' && promoted == true)
				ImageView.view(c[sourcex,sourcey], imread("PiWC.png"))
			
			elseif(piece == 'i')
				ImageView.view(c[sourcex,sourcey], imread("iWC.png"))
			end
		end
		
	end
		
end # function



end ##module end

Changes to board_function.jl.

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
      synBoard(board, chess(i,4,1,0,'p',0))
      synBoard(board, chess(i,9,1,0,'p',1))
    end
  end
  return board
end

function displayCurr1(board)
  gamesize = size(board,1)
  c = Set_board(gamesize)
  for j = 1:gamesize
	for i = 1: gamesize
		put_piece(gamesize,board[j,i],c)
	end
  end
end
function displayCurr(board)
  gamesize = size(board,1)
  print("\n")
  print(repeat("-",gamesize*2+1))
  print("\n")
  for j = 1:gamesize
    print("|")
    for i = gamesize:-1:1







|








|







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
      synBoard(board, chess(i,4,1,0,'p',0))
      synBoard(board, chess(i,9,1,0,'p',1))
    end
  end
  return board
end

function displayCurr(board)
  gamesize = size(board,1)
  c = Set_board(gamesize)
  for j = 1:gamesize
	for i = 1: gamesize
		put_piece(gamesize,board[j,i],c)
	end
  end
end
function displayCurr1(board)
  gamesize = size(board,1)
  print("\n")
  print(repeat("-",gamesize*2+1))
  print("\n")
  for j = 1:gamesize
    print("|")
    for i = gamesize:-1:1

Added display.jl.





























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# need a gamesize in header file
# need type-chess defined
module display
push!(LOAD_PATH,pwd())
using SQLite
using board_function
using databases


global B = 0 # global flag for existence of board, 1 - exist

function display1(gamesize) # function that replay the game from start to end
  board = initializeBoard(gamesize)
  for i = 1:Length_Of_Tables(db,"moves")
    mv = Access_By_Move_Number(db,i) #Access each move from 1 to now [move_number, move_type, sourcex, sourcey, targetx, targety, option, i_am_cheating,targetx2,targety2]
	if mv[2] == "move"
      pro = 0
      if mv[7] == "!"
        pro = 1
      end
      temp = board[mv[3],mv[4]] # keep original piece data
      board[mv[3],mv[4]] = chess(mv[3],mv[4],0,0,'.',-1) # set source position to null chess
      board[mv[5],mv[6]] = temp # replace target position with original piece, dispite of what it used to be
      #modify the new position
      board[mv[5],mv[6]].x_axis = mv[5]
      board[mv[5],mv[6]].y_axis = mv[6]
      if pro == 1
        board[mv[5],mv[6]].view = uppercase(board[mv[5],mv[6]].view)
      end
    elseif mv[2] == "drop"
      now_play = i%2
      board[mv[5],mv[6]] = chess(mv[5],mv[6],1,0,mv[7][1],now_play)
    end
	if mv[9] == "NULL" && mv[10] == "NULL"
		displayCurr(board)
	else
		if mv[2] == "move"
			pro = 0
			if mv[7] == "!"
				pro = 1
			end
			temp = board[mv[5],mv[6]]
			board[mv[5],mv[6]] = chess(mv[5],mv[6],0,0,'.',-1)
			board[mv[9],mv[10]] = temp
			board[mv[9],mv[10]].x_axis = mv[9]
			board[mv[9],mv[10]].y_axis = mv[10]
			if pro == 1
				board[mv[9],mv[10]].view = uppercase(board[mv[9],mv[10]].view)
			end
		elseif mv[2] == "drop"
			now_play = i%2
			board[mv[9],mv[10]] = chess(mv[9],mv[10],1,0,mv[7][1],now_play)
		end
		displayCurr(board)
    end
  end
  print("\n")
end #function




############################################################################################################################################################################################

db = SQLite.DB("database.db")

meta_row = Access_By_key(db,"type")
if meta_row[2] == "standard"
  gamesize = 9
elseif meta_row[2] == "minishoghi"
  gamesize = 5
else
  gamesize = 12
end

display1(gamesize)

end # the end of display module

Changes to game.jl.

550
551
552
553
554
555
556


557
558
559
560
561
562
563
			push!(hbox2, Local)
			push!(hbox2, E_turn)
			showall(win)
		end

		id3 = signal_connect(replay, "clicked") do widget
			update_gameval(db,"replay")


			hbox2 = @Box(:v) 
			push!(f, hbox2)
			StartGamebutton = @Button("Start Game Now")
			id71 = signal_connect(StartGamebutton, "clicked") do widget
				println("call the module start")
				destroy(win)
			end







>
>







550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
			push!(hbox2, Local)
			push!(hbox2, E_turn)
			showall(win)
		end

		id3 = signal_connect(replay, "clicked") do widget
			update_gameval(db,"replay")
			destroy(hbox)
			
			hbox2 = @Box(:v) 
			push!(f, hbox2)
			StartGamebutton = @Button("Start Game Now")
			id71 = signal_connect(StartGamebutton, "clicked") do widget
				println("call the module start")
				destroy(win)
			end

Added join.jl.









>
>
>
>
1
2
3
4
module join
push!(LOAD_PATH,pwd())
println("Join need to be done")
end

Added move_user_move.jl.

































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#=
move_user_move.jl <filename> <xsource> <ysource> <xtarget> <ytarget> <promote>
-moves the piece at the source into the target area
-if promote is ”T”, promote the piece after completed the move
-do not attempt to validate the move
=#
module move_user_move
push!(LOAD_PATH,pwd())
using SQLite
using board_function

using databases
#connect to database
db = SQLite.DB("database.db")

#######################################################################################################################################################################################
#sets the board according to the given database
function database_to_board(board)
  query1 = "SELECT * FROM Player WHERE player = 1;"
  p1_table=SQLite.query(db,query1)
  l1=size(p1_table)[1]
  query2 = "SELECT * FROM Player WHERE player = 0;"
  p2_table=SQLite.query(db,query2)
  l2=size(p2_table)[1]
  for i = 1:l1
    x = get(p1_table[2][i])
    y = get(p1_table[3][i])
    status = get(p1_table[4][i])
    promo = get(p1_table[5][i])
    piece = get(p1_table[6][i])[1]
    if status == 1
      if promo == 1
        board[x,y] = chess(x,y,status,promo,uppercase(piece),1)
      else
        board[x,y] = chess(x,y,status,promo,piece,1)
      end
	end
  end

  for i = 1:l2
    x = get(p2_table[2][i])
    y = get(p2_table[3][i])
    status = get(p2_table[4][i])
    promo = get(p2_table[5][i])
    piece = get(p2_table[6][i])[1]
    if status == 1
      if promo == 1
        board[x,y] = chess(x,y,status,promo,uppercase(piece),0)
      else
        board[x,y] = chess(x,y,status,promo,piece,0)
      end
    end
 end
end

#######################################################################################################################################################################################




########################################################################################################################################################################################

#check if piece exist at source x y and set up board

function Take_inputs(db,gamesize,now_play)
  t=time()
  if timed(db) == 1
	  update_time(db,t,"time_add")
	  if now_play == 1
		update_time(db,t,"gote_time")
		println("Time left for player 1:")
		println(get_time(db,"gote_time"))
	  else
		update_time(db,t,"sente_time")
		println("Time left for player 2:")
		println(get_time(db,"sente_time"))
	  end
	  print("\n")
  end
  results = check_win(db)
  if results == 1 
	println("\nGame Ended!\n")
	include("game.jl")
  end
  print("Please enter source x: ")
  s_x = readline(STDIN)
  s_x=parse(s_x)
  print("Please enter source y: ")
  s_y = readline(STDIN)
  s_y=parse(s_y)
  print("Please enter target x: ")
  t_x = readline(STDIN)
  t_x=parse(t_x)
  print("Please enter target y: ")
  t_y = readline(STDIN)
  t_y=parse(t_y)

  print("Please enter promote or not after move, 'T' if yes: ")
  p = readline(STDIN)
  if p[end]=='\n'
   p = p[1:end-1]
  end
  if p == "T"
    p = 1
  else
    p = 0
  end

  if board[s_x,s_y].view == '.'
    println("Error: There is no chess piece on the source position!")
	println("Enter valid input")
	quit()
  end

  if board[s_x,s_y].view != '.' && board[s_x,s_y].player != now_play
    println("Error: You are moving another player's piece")
	println("Enter valid input")
	quit()
  end

  if board[t_x,t_y].player == now_play
	println(board[t_x,t_y].view)
	println("Error: You are killing your own player")
	println("Enter valid input")
	println(now_play)
	quit()
  end
  t_x2=0
  t_y2=0

  if gamesize == 12
	print("Please enter target x 2:")
	t_x2 = readline(STDIN)
	t_x2 = parse(t_x2)
	if typeof(t_x2) == Void
		t_x2 = 0
	end
	print("Please enter target y 2:")
	t_y2 = readline(STDIN)
	t_y2 = parse(t_y2)
	if typeof(t_y2) == Void
		t_y2 = 0
	end
	if t_x2 != 0 && t_y2!=0
		if board[t_x2,t_y2].player == now_play
			println("Error: You are killing your own player")
			println("Enter valid input")
			println(now_play)
			quit()
		end
	end
  end
  return [s_x,s_y,t_x,t_y,t_x2,t_y2, p]
end

################################################################################################################################################################################

now_play = (Length_Of_Tables(db,"moves")+1)%2

board = emptyBoard(db)
gamesize = size(board,1)

database_to_board(board)

x_in = Take_inputs(db,gamesize,now_play)
s_x=x_in[1]
s_y=x_in[2]
t_x=x_in[3]
t_y=x_in[4]
t_x2=x_in[5]
t_y2=x_in[6]
pro=x_in[7]

println("now playing $now_play")

if gamesize == 5
	if board[t_x,t_y].view != '.' && board[t_x,t_y].player !=now_play
		query="DELETE FROM Player WHERE curr_x= $t_x AND curr_y = $t_y;"
		stmt=SQLite.Stmt(db,query)
		SQLite.execute!(stmt)
		na = board[t_x,t_y].view
		updatePlayer(db,now_play,0, 0, 0, 0, na)
	end
	query = "UPDATE Player SET curr_x= $t_x, curr_y = $t_y WHERE curr_x = $s_x AND curr_y = $s_y"
	SQLite.execute!(SQLite.Stmt(db,query))
elseif gamesize == 9
	if board[t_x,t_y].view != '.' && board[t_x,t_y].player !=now_play
		query="DELETE FROM Player WHERE curr_x= $t_x AND curr_y = $t_y;"
		stmt=SQLite.Stmt(db,query)
		SQLite.execute!(stmt)
		na = board[t_x,t_y].view
		updatePlayer(db,now_play,0, 0, 0, 0, na)
	end
	query = "UPDATE Player SET curr_x= $t_x, curr_y = $t_y WHERE curr_x = $s_x AND curr_y = $s_y"
	SQLite.execute!(SQLite.Stmt(db,query))
else
	if board[t_x,t_y].view != '.' && board[t_x,t_y].player !=now_play
		query="DELETE FROM Player WHERE curr_x= $t_x AND curr_y = $t_y;"
		stmt=SQLite.Stmt(db,query)
		SQLite.execute!(stmt)
		na = board[t_x,t_y].view
		updatePlayer(db,now_play,0, 0, 0, 0, na)
	end
	query = "UPDATE Player SET curr_x= $t_x, curr_y = $t_y WHERE curr_x = $s_x AND curr_y = $s_y"
	SQLite.execute!(SQLite.Stmt(db,query))
	if t_x2 !=0 && t_y2!=0
		if board[t_x2,t_y2].view != '.' && board[t_x2,t_y2].player !=now_play
			query="DELETE FROM Player WHERE curr_x= $t_x2 AND curr_y = $t_y2;"
			stmt=SQLite.Stmt(db,query)
			SQLite.execute!(stmt)
			na = board[t_x2,t_y2].view
			updatePlayer(db,now_play,0, 0, 0, 0, na)
		end

		query = "UPDATE Player SET curr_x= $t_x2, curr_y = $t_y2 WHERE curr_x = $t_x AND curr_y = $t_y"
		SQLite.execute!(SQLite.Stmt(db,query))
	end
end
#update moves table
if pro == 1
  updateMoves(db,Length_Of_Tables(db,"moves")+1,"move",s_x,s_y,t_x,t_y,"!",0,t_x2,t_y2)
  query = "UPDATE Player SET promotion= 1 WHERE curr_x = $t_x AND curr_y = $t_y"
  SQLite.execute!(SQLite.Stmt(db,query))
else
  updateMoves(db,Length_Of_Tables(db,"moves")+1,"move",s_x,s_y,t_x,t_y,0,0,t_x2,t_y2)
end

board_new = Matrix{chess}(gamesize,gamesize)
for i in 1:gamesize
  for j in 1:gamesize
    board_new[i,j] = chess(i,j,0,0,'.',-1) # Setup a null chess for every cell on the board
  end
end

database_to_board(board_new)
displayCurr(board_new)
while true
	include("move_user_move.jl")
end
end #module end

Changes to play.jl.

28
29
30
31
32
33
34
35





36












		include("starthost_human.jl")
	end
	x6 = get_optval(db,"host_email")
	if x6 == 1
		include("starthost_email.jl")
	end
end






end




















>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
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
		include("starthost_human.jl")
	end
	x6 = get_optval(db,"host_email")
	if x6 == 1
		include("starthost_email.jl")
	end
end

y = get_optval(db,"continue")
if y == 1
	y1 = get_optval(db,"e_turn")
	if y1 == 1
		include("e_turn.jl")
	end
	y2 = get_optval(db,"local")
	if y2 == 1
		include("move_user_move.jl")
	end
end

z = get_optval(db,"replay")
if z == 1
	include("display.jl")
end

end

Added starthuman.jl.













































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
module starthuman
push!(LOAD_PATH,pwd())
using SQLite
using databases
using board_function
gamesize = 0
######################################################################################################################################################################################
db = SQLite.DB("database.db")
function Decide_Type()
  minishoghi = get_optval(db,"minishoghi")
  stshoghi = get_optval(db,"stshoghi")
  chshoghi = get_optval(db,"chshoghi")
  if minishoghi == 1
	A2 = "M"
	global gamesize = 5
  end
  if stshoghi == 1
	A2 = "S"
	global gamesize = 9
  end
  if chshoghi == 1
	A2 = "C"
	global gamesize = 12
  end
  return A2
end

function Decide_Cheat()
  cheat = get_optval(db, "cheat")
  if cheat == 1
	A3 = "T"
  else
	A3 = "N"
  end
  return A3
end

function Timed()
	timed = get_optval(db, "timed")
	if timed == 1
		A4 = "timed"
	else
		A4 = "n"
	end
end

function Game_Setup()
  
  A2 = Decide_Type()
  A3 = Decide_Cheat()
  A4 = Timed()
  Result = [A2,A3,A4]
  return Result
end

Result = Game_Setup()
A2 = Result[1]
A3 = Result[2]
A4 = Result[3]



Create_Table(db,"meta")
Create_Table(db,"moves")
Create_Table(db,"Player")
updateMeta(db,A2,A3,A4,9999999999,9999999999)
####################################################################################################################################################################################


  #initialize the board
  board = initializeBoard(gamesize)

  #set up Player table
 if gamesize == 5
                  
	updatePlayer(db,1,1,5,1,0,"r")
    updatePlayer(db,0,5,1,1,0,"r")
    updatePlayer(db,0,4,1,1,0,"b") 
    updatePlayer(db,1,2,5,1,0,"b")
    updatePlayer(db,0,3,1,1,0,"s")
    updatePlayer(db,1,3,5,1,0,"s")
    updatePlayer(db,0,2,1,1,0,"g")
    updatePlayer(db,1,4,5,1,0,"g")
    updatePlayer(db,0,1,1,1,0,"k")
    updatePlayer(db,1,5,5,1,0,"k")
    updatePlayer(db,0,1,2,1,0,"p")
    updatePlayer(db,1,5,4,1,0,"p")
	                                  
  
  elseif gamesize == 9
    updatePlayer(db,0,1,1,1,0,"l")
	updatePlayer(db,0,9,1,1,0,"l")
	updatePlayer(db,1,1,9,1,0,"l")
	updatePlayer(db,1,9,9,1,0,"l")
	updatePlayer(db,0,2,1,1,0,"n")
	updatePlayer(db,0,8,1,1,0,"n")
	updatePlayer(db,1,2,9,1,0,"n")
	updatePlayer(db,1,8,9,1,0,"n")
	updatePlayer(db,0,3,1,1,0,"s")
	updatePlayer(db,0,7,1,1,0,"s")
	updatePlayer(db,1,3,9,1,0,"s")
	updatePlayer(db,1,7,9,1,0,"s")
	updatePlayer(db,0,4,1,1,0,"g")
	updatePlayer(db,0,6,1,1,0,"g")
	updatePlayer(db,1,4,9,1,0,"g")
	updatePlayer(db,1,6,9,1,0,"g")
	updatePlayer(db,0,5,1,1,0,"k")
	updatePlayer(db,1,5,9,1,0,"k")
	updatePlayer(db,0,8,2,1,0,"r")
	updatePlayer(db,1,2,8,1,0,'r')
	updatePlayer(db,0,2,2,1,0,"b")
	updatePlayer(db,1,8,8,1,0,"b")
	for i=1:9
		updatePlayer(db,0,i,3,1,0,"p")
		updatePlayer(db,1,i,7,1,0,"p")
	end
    else 
		updatePlayer(db,0,1,1,1,0,"l")
		updatePlayer(db,0,12,1,1,0,"l")
		updatePlayer(db,1,1,12,1,0,"l")
		updatePlayer(db,1,12,12,1,0,"l")
		updatePlayer(db,0,2,1,1,0,"f")
		updatePlayer(db,0,11,1,1,0,"f")
		updatePlayer(db,1,2,12,1,0,"f")
		updatePlayer(db,1,11,12,1,0,"f")
		updatePlayer(db,0,3,1,1,0,"c")
		updatePlayer(db,0,10,1,1,0,"c")
		updatePlayer(db,1,3,12,1,0,"c")
		updatePlayer(db,1,10,12,1,0,"c")
		updatePlayer(db,0,4,1,1,0,"s")
		updatePlayer(db,0,9,1,1,0,"s")
		updatePlayer(db,1,4,12,1,0,"s")
		updatePlayer(db,1,9,12,1,0,"s")
		updatePlayer(db,0,5,1,1,0,"g")
		updatePlayer(db,0,8,1,1,0,"g")
		updatePlayer(db,1,5,12,1,0,"g")
		updatePlayer(db,1,8,12,1,0,"g")
		updatePlayer(db,0,6,1,1,0,"k")
		updatePlayer(db,1,7,12,1,0,"k")
		updatePlayer(db,0,7,1,1,0,"e")
		updatePlayer(db,1,6,12,1,0,"e")
		updatePlayer(db,0,1,2,1,0,"a")
		updatePlayer(db,0,12,2,1,0,"a")
		updatePlayer(db,1,1,11,1,0,"a")
		updatePlayer(db,1,12,11,1,0,"a")
		updatePlayer(db,0,3,2,1,0,"b")
		updatePlayer(db,0,10,2,1,0,"b")
		updatePlayer(db,1,3,11,1,0,"b")
		updatePlayer(db,1,10,11,1,0,"b")
		updatePlayer(db,0,5,2,1,0,"t")
		updatePlayer(db,0,8,2,1,0,"t")
		updatePlayer(db,1,5,11,1,0,"t")
		updatePlayer(db,1,8,11,1,0,"t")
		updatePlayer(db,0,7,2,1,0,"x")
		updatePlayer(db,1,6,11,1,0,"x")
		updatePlayer(db,0,6,2,1,0,"n")
		updatePlayer(db,1,7,11,1,0,"n")
		updatePlayer(db,0,1,3,1,0,"m")
		updatePlayer(db,0,12,3,1,0,"m")
		updatePlayer(db,1,1,10,1,0,"m")
		updatePlayer(db,1,12,10,1,0,"m")
		updatePlayer(db,0,2,3,1,0,"v")
		updatePlayer(db,0,11,3,1,0,"v")
		updatePlayer(db,1,2,10,1,0,"v")
		updatePlayer(db,1,11,10,1,0,"v")
		updatePlayer(db,0,3,3,1,0,"r")
		updatePlayer(db,0,10,3,1,0,"r")
		updatePlayer(db,1,3,10,1,0,"r")
		updatePlayer(db,1,10,10,1,0,"r")
		updatePlayer(db,0,4,3,1,0,"h")
		updatePlayer(db,0,9,3,1,0,"h")
		updatePlayer(db,1,4,10,1,0,"h")
		updatePlayer(db,1,9,10,1,0,"h")
		updatePlayer(db,0,5,3,1,0,"d")
		updatePlayer(db,0,8,3,1,0,"d")
		updatePlayer(db,1,5,10,1,0,"d")
		updatePlayer(db,1,8,10,1,0,"d")
		updatePlayer(db,0,6,3,1,0,"i")
		updatePlayer(db,1,7,10,1,0,"i")
		updatePlayer(db,0,7,3,1,0,"q")
		updatePlayer(db,1,6,10,1,0,"q")
		updatePlayer(db,0,4,5,1,0,"o")
		updatePlayer(db,0,9,5,1,0,"o")
		updatePlayer(db,1,4,8,1,0,"o")
		updatePlayer(db,1,9,8,1,0,"o")
		for i=1:12
			updatePlayer(db,0,i,4,1,0,"p")
			updatePlayer(db,1,i,9,1,0,"p")
		end
		
end

displayCurr(board)
	
include("move_user_move.jl")


end

Added startjoin.jl.











































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
module startjoin
push!(LOAD_PATH,pwd())
using SQLite
using databases
using board_function
gamesize = 0
######################################################################################################################################################################################
db = SQLite.DB("database.db")
function Decide_Type()
  minishoghi = get_optval(db,"minishoghi")
  stshoghi = get_optval(db,"stshoghi")
  chshoghi = get_optval(db,"chshoghi")
  if minishoghi == 1
	A2 = "M"
	global gamesize = 5
  end
  if stshoghi == 1
	A2 = "S"
	global gamesize = 9
  end
  if chshoghi == 1
	A2 = "C"
	global gamesize = 12
  end
  return A2
end

function Decide_Cheat()
  cheat = get_optval(db, "cheat")
  if cheat == 1
	A3 = "T"
  else
	A3 = "N"
  end
  return A3
end

function Timed()
	timed = get_optval(db, "timed")
	if timed == 1
		A4 = "timed"
	else
		A4 = "n"
	end
end

function Game_Setup()
  
  A2 = Decide_Type()
  A3 = Decide_Cheat()
  A4 = Timed()
  Result = [A2,A3,A4]
  return Result
end

Result = Game_Setup()
A2 = Result[1]
A3 = Result[2]
A4 = Result[3]



Create_Table(db,"meta")
Create_Table(db,"moves")
Create_Table(db,"Player")
updateMeta(db,A2,A3,A4,9999999999,9999999999)
####################################################################################################################################################################################


  #initialize the board
  board = initializeBoard(gamesize)

  #set up Player table
 if gamesize == 5
                  
	updatePlayer(db,1,1,5,1,0,"r")
    updatePlayer(db,0,5,1,1,0,"r")
    updatePlayer(db,0,4,1,1,0,"b") 
    updatePlayer(db,1,2,5,1,0,"b")
    updatePlayer(db,0,3,1,1,0,"s")
    updatePlayer(db,1,3,5,1,0,"s")
    updatePlayer(db,0,2,1,1,0,"g")
    updatePlayer(db,1,4,5,1,0,"g")
    updatePlayer(db,0,1,1,1,0,"k")
    updatePlayer(db,1,5,5,1,0,"k")
    updatePlayer(db,0,1,2,1,0,"p")
    updatePlayer(db,1,5,4,1,0,"p")
	                                  
  
  elseif gamesize == 9
    updatePlayer(db,0,1,1,1,0,"l")
	updatePlayer(db,0,9,1,1,0,"l")
	updatePlayer(db,1,1,9,1,0,"l")
	updatePlayer(db,1,9,9,1,0,"l")
	updatePlayer(db,0,2,1,1,0,"n")
	updatePlayer(db,0,8,1,1,0,"n")
	updatePlayer(db,1,2,9,1,0,"n")
	updatePlayer(db,1,8,9,1,0,"n")
	updatePlayer(db,0,3,1,1,0,"s")
	updatePlayer(db,0,7,1,1,0,"s")
	updatePlayer(db,1,3,9,1,0,"s")
	updatePlayer(db,1,7,9,1,0,"s")
	updatePlayer(db,0,4,1,1,0,"g")
	updatePlayer(db,0,6,1,1,0,"g")
	updatePlayer(db,1,4,9,1,0,"g")
	updatePlayer(db,1,6,9,1,0,"g")
	updatePlayer(db,0,5,1,1,0,"k")
	updatePlayer(db,1,5,9,1,0,"k")
	updatePlayer(db,0,8,2,1,0,"r")
	updatePlayer(db,1,2,8,1,0,'r')
	updatePlayer(db,0,2,2,1,0,"b")
	updatePlayer(db,1,8,8,1,0,"b")
	for i=1:9
		updatePlayer(db,0,i,3,1,0,"p")
		updatePlayer(db,1,i,7,1,0,"p")
	end
    else 
		updatePlayer(db,0,1,1,1,0,"l")
		updatePlayer(db,0,12,1,1,0,"l")
		updatePlayer(db,1,1,12,1,0,"l")
		updatePlayer(db,1,12,12,1,0,"l")
		updatePlayer(db,0,2,1,1,0,"f")
		updatePlayer(db,0,11,1,1,0,"f")
		updatePlayer(db,1,2,12,1,0,"f")
		updatePlayer(db,1,11,12,1,0,"f")
		updatePlayer(db,0,3,1,1,0,"c")
		updatePlayer(db,0,10,1,1,0,"c")
		updatePlayer(db,1,3,12,1,0,"c")
		updatePlayer(db,1,10,12,1,0,"c")
		updatePlayer(db,0,4,1,1,0,"s")
		updatePlayer(db,0,9,1,1,0,"s")
		updatePlayer(db,1,4,12,1,0,"s")
		updatePlayer(db,1,9,12,1,0,"s")
		updatePlayer(db,0,5,1,1,0,"g")
		updatePlayer(db,0,8,1,1,0,"g")
		updatePlayer(db,1,5,12,1,0,"g")
		updatePlayer(db,1,8,12,1,0,"g")
		updatePlayer(db,0,6,1,1,0,"k")
		updatePlayer(db,1,7,12,1,0,"k")
		updatePlayer(db,0,7,1,1,0,"e")
		updatePlayer(db,1,6,12,1,0,"e")
		updatePlayer(db,0,1,2,1,0,"a")
		updatePlayer(db,0,12,2,1,0,"a")
		updatePlayer(db,1,1,11,1,0,"a")
		updatePlayer(db,1,12,11,1,0,"a")
		updatePlayer(db,0,3,2,1,0,"b")
		updatePlayer(db,0,10,2,1,0,"b")
		updatePlayer(db,1,3,11,1,0,"b")
		updatePlayer(db,1,10,11,1,0,"b")
		updatePlayer(db,0,5,2,1,0,"t")
		updatePlayer(db,0,8,2,1,0,"t")
		updatePlayer(db,1,5,11,1,0,"t")
		updatePlayer(db,1,8,11,1,0,"t")
		updatePlayer(db,0,7,2,1,0,"x")
		updatePlayer(db,1,6,11,1,0,"x")
		updatePlayer(db,0,6,2,1,0,"n")
		updatePlayer(db,1,7,11,1,0,"n")
		updatePlayer(db,0,1,3,1,0,"m")
		updatePlayer(db,0,12,3,1,0,"m")
		updatePlayer(db,1,1,10,1,0,"m")
		updatePlayer(db,1,12,10,1,0,"m")
		updatePlayer(db,0,2,3,1,0,"v")
		updatePlayer(db,0,11,3,1,0,"v")
		updatePlayer(db,1,2,10,1,0,"v")
		updatePlayer(db,1,11,10,1,0,"v")
		updatePlayer(db,0,3,3,1,0,"r")
		updatePlayer(db,0,10,3,1,0,"r")
		updatePlayer(db,1,3,10,1,0,"r")
		updatePlayer(db,1,10,10,1,0,"r")
		updatePlayer(db,0,4,3,1,0,"h")
		updatePlayer(db,0,9,3,1,0,"h")
		updatePlayer(db,1,4,10,1,0,"h")
		updatePlayer(db,1,9,10,1,0,"h")
		updatePlayer(db,0,5,3,1,0,"d")
		updatePlayer(db,0,8,3,1,0,"d")
		updatePlayer(db,1,5,10,1,0,"d")
		updatePlayer(db,1,8,10,1,0,"d")
		updatePlayer(db,0,6,3,1,0,"i")
		updatePlayer(db,1,7,10,1,0,"i")
		updatePlayer(db,0,7,3,1,0,"q")
		updatePlayer(db,1,6,10,1,0,"q")
		updatePlayer(db,0,4,5,1,0,"o")
		updatePlayer(db,0,9,5,1,0,"o")
		updatePlayer(db,1,4,8,1,0,"o")
		updatePlayer(db,1,9,8,1,0,"o")
		for i=1:12
			updatePlayer(db,0,i,4,1,0,"p")
			updatePlayer(db,1,i,9,1,0,"p")
		end
		
end

displayCurr(board)
	
include("join.jl")

end