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
dff78c05
Verified
Commit
dff78c05
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Implement method to get possible nodes from ticket list
parent
2f9a989a
Branches
Branches containing commit
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
+15
-3
15 additions, 3 deletions
src/syai/game.py
with
15 additions
and
3 deletions
src/syai/game.py
+
15
−
3
View file @
dff78c05
...
...
@@ -38,14 +38,26 @@ class Board:
return
graph
def
__init__
(
self
):
self
.
ticket_graphs
=
{}
def
add_connection
(
self
,
ticket
:
str
,
departure
:
str
,
destination
:
str
,
oneway
:
bool
=
False
)
->
None
:
self
.
ticket_graphs
.
setdefault
(
ticket
,
{}).
setdefault
(
departure
,
set
()).
add
(
destination
)
if
not
oneway
:
self
.
ticket_graphs
.
setdefault
(
ticket
,
{}).
setdefault
(
destination
,
set
()).
add
(
departure
)
def
get_possible_nodes
(
self
,
last
:
str
,
tickets
:
list
[
str
])
->
list
[
str
]:
possible
=
set
((
last
,))
for
ticket
in
tickets
:
graph
=
self
.
full_graph
if
ticket
==
"
*
"
else
self
.
ticket_graphs
[
ticket
]
new_possible
=
set
()
for
node
in
possible
:
new_possible
.
update
(
graph
[
node
])
possible
=
new_possible
return
possible
def
__init__
(
self
):
self
.
ticket_graphs
=
{}
@classmethod
def
from_dot
(
cls
,
filename
:
str
)
->
"
Board
"
:
board
=
cls
()
...
...
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