Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp30024-project-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scott Wong
comp30024-project-1
Commits
8bc241f9
Commit
8bc241f9
authored
4 years ago
by
Scott Wong
Browse files
Options
Downloads
Patches
Plain Diff
Can add non-dupe pieces to dict
parent
60858f5f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
search/main.py
+25
-9
25 additions, 9 deletions
search/main.py
search/method.py
+1
-1
1 addition, 1 deletion
search/method.py
search/movement_logic.py
+2
-2
2 additions, 2 deletions
search/movement_logic.py
with
28 additions
and
12 deletions
search/main.py
+
25
−
9
View file @
8bc241f9
...
@@ -22,6 +22,22 @@ def main():
...
@@ -22,6 +22,22 @@ def main():
except
IndexError
:
except
IndexError
:
print
(
"
usage: python3 -m search path/to/input.json
"
,
file
=
sys
.
stderr
)
print
(
"
usage: python3 -m search path/to/input.json
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
# We can put the code to read the file NOT in the try/except statement because
# if the file couldn't be read the process would end anyway
# data is a dictionary with keys "upper", "lower" and "block"
# pieces in dictionary, blocks in set, we can use if position in setblocks
dictpieces
=
{}
setblocks
=
set
()
initialpiecesupper
=
data
[
"
upper
"
]
initialpieceslower
=
data
[
"
lower
"
]
initialblocks
=
data
[
"
block
"
]
# Will edit to handle duplicate pieces soon
for
piece
in
initialpiecesupper
:
dictpieces
[
piece
[
0
].
upper
]
=
(
piece
[
1
],
piece
[
2
])
for
piece
in
initialpieceslower
:
dictpieces
[
piece
[
0
]]
=
(
piece
[
1
],
piece
[
2
])
for
block
in
initialblocks
:
setblocks
.
add
((
block
[
1
],
block
[
2
]))
# TODO:
# TODO:
# Find and print a solution to the board configuration described
# Find and print a solution to the board configuration described
...
@@ -38,20 +54,20 @@ def main():
...
@@ -38,20 +54,20 @@ def main():
def
piece_collision
(
piecea
,
pieceb
)
->
int
:
def
piece_collision
(
piecea
,
pieceb
)
->
int
:
piecea
=
piecea
.
lower
()
piecea
=
piecea
.
lower
()
pieceb
=
pieceb
.
lower
()
pieceb
=
pieceb
.
lower
()
if
(
piecea
==
"
r
"
)
:
if
piecea
==
"
r
"
:
if
(
pieceb
==
"
s
"
)
:
if
pieceb
==
"
s
"
:
return
1
return
1
elif
(
pieceb
==
"
p
"
)
:
elif
pieceb
==
"
p
"
:
return
2
return
2
elif
(
piecea
==
"
s
"
)
:
elif
piecea
==
"
s
"
:
if
(
pieceb
==
"
p
"
)
:
if
pieceb
==
"
p
"
:
return
1
return
1
elif
(
pieceb
==
"
r
"
)
:
elif
pieceb
==
"
r
"
:
return
2
return
2
elif
(
piecea
==
"
p
"
)
:
elif
piecea
==
"
p
"
:
if
(
pieceb
==
"
r
"
)
:
if
pieceb
==
"
r
"
:
return
1
return
1
elif
(
pieceb
==
"
s
"
)
:
elif
pieceb
==
"
s
"
:
return
2
return
2
return
0
return
0
# We may have to edit this to strip numbers later
# We may have to edit this to strip numbers later
...
...
This diff is collapsed.
Click to expand it.
search/method.py
+
1
−
1
View file @
8bc241f9
...
@@ -7,7 +7,7 @@ TYPE = 0
...
@@ -7,7 +7,7 @@ TYPE = 0
ROW
=
1
ROW
=
1
COLUMN
=
2
COLUMN
=
2
# This isn't reaaly needed, check main file
def
read_position_list
(
file
):
def
read_position_list
(
file
):
"""
"""
:argument file - of the JSON file
:argument file - of the JSON file
...
...
This diff is collapsed.
Click to expand it.
search/movement_logic.py
+
2
−
2
View file @
8bc241f9
...
@@ -100,7 +100,7 @@ DOWN_RIGHT = 6
...
@@ -100,7 +100,7 @@ DOWN_RIGHT = 6
Swing action logic:
Swing action logic:
x is the another token that current token swing from
x is the another token that current token swing from
-> token can only swing to adjcent tiles{1,2,3} to [x] that are not adjcent to itself
-> token can only swing to adj
a
cent tiles{1,2,3} to [x] that are not adj
a
cent to itself
tile 1, 2 and 3 are those token can swing to.
tile 1, 2 and 3 are those token can swing to.
...
@@ -200,7 +200,7 @@ def get_relative_position(token, x):
...
@@ -200,7 +200,7 @@ def get_relative_position(token, x):
:argument token - the selected game object that is presented by its position on board { (row, column)}
:argument token - the selected game object that is presented by its position on board { (row, column)}
x - the adjacent game object
x - the adjacent game object
:return the position of x relative to token
:return the position of x relative to token
-> using the slide direction as the position defition.
-> using the slide direction as the position defi
ni
tion.
e.g left,right, up_left, up_right,..etc
e.g left,right, up_left, up_right,..etc
"""
"""
# check if x is to the left of tile
# check if x is to the left of tile
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment