Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2018-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
adc2018
adc2018-system
Commits
e2397ae4
Commit
e2397ae4
authored
Aug 16, 2018
by
Kento HASEGAWA
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 3D viewer to show the solution
parent
5e4c621e
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2413 additions
and
5 deletions
+2413
-5
main.py
comm/server/main.py
+112
-3
OrbitControls.js
comm/server/static/js/OrbitControls.js
+1051
-0
pynq-manager.js
comm/server/static/js/pynq-manager.js
+7
-0
three.min.js
comm/server/static/js/three.min.js
+949
-0
board-viewer.html
comm/server/templates/board-viewer.html
+292
-0
part_question_status.html
comm/server/templates/part_question_status.html
+2
-2
No files found.
comm/server/main.py
View file @
e2397ae4
...
...
@@ -60,7 +60,7 @@ def load_questions():
"board_size"
:
board_size
,
"line_num"
:
line_num
,
"last_req"
:
None
,
"answers"
:
[]
,
"answers"
:
OrderedDict
()
,
}
update_answer_list
(
_name
)
...
...
@@ -87,7 +87,7 @@ def update_answer_list(qname):
global
app_args
global
questions
questions
[
qname
][
'answers'
]
=
[]
questions
[
qname
][
'answers'
]
=
OrderedDict
()
_folder_name
=
os
.
path
.
splitext
(
qname
)[
0
]
_answers_path
=
"{}/{}"
.
format
(
app_args
[
'out'
],
_folder_name
)
...
...
@@ -97,9 +97,10 @@ def update_answer_list(qname):
answer_log_file
.
reverse
()
for
v2
in
answer_log_file
:
json_name
=
os
.
path
.
basename
(
v2
)
with
open
(
v2
,
"r"
)
as
fp
:
answer_log
=
json
.
load
(
fp
)
questions
[
qname
][
'answers'
]
.
append
(
answer_log
)
questions
[
qname
][
'answers'
]
[
json_name
]
=
answer_log
@
app
.
before_request
def
before_request
():
...
...
@@ -282,6 +283,109 @@ def get_status():
return
json
.
dumps
(
res
)
@
app
.
route
(
"/board-data"
,
methods
=
[
"POST"
])
def
get_board_data
():
global
questions
qname
=
request
.
form
[
'qname'
]
json_name
=
request
.
form
[
'jname'
]
lines
=
questions
[
qname
][
'answers'
][
json_name
][
'answer'
]
.
split
(
"
\n
"
)
# board_size = [int(v) for v in lines[1].rstrip().split()[1].split("X")]
board_size
=
[
int
(
v
)
for
v
in
questions
[
qname
][
'board_size'
]
.
split
(
"X"
)]
raw_data
=
[[[
0
for
x
in
range
(
board_size
[
0
])]
for
y
in
range
(
board_size
[
1
])]
for
z
in
range
(
board_size
[
2
])]
data
=
[]
max_line_num
=
0
for
l
in
lines
[
1
:]:
if
l
.
rstrip
()
==
""
:
continue
elif
l
.
startswith
(
"LAYER"
):
z
=
int
(
l
.
rstrip
()
.
split
()[
1
])
-
1
y
=
0
continue
else
:
ldat
=
l
.
rstrip
()
.
split
(
","
)
for
x
,
v
in
enumerate
(
ldat
):
raw_data
[
z
][
y
][
x
]
=
int
(
v
)
max_line_num
=
max
(
max_line_num
,
int
(
v
))
y
+=
1
terminals
=
[[]
for
v
in
range
(
max_line_num
+
1
)]
for
z
in
range
(
board_size
[
2
]):
for
y
in
range
(
board_size
[
1
]):
for
x
in
range
(
board_size
[
0
]):
line_num
=
raw_data
[
z
][
y
][
x
]
if
line_num
==
0
:
continue
adj_cnt
=
0
if
((
0
<=
x
-
1
<
board_size
[
0
])
and
(
raw_data
[
z
][
y
][
x
-
1
]
==
line_num
)):
adj_cnt
+=
1
if
((
0
<=
x
+
1
<
board_size
[
0
])
and
(
raw_data
[
z
][
y
][
x
+
1
]
==
line_num
)):
adj_cnt
+=
1
if
((
0
<=
y
-
1
<
board_size
[
1
])
and
(
raw_data
[
z
][
y
-
1
][
x
]
==
line_num
)):
adj_cnt
+=
1
if
((
0
<=
y
+
1
<
board_size
[
1
])
and
(
raw_data
[
z
][
y
+
1
][
x
]
==
line_num
)):
adj_cnt
+=
1
if
((
0
<=
z
-
1
<
board_size
[
2
])
and
(
raw_data
[
z
-
1
][
y
][
x
]
==
line_num
)):
adj_cnt
+=
1
if
((
0
<=
z
+
1
<
board_size
[
2
])
and
(
raw_data
[
z
+
1
][
y
][
x
]
==
line_num
)):
adj_cnt
+=
1
if
adj_cnt
==
1
:
terminals
[
line_num
]
.
append
((
x
,
y
,
z
))
lines
=
{}
for
i
in
range
(
1
,
max_line_num
+
1
):
if
len
(
terminals
[
i
])
!=
2
:
continue
start
=
terminals
[
i
][
0
]
goal
=
terminals
[
i
][
1
]
lines
[
i
]
=
[]
lines
[
i
]
.
append
(
start
)
lines
[
i
]
.
append
(
start
)
now
=
start
_next
=
(
0
,
0
,
0
)
while
now
!=
goal
:
x
,
y
,
z
=
now
adj_cnt
=
0
if
((
0
<=
x
-
1
<
board_size
[
0
])
and
(
raw_data
[
z
][
y
][
x
-
1
]
==
i
)
and
(
lines
[
i
][
-
2
]
!=
(
x
-
1
,
y
,
z
))):
_next
=
(
x
-
1
,
y
,
z
)
elif
((
0
<=
x
+
1
<
board_size
[
0
])
and
(
raw_data
[
z
][
y
][
x
+
1
]
==
i
)
and
(
lines
[
i
][
-
2
]
!=
(
x
+
1
,
y
,
z
))):
_next
=
(
x
+
1
,
y
,
z
)
elif
((
0
<=
y
-
1
<
board_size
[
1
])
and
(
raw_data
[
z
][
y
-
1
][
x
]
==
i
)
and
(
lines
[
i
][
-
2
]
!=
(
x
,
y
-
1
,
z
))):
_next
=
(
x
,
y
-
1
,
z
)
elif
((
0
<=
y
+
1
<
board_size
[
1
])
and
(
raw_data
[
z
][
y
+
1
][
x
]
==
i
)
and
(
lines
[
i
][
-
2
]
!=
(
x
,
y
+
1
,
z
))):
_next
=
(
x
,
y
+
1
,
z
)
elif
((
0
<=
z
-
1
<
board_size
[
2
])
and
(
raw_data
[
z
-
1
][
y
][
x
]
==
i
)
and
(
lines
[
i
][
-
2
]
!=
(
x
,
y
,
z
-
1
))):
_next
=
(
x
,
y
,
z
-
1
)
elif
((
0
<=
z
+
1
<
board_size
[
2
])
and
(
raw_data
[
z
+
1
][
y
][
x
]
==
i
)
and
(
lines
[
i
][
-
2
]
!=
(
x
,
y
,
z
+
1
))):
_next
=
(
x
,
y
,
z
+
1
)
else
:
print
(
"Error: Not found an adjacent node"
)
_next
=
goal
lines
[
i
]
.
append
(
_next
)
now
=
_next
res
=
{
'line'
:
lines
,
'board'
:
board_size
,
}
return
json
.
dumps
(
res
)
@
app
.
route
(
"/get_clients"
)
def
get_clients
():
global
clients
...
...
@@ -294,6 +398,11 @@ def get_clients():
return
json
.
dumps
(
res
)
@
app
.
route
(
"/board-viewer"
,
methods
=
[
"GET"
])
def
show_board_viewer
():
return
render_template
(
"board-viewer.html"
)
@
app
.
route
(
"/get_question_table"
)
def
question_table
():
...
...
comm/server/static/js/OrbitControls.js
0 → 100644
View file @
e2397ae4
This diff is collapsed.
Click to expand it.
comm/server/static/js/pynq-manager.js
View file @
e2397ae4
...
...
@@ -166,6 +166,13 @@ $(function(){
$
(
"#client-control-pane"
).
find
(
".stop-button"
).
eq
(
0
).
click
(
function
(){
pm
.
sendStop
();
});
$
(
".answer-detail-row td"
).
click
(
function
(){
var
json_name
=
$
(
this
).
parent
(
"tr"
).
data
(
"json"
);
var
qname
=
$
(
this
).
parent
(
"tr"
).
data
(
"qname"
);
var
viewer_url
=
"/board-viewer#"
+
qname
+
","
+
json_name
window
.
open
(
viewer_url
,
null
);
})
});
}
...
...
comm/server/static/js/three.min.js
0 → 100644
View file @
e2397ae4
This diff is collapsed.
Click to expand it.
comm/server/templates/board-viewer.html
0 → 100644
View file @
e2397ae4
This diff is collapsed.
Click to expand it.
comm/server/templates/part_question_status.html
View file @
e2397ae4
...
...
@@ -39,8 +39,8 @@
<th>
Client
</th>
<th>
Score
</th>
</tr>
{% for
v in qdata.answers
%}
<tr>
{% for
k, v in qdata.answers.items()
%}
<tr
class=
"answer-detail-row"
data-json=
"{{k}}"
data-qname=
"{{qname}}"
>
<td>
{{v.timestamp}}
</td>
<td>
{{v.solver}}
</td>
<td>
{{v.nlcheck}}
</td>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment