Skip to content
Snippets Groups Projects
Commit 26ea66ad authored by Scott Wong's avatar Scott Wong
Browse files

6pm 20-03, added comparison of two pieces and sample dictionary

parent bbdac08e
No related branches found
No related tags found
No related merge requests found
# Default ignored files
/shelf/
/workspace.xml
util.py
\ No newline at end of file
<?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
<?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
<?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
<?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
...@@ -14,6 +14,7 @@ import json ...@@ -14,6 +14,7 @@ import json
# then import from them like this: # then import from them like this:
from search.util import print_board, print_slide, print_swing from search.util import print_board, print_slide, print_swing
def main(): def main():
try: try:
with open(sys.argv[1]) as file: with open(sys.argv[1]) as file:
...@@ -28,3 +29,43 @@ def main(): ...@@ -28,3 +29,43 @@ def main():
# Why not start by trying to print this configuration out using the # Why not start by trying to print this configuration out using the
# `print_board` helper function? (See the `util.py` source code for # `print_board` helper function? (See the `util.py` source code for
# usage information). # 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)
}
...@@ -57,19 +57,19 @@ def distance_between(Upper_token, Lower_token): ...@@ -57,19 +57,19 @@ def distance_between(Upper_token, Lower_token):
movement logic movement logic
""" """
row = 1 row = 1
collumn = 2 column = 2
def move_left(coordinate): def move_left(coordinate):
if coordinate: if coordinate:
coordinate[collumn] -= 1 coordinate[column] -= 1
def move_right(coordinate): def move_right(coordinate):
if coordinate: if coordinate:
coordinate[collumn] += 1 coordinate[column] += 1
def move_up_left(coordinate): def move_up_left(coordinate):
if coordinate: if coordinate:
coordinate[collumn] -= 1 coordinate[column] -= 1
coordinate[row] += 1 coordinate[row] += 1
def move_up_right(coordinate): def move_up_right(coordinate):
...@@ -84,9 +84,10 @@ def move_down_left(coordinate): ...@@ -84,9 +84,10 @@ def move_down_left(coordinate):
def move_down_right(coordinate): def move_down_right(coordinate):
if coordinate: if coordinate:
coordinate[row] -= 1 coordinate[row] -= 1
coordinate[collumn] += 1 coordinate[column] += 1
def transfer_move_to_board(, coordinate, new_coordinate): def transfer_move_to_board(, coordinate, new_coordinate):
if not board[new_coordinate] if not board[new_coordinate]
print(distance_between([-3, 0], [1, 0])) print(distance_between([-3, 0], [1, 0]))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment