Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scotland-yard-ai
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nik | Klampfradler
scotland-yard-ai
Commits
46041f6a
Verified
Commit
46041f6a
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Allow passing multiple, or no, last locations
parent
ebd0912b
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/syai/game.py
+12
-2
12 additions, 2 deletions
src/syai/game.py
with
12 additions
and
2 deletions
src/syai/game.py
+
12
−
2
View file @
46041f6a
from
typing
import
Iterable
,
Optional
,
Sequence
,
Union
from
pydot
import
graph_from_dot_file
...
...
@@ -40,8 +42,16 @@ class Board:
self
.
ticket_graphs
.
setdefault
(
ticket
,
{}).
setdefault
(
destination
,
set
()).
add
(
departure
)
self
.
ticket_graphs
.
setdefault
(
"
*
"
,
{}).
setdefault
(
destination
,
set
()).
add
(
departure
)
def
get_possible_nodes
(
self
,
last
:
str
,
tickets
:
list
[
str
])
->
list
[
str
]:
possible
=
set
((
last
,))
def
get_possible_nodes
(
self
,
tickets
:
Sequence
[
str
],
last
:
Optional
[
Union
[
Iterable
[
str
],
str
]]
=
None
)
->
set
[
str
]:
if
last
is
None
:
possible
=
set
(
self
.
ticket_graphs
.
get
(
"
*
"
,
{}).
keys
())
elif
isinstance
(
last
,
str
):
possible
=
set
((
last
,))
else
:
possible
=
set
(
last
)
for
ticket
in
tickets
:
new_possible
=
set
()
for
node
in
possible
:
...
...
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