diff --git a/Test_case/level_1/1.json b/Test_case/level_1/1.json new file mode 100644 index 0000000000000000000000000000000000000000..c5e2781dd2ec668d47ba45c116ceb856f5f038ea --- /dev/null +++ b/Test_case/level_1/1.json @@ -0,0 +1,17 @@ +{ + "upper": [ + [ + "r", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 4 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_1/2.json b/Test_case/level_1/2.json new file mode 100644 index 0000000000000000000000000000000000000000..a6cffaba84d25a56e1ef03c4f1a300671ae0c565 --- /dev/null +++ b/Test_case/level_1/2.json @@ -0,0 +1,17 @@ +{ + "upper": [ + [ + "p", + 4, + -3 + ] + ], + "lower": [ + [ + "r", + -4, + 4 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_1/3.json b/Test_case/level_1/3.json new file mode 100644 index 0000000000000000000000000000000000000000..ee99f904f5abbb59809df00d53c3fbd6f21b39ac --- /dev/null +++ b/Test_case/level_1/3.json @@ -0,0 +1,17 @@ +{ + "upper": [ + [ + "s", + 4, + -3 + ] + ], + "lower": [ + [ + "p", + -4, + 4 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_1/4.json b/Test_case/level_1/4.json new file mode 100644 index 0000000000000000000000000000000000000000..e9110b190153f82b221b7219c456455740a423bb --- /dev/null +++ b/Test_case/level_1/4.json @@ -0,0 +1,17 @@ +{ + "upper": [ + [ + "p", + -4, + 4 + ] + ], + "lower": [ + [ + "r", + 4, + -3 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_1/5.json b/Test_case/level_1/5.json new file mode 100644 index 0000000000000000000000000000000000000000..33fe4a0c907e407616b338a45d8c7afa8b1a1ace --- /dev/null +++ b/Test_case/level_1/5.json @@ -0,0 +1,17 @@ +{ + "upper": [ + [ + "s", + -4, + 4 + ] + ], + "lower": [ + [ + "p", + 4, + -3 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_1/6.json b/Test_case/level_1/6.json new file mode 100644 index 0000000000000000000000000000000000000000..5178988d3c2ec09646a66d45c507a78725868a5b --- /dev/null +++ b/Test_case/level_1/6.json @@ -0,0 +1,17 @@ +{ + "upper": [ + [ + "r", + -4, + 4 + ] + ], + "lower": [ + [ + "s", + 4, + -3 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/1.json b/Test_case/level_2/1.json new file mode 100644 index 0000000000000000000000000000000000000000..a944e4653e635f02c3e2ced8695e1946037426b6 --- /dev/null +++ b/Test_case/level_2/1.json @@ -0,0 +1,22 @@ +{ + "upper": [ + [ + "r", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 1 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/10.json b/Test_case/level_2/10.json new file mode 100644 index 0000000000000000000000000000000000000000..f60463813f00065579e8b52db496332a2e9f6ec7 --- /dev/null +++ b/Test_case/level_2/10.json @@ -0,0 +1,22 @@ +{ + "upper": [ + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "s", + -4, + 4 + ], + [ + "r", + 4, + -4 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/11.json b/Test_case/level_2/11.json new file mode 100644 index 0000000000000000000000000000000000000000..f30b6e1f30bbe24e7e4199a16e5da4ae3c7429e9 --- /dev/null +++ b/Test_case/level_2/11.json @@ -0,0 +1,27 @@ +{ + "upper": [ + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "p", + -4, + 0 + ], + [ + "s", + -4, + 4 + ], + [ + "r", + 4, + -4 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/12.json b/Test_case/level_2/12.json new file mode 100644 index 0000000000000000000000000000000000000000..e1723e3e0c42bfc9f9df78c7cf55d44d28ee238f --- /dev/null +++ b/Test_case/level_2/12.json @@ -0,0 +1,32 @@ +{ + "upper": [ + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "p", + -4, + 0 + ], + [ + "s", + -4, + 4 + ], + [ + "r", + 4, + -4 + ], + [ + "s", + 4, + -3 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/13.json b/Test_case/level_2/13.json new file mode 100644 index 0000000000000000000000000000000000000000..db2db60701f8850e6eb99e9358585601a50515fa --- /dev/null +++ b/Test_case/level_2/13.json @@ -0,0 +1,148 @@ +{ + "upper": [ + [ + "s", + 0, + 0 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 4 + ], + [ + "s", + 0, + -4 + ], + [ + "s", + 0, + 4 + ], + [ + "s", + 4, + -4 + ], + [ + "s", + 4, + 0 + ] + ], + "block": [ + [ + "", + -4, + 1 + ], + [ + "", + -4, + 2 + ], + [ + "", + -4, + 3 + ], + [ + "", + -3, + -1 + ], + [ + "", + -3, + 4 + ], + [ + "", + -2, + -2 + ], + [ + "", + -2, + 4 + ], + [ + "", + -1, + -3 + ], + [ + "", + -1, + -2 + ], + [ + "", + -1, + -1 + ], + [ + "", + -1, + 4 + ], + [ + "", + 0, + -1 + ], + [ + "", + 1, + -4 + ], + [ + "", + 1, + 3 + ], + [ + "", + 2, + -4 + ], + [ + "", + 2, + 2 + ], + [ + "", + 3, + -4 + ], + [ + "", + 3, + 1 + ], + [ + "", + 4, + -3 + ], + [ + "", + 4, + -2 + ], + [ + "", + 4, + -1 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_2/2.json b/Test_case/level_2/2.json new file mode 100644 index 0000000000000000000000000000000000000000..5e977697e6ef116588052229b923f91bece06859 --- /dev/null +++ b/Test_case/level_2/2.json @@ -0,0 +1,27 @@ +{ + "upper": [ + [ + "r", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 1 + ], + [ + "s", + -4, + 2 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/3.json b/Test_case/level_2/3.json new file mode 100644 index 0000000000000000000000000000000000000000..7426e92337248bf3917f55df43d3821bdd84f95f --- /dev/null +++ b/Test_case/level_2/3.json @@ -0,0 +1,57 @@ +{ + "upper": [ + [ + "r", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 1 + ], + [ + "s", + -4, + 2 + ], + [ + "s", + -4, + 3 + ], + [ + "s", + -4, + 4 + ], + [ + "s", + -1, + 2 + ], + [ + "s", + 0, + -2 + ], + [ + "s", + 1, + -4 + ], + [ + "s", + 2, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/4.json b/Test_case/level_2/4.json new file mode 100644 index 0000000000000000000000000000000000000000..ef4ed181b31670879334684c9ab562538cc98487 --- /dev/null +++ b/Test_case/level_2/4.json @@ -0,0 +1,57 @@ +{ + "upper": [ + [ + "p", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 1 + ], + [ + "s", + -4, + 2 + ], + [ + "s", + -4, + 3 + ], + [ + "s", + -4, + 4 + ], + [ + "s", + -1, + 2 + ], + [ + "s", + 0, + -2 + ], + [ + "s", + 1, + -4 + ], + [ + "s", + 2, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_2/5.json b/Test_case/level_2/5.json new file mode 100644 index 0000000000000000000000000000000000000000..eeb596f8d44dc6f7fd79ee392c3c852102205da7 --- /dev/null +++ b/Test_case/level_2/5.json @@ -0,0 +1,68 @@ +{ + "upper": [ + [ + "r", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 1 + ], + [ + "s", + -4, + 2 + ], + [ + "s", + -4, + 3 + ], + [ + "s", + -4, + 4 + ], + [ + "s", + -1, + 2 + ], + [ + "s", + 1, + -4 + ], + [ + "s", + 2, + 0 + ] + ], + "block": [ + [ + "", + 0, + -2 + ], + [ + "", + 0, + -1 + ], + [ + "", + 0, + 0 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_2/6.json b/Test_case/level_2/6.json new file mode 100644 index 0000000000000000000000000000000000000000..fb05a7de439d537a59bb099730e296a6a23db27e --- /dev/null +++ b/Test_case/level_2/6.json @@ -0,0 +1,78 @@ +{ + "upper": [ + [ + "r", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 2 + ], + [ + "s", + -4, + 3 + ], + [ + "s", + -4, + 4 + ], + [ + "s", + -1, + 2 + ], + [ + "s", + 1, + -4 + ], + [ + "s", + 2, + 0 + ] + ], + "block": [ + [ + "", + -4, + 1 + ], + [ + "", + -3, + -1 + ], + [ + "", + -3, + 0 + ], + [ + "", + 0, + -2 + ], + [ + "", + 0, + -1 + ], + [ + "", + 0, + 0 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_2/7.json b/Test_case/level_2/7.json new file mode 100644 index 0000000000000000000000000000000000000000..14abc47d482d7a3d94b1be4741c000be51060ebc --- /dev/null +++ b/Test_case/level_2/7.json @@ -0,0 +1,63 @@ +{ + "upper": [ + [ + "r", + 4, + -4 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "s", + -4, + 4 + ], + [ + "s", + -1, + 2 + ], + [ + "s", + 2, + 0 + ] + ], + "block": [ + [ + "", + -4, + 2 + ], + [ + "", + -3, + -1 + ], + [ + "", + -3, + 0 + ], + [ + "", + 0, + -2 + ], + [ + "", + 0, + -1 + ], + [ + "", + 0, + 0 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_2/8.json b/Test_case/level_2/8.json new file mode 100644 index 0000000000000000000000000000000000000000..32e5aeda6f0d8c74d9971859a6669a8314ce34dd --- /dev/null +++ b/Test_case/level_2/8.json @@ -0,0 +1,58 @@ +{ + "upper": [ + [ + "p", + 4, + -4 + ] + ], + "lower": [ + [ + "r", + -4, + 4 + ], + [ + "r", + 2, + 0 + ] + ], + "block": [ + [ + "", + -4, + 2 + ], + [ + "", + -3, + -1 + ], + [ + "", + -3, + 0 + ], + [ + "", + -1, + 2 + ], + [ + "", + 0, + -2 + ], + [ + "", + 0, + -1 + ], + [ + "", + 0, + 0 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_2/9.json b/Test_case/level_2/9.json new file mode 100644 index 0000000000000000000000000000000000000000..4415cead86caf108da8f84b0d3b6a34a3aeabc1c --- /dev/null +++ b/Test_case/level_2/9.json @@ -0,0 +1,63 @@ +{ + "upper": [ + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "r", + -4, + 4 + ], + [ + "r", + 4, + -4 + ] + ], + "block": [ + [ + "", + -4, + 2 + ], + [ + "", + -3, + -1 + ], + [ + "", + -3, + 0 + ], + [ + "", + -1, + 2 + ], + [ + "", + 0, + -2 + ], + [ + "", + 0, + -1 + ], + [ + "", + 0, + 0 + ], + [ + "", + 2, + 0 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_3/1.json b/Test_case/level_3/1.json new file mode 100644 index 0000000000000000000000000000000000000000..c09dda24afe0664f25775e106b042a98d8bad41b --- /dev/null +++ b/Test_case/level_3/1.json @@ -0,0 +1,27 @@ +{ + "upper": [ + [ + "p", + -3, + 3 + ], + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "r", + -4, + 0 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_3/10.json b/Test_case/level_3/10.json new file mode 100644 index 0000000000000000000000000000000000000000..273cde4aa9a24e89cd1be29efb0944ccf593d41f --- /dev/null +++ b/Test_case/level_3/10.json @@ -0,0 +1,63 @@ +{ + "upper": [ + [ + "p", + 2, + -3 + ], + [ + "s", + 2, + 1 + ] + ], + "lower": [ + [ + "r", + -2, + 4 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [ + [ + "", + -4, + 1 + ], + [ + "", + -3, + 1 + ], + [ + "", + -2, + 1 + ], + [ + "", + -1, + 1 + ], + [ + "", + 0, + 1 + ], + [ + "", + 1, + 1 + ], + [ + "", + 3, + 1 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_3/11.json b/Test_case/level_3/11.json new file mode 100644 index 0000000000000000000000000000000000000000..4208779bb028ac0b92f5dd2bc4881a92940d0008 --- /dev/null +++ b/Test_case/level_3/11.json @@ -0,0 +1,68 @@ +{ + "upper": [ + [ + "r", + -1, + 3 + ], + [ + "p", + 2, + -3 + ] + ], + "lower": [ + [ + "r", + -2, + 4 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [ + [ + "", + -4, + 1 + ], + [ + "", + -3, + 1 + ], + [ + "", + -2, + 1 + ], + [ + "", + -1, + 1 + ], + [ + "", + 0, + 1 + ], + [ + "", + 0, + 3 + ], + [ + "", + 1, + 1 + ], + [ + "", + 3, + 1 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_3/2.json b/Test_case/level_3/2.json new file mode 100644 index 0000000000000000000000000000000000000000..8e24fb4a6c809aac2fb8b9ee8357887a14443ab9 --- /dev/null +++ b/Test_case/level_3/2.json @@ -0,0 +1,32 @@ +{ + "upper": [ + [ + "p", + -3, + 3 + ], + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "r", + -4, + 0 + ], + [ + "r", + -4, + 4 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_3/3.json b/Test_case/level_3/3.json new file mode 100644 index 0000000000000000000000000000000000000000..497dcd5fcf70060e39a9daaa272b798954830a5b --- /dev/null +++ b/Test_case/level_3/3.json @@ -0,0 +1,22 @@ +{ + "upper": [ + [ + "p", + -3, + 3 + ], + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "r", + 4, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_3/4.json b/Test_case/level_3/4.json new file mode 100644 index 0000000000000000000000000000000000000000..c8aa28f01ae08b0473d7277ed19bf3271f97e8bb --- /dev/null +++ b/Test_case/level_3/4.json @@ -0,0 +1,32 @@ +{ + "upper": [ + [ + "p", + -3, + 3 + ], + [ + "p", + -1, + 1 + ] + ], + "lower": [ + [ + "r", + 2, + 2 + ], + [ + "r", + 3, + 1 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_3/5.json b/Test_case/level_3/5.json new file mode 100644 index 0000000000000000000000000000000000000000..88ad98584301b4553a7d5791a9c570ff01af2a51 --- /dev/null +++ b/Test_case/level_3/5.json @@ -0,0 +1,32 @@ +{ + "upper": [ + [ + "p", + -1, + 1 + ], + [ + "r", + 0, + 1 + ] + ], + "lower": [ + [ + "r", + 2, + 2 + ], + [ + "r", + 3, + 1 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_3/6.json b/Test_case/level_3/6.json new file mode 100644 index 0000000000000000000000000000000000000000..26a7232c5fa2d55b0ba17959e3b754df721bd70f --- /dev/null +++ b/Test_case/level_3/6.json @@ -0,0 +1,32 @@ +{ + "upper": [ + [ + "p", + -1, + 1 + ], + [ + "s", + 2, + 1 + ] + ], + "lower": [ + [ + "r", + 2, + 2 + ], + [ + "r", + 3, + 1 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_3/7.json b/Test_case/level_3/7.json new file mode 100644 index 0000000000000000000000000000000000000000..b3ff22fd4cfa513fd082e0a0fc9b35176e7d3d6b --- /dev/null +++ b/Test_case/level_3/7.json @@ -0,0 +1,33 @@ +{ + "upper": [ + [ + "p", + -1, + 1 + ], + [ + "s", + 2, + 1 + ] + ], + "lower": [ + [ + "r", + 2, + 2 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [ + [ + "", + 3, + 1 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_3/8.json b/Test_case/level_3/8.json new file mode 100644 index 0000000000000000000000000000000000000000..0b5b5e00f3fc05e7b8448bab2dece004a08c5673 --- /dev/null +++ b/Test_case/level_3/8.json @@ -0,0 +1,48 @@ +{ + "upper": [ + [ + "s", + 2, + 1 + ], + [ + "p", + 4, + -4 + ] + ], + "lower": [ + [ + "r", + -2, + 4 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [ + [ + "", + -1, + 1 + ], + [ + "", + 0, + 1 + ], + [ + "", + 1, + 1 + ], + [ + "", + 3, + 1 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_3/9.json b/Test_case/level_3/9.json new file mode 100644 index 0000000000000000000000000000000000000000..905b5878e773f29483f389555832bf97c51f0258 --- /dev/null +++ b/Test_case/level_3/9.json @@ -0,0 +1,58 @@ +{ + "upper": [ + [ + "p", + 2, + -3 + ], + [ + "s", + 2, + 1 + ] + ], + "lower": [ + [ + "r", + -2, + 4 + ], + [ + "r", + 4, + 0 + ] + ], + "block": [ + [ + "", + -3, + 1 + ], + [ + "", + -2, + 1 + ], + [ + "", + -1, + 1 + ], + [ + "", + 0, + 1 + ], + [ + "", + 1, + 1 + ], + [ + "", + 3, + 1 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_4/1.json b/Test_case/level_4/1.json new file mode 100644 index 0000000000000000000000000000000000000000..7863e69b2783bec2cb71870b1640f97ade19cb00 --- /dev/null +++ b/Test_case/level_4/1.json @@ -0,0 +1,27 @@ +{ + "upper": [ + [ + "r", + 2, + -4 + ], + [ + "p", + 2, + -3 + ], + [ + "p", + 3, + -4 + ] + ], + "lower": [ + [ + "s", + 4, + 0 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_4/2.json b/Test_case/level_4/2.json new file mode 100644 index 0000000000000000000000000000000000000000..6899b9b605765614165fc4a6d541afbdc37c2595 --- /dev/null +++ b/Test_case/level_4/2.json @@ -0,0 +1,33 @@ +{ + "upper": [ + [ + "r", + 2, + -4 + ], + [ + "s", + 2, + -3 + ], + [ + "p", + 3, + -4 + ] + ], + "lower": [ + [ + "s", + 4, + 0 + ] + ], + "block": [ + [ + "", + 3, + -3 + ] + ] +} \ No newline at end of file diff --git a/Test_case/level_4/3.json b/Test_case/level_4/3.json new file mode 100644 index 0000000000000000000000000000000000000000..838eb349fc047afce8609ed4af4c0439e443b5ba --- /dev/null +++ b/Test_case/level_4/3.json @@ -0,0 +1,37 @@ +{ + "upper": [ + [ + "s", + 0, + -1 + ], + [ + "r", + 0, + 0 + ], + [ + "p", + 0, + 1 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "p", + -4, + 2 + ], + [ + "r", + -4, + 4 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_4/4.json b/Test_case/level_4/4.json new file mode 100644 index 0000000000000000000000000000000000000000..862f4f826036aae0883047708e39b56d6209c1ba --- /dev/null +++ b/Test_case/level_4/4.json @@ -0,0 +1,37 @@ +{ + "upper": [ + [ + "s", + -4, + 2 + ], + [ + "p", + 0, + 0 + ], + [ + "p", + 4, + 0 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "p", + -4, + 1 + ], + [ + "r", + -4, + 4 + ] + ], + "block": [] +} \ No newline at end of file diff --git a/Test_case/level_4/5.json b/Test_case/level_4/5.json new file mode 100644 index 0000000000000000000000000000000000000000..3fbb4379715f099cbbc6a8844ede1a82241fbf46 --- /dev/null +++ b/Test_case/level_4/5.json @@ -0,0 +1,68 @@ +{ + "upper": [ + [ + "s", + -4, + 2 + ], + [ + "s", + 0, + 0 + ], + [ + "p", + 4, + 0 + ] + ], + "lower": [ + [ + "s", + -4, + 0 + ], + [ + "p", + -4, + 1 + ], + [ + "r", + -4, + 4 + ], + [ + "s", + -3, + 4 + ], + [ + "s", + 0, + -4 + ], + [ + "s", + 0, + 4 + ], + [ + "s", + 4, + -4 + ], + [ + "s", + 4, + -1 + ] + ], + "block": [ + [ + "", + 0, + -1 + ] + ] +} \ No newline at end of file diff --git a/search/method.py b/search/method.py new file mode 100644 index 0000000000000000000000000000000000000000..f17fa2eab4b4efcda915e63d9a303f23ef0add59 --- /dev/null +++ b/search/method.py @@ -0,0 +1,92 @@ + +from src.search.util import print_board +import json + +""" +Read from JSON file: + -> load each piece into board's dictionary. + -> ensure format token to distinguish between upper and lower. + -> handling file IO exception +""" +def to_board(file): + TYPE = 0 + X_COORD = 1 + Y_COORD = 2 + + if not isinstance(file, str): + print("Pass invalid argument to to_board()~!!!") + exit(-1) + try: + # open the file handle by json module + FILE = open(file) + game = json.load(FILE) + + board = {} + # iterate through the entity who is not empty in order to add it type and coordinate to dictionary. + for entity in game.keys(): + + if game[entity]: + + for token in game[entity]: + if entity == 'upper': + board[(int(token[X_COORD]), int(token[Y_COORD]))] = token[TYPE].upper() + else: + board[(int(token[X_COORD]), int(token[Y_COORD]))] = token[TYPE] + + FILE.close() + return board + + except IOError: + print("There is an issue when try to open file") + exit(-1) + + +""" +taken from https://www.redblobgames.com/grids/hexagons/ +under section: double coordinates for doublewidth +-> +""" +def distance_between(Upper_token, Lower_token): + dx = abs(Upper_token[0] - Lower_token[0]) + dy = abs(Upper_token[1] - Lower_token[1]) + + return dx + max(0, (dy - dx) / 2) + + +""" +movement logic +""" +row = 1 +collumn = 2 + +def move_left(coordinate): + if coordinate: + coordinate[collumn] -= 1 + +def move_right(coordinate): + if coordinate: + coordinate[collumn] += 1 + +def move_up_left(coordinate): + if coordinate: + coordinate[collumn] -= 1 + coordinate[row] += 1 + +def move_up_right(coordinate): + if coordinate: + coordinate[row] += 1 + + +def move_down_left(coordinate): + if coordinate: + coordinate[row] -= 1 + +def move_down_right(coordinate): + if coordinate: + coordinate[row] -= 1 + coordinate[collumn] += 1 + + +def transfer_move_to_board(, coordinate, new_coordinate): + if not board[new_coordinate] +print(distance_between([-3, 0], [1, 0]))