From 26ea66ad964d91afa24175df2c175ff0d9912ef1 Mon Sep 17 00:00:00 2001
From: Scott Wong <scottmw@student.unimelb.edu.au>
Date: Sat, 20 Mar 2021 17:58:16 +1100
Subject: [PATCH] 6pm 20-03, added comparison of two pieces and sample
 dictionary

---
 .idea/.gitignore   |  3 +++
 .idea/.name        |  1 +
 .idea/Project1.iml | 15 +++++++++++++++
 .idea/misc.xml     |  6 ++++++
 .idea/modules.xml  |  8 ++++++++
 .idea/vcs.xml      |  6 ++++++
 search/main.py     | 41 +++++++++++++++++++++++++++++++++++++++++
 search/method.py   | 11 ++++++-----
 8 files changed, 86 insertions(+), 5 deletions(-)
 create mode 100644 .idea/.gitignore
 create mode 100644 .idea/.name
 create mode 100644 .idea/Project1.iml
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/modules.xml
 create mode 100644 .idea/vcs.xml

diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..03438df
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+util.py
\ No newline at end of file
diff --git a/.idea/Project1.iml b/.idea/Project1.iml
new file mode 100644
index 0000000..2968bc2
--- /dev/null
+++ b/.idea/Project1.iml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="Python" name="Python">
+      <configuration sdkName="Python 3.6" />
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Python 3.6 interpreter library" level="application" />
+  </component>
+</module>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..1763e15
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..3db647a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/Project1.iml" filepath="$PROJECT_DIR$/.idea/Project1.iml" />
+    </modules>
+  </component>
+</project>
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/search/main.py b/search/main.py
index 8da7a40..f2c7e88 100644
--- a/search/main.py
+++ b/search/main.py
@@ -14,6 +14,7 @@ import json
 # then import from them like this:
 from search.util import print_board, print_slide, print_swing
 
+
 def main():
     try:
         with open(sys.argv[1]) as file:
@@ -28,3 +29,43 @@ def main():
     # Why not start by trying to print this configuration out using the
     # `print_board` helper function? (See the `util.py` source code for
     # usage information).
+
+
+# Our upper pieces are R, P and S, lower pieces are r, p and s
+# We will convert both to lower case letters and check each case
+# Would be nice to use comparator but can't have r>s>p>r using it
+# Return 1 if piecea wins, 2 if pieceb wins and 0 if neither win
+def piece_collision(piecea, pieceb) -> int:
+    piecea = piecea.lower()
+    pieceb = pieceb.lower()
+    if (piecea == "r"):
+        if (pieceb == "s"):
+            return 1
+        elif (pieceb == "p"):
+            return 2
+    elif (piecea == "s"):
+        if (pieceb == "p"):
+            return 1
+        elif (pieceb == "r"):
+            return 2
+    elif (piecea == "p"):
+        if (pieceb == "r"):
+            return 1
+        elif (pieceb == "s"):
+            return 2
+    return 0
+# We may have to edit this to strip numbers later
+
+
+# We will have dictionary containing pieces
+# This is so we don't have to search the entire board every time
+# we need to find pieces
+# Blocks can be stored in a separate list
+# Other option is to have dictionary of entire board
+
+#Sample dictionary
+sample_dict = {
+    "R": (0, -2),
+    "s": (-1, 1)
+}
+
diff --git a/search/method.py b/search/method.py
index f17fa2e..fdf65b3 100644
--- a/search/method.py
+++ b/search/method.py
@@ -57,19 +57,19 @@ def distance_between(Upper_token, Lower_token):
 movement logic
 """
 row = 1
-collumn = 2
+column = 2
 
 def move_left(coordinate):
     if coordinate:
-        coordinate[collumn] -= 1
+        coordinate[column] -= 1
 
 def move_right(coordinate):
     if coordinate:
-        coordinate[collumn] += 1
+        coordinate[column] += 1
 
 def move_up_left(coordinate):
     if coordinate:
-        coordinate[collumn] -= 1
+        coordinate[column] -= 1
         coordinate[row] += 1
 
 def move_up_right(coordinate):
@@ -84,9 +84,10 @@ def move_down_left(coordinate):
 def move_down_right(coordinate):
     if coordinate:
         coordinate[row] -= 1
-        coordinate[collumn] += 1
+        coordinate[column] += 1
 
 
 def transfer_move_to_board(, coordinate, new_coordinate):
     if not board[new_coordinate]
 print(distance_between([-3, 0], [1, 0]))
+
-- 
GitLab