Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qwgame
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵国君
qwgame
Commits
c05ae468
Commit
c05ae468
authored
Apr 15, 2019
by
hxw2303632
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除没有用到的变量
parent
148904cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
37 deletions
+2
-37
MapConstructor.java
...va/com/qiwu/chatbotbackend/gameDesign/MapConstructor.java
+2
-37
No files found.
src/main/java/com/qiwu/chatbotbackend/gameDesign/MapConstructor.java
View file @
c05ae468
...
@@ -14,7 +14,6 @@ import static com.qiwu.chatbotbackend.Config.Config.TASK_REPLY;
...
@@ -14,7 +14,6 @@ import static com.qiwu.chatbotbackend.Config.Config.TASK_REPLY;
public
class
MapConstructor
extends
ElementConstructor
{
public
class
MapConstructor
extends
ElementConstructor
{
int
[][]
matrix
;
int
locationNum
;
int
locationNum
;
HashMap
<
Integer
,
JSONObject
>
id2j
=
new
HashMap
<
Integer
,
JSONObject
>();
HashMap
<
Integer
,
JSONObject
>
id2j
=
new
HashMap
<
Integer
,
JSONObject
>();
Map
<
String
,
String
>
question2keyword
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
question2keyword
=
new
HashMap
<
String
,
String
>();
...
@@ -43,14 +42,11 @@ public class MapConstructor extends ElementConstructor {
...
@@ -43,14 +42,11 @@ public class MapConstructor extends ElementConstructor {
String
locationName
,
taskLineName
=
""
;
String
locationName
,
taskLineName
=
""
;
locationNum
=
locations
.
size
();
locationNum
=
locations
.
size
();
StringBuffer
nameSet
=
null
;
keywordMap
.
putIfAbsent
(
"site_list"
,
new
StringBuffer
());
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
jobj
=
locations
.
getJSONObject
(
i
);
jobj
=
locations
.
getJSONObject
(
i
);
jobj
.
put
(
"index"
,
i
);
jobj
.
put
(
"index"
,
i
);
locationName
=
(
String
)
jobj
.
get
(
"name"
);
locationName
=
(
String
)
jobj
.
get
(
"name"
);
keywordMap
.
get
(
"site_list"
).
append
(
"+"
).
append
(
locationName
);
taskLineName
=
String
.
format
(
TASK_LINE
,
locationName
);
taskLineName
=
String
.
format
(
TASK_LINE
,
locationName
);
...
@@ -61,44 +57,21 @@ public class MapConstructor extends ElementConstructor {
...
@@ -61,44 +57,21 @@ public class MapConstructor extends ElementConstructor {
varInitialMap
.
put
(
taskLineName
,
""
);
varInitialMap
.
put
(
taskLineName
,
""
);
}
}
nameSet
=
new
StringBuffer
();
nameSet
.
append
(
locationName
);
name2nickname
.
putIfAbsent
(
locationName
,
new
ArrayList
<>());
name2nickname
.
putIfAbsent
(
locationName
,
new
ArrayList
<>());
POS
.
append
(
"="
+
locationName
+
"|地名\r\n"
);
POS
.
append
(
"="
+
locationName
+
"|地名\r\n"
);
if
(
jobj
.
containsKey
(
"nickname"
)){
if
(
jobj
.
containsKey
(
"nickname"
)){
for
(
String
nickname:
JSONArray
.
parseArray
(
locations
.
getJSONObject
(
i
).
getJSONArray
(
"nickname"
).
toJSONString
(),
String
.
class
)){
for
(
String
nickname:
JSONArray
.
parseArray
(
locations
.
getJSONObject
(
i
).
getJSONArray
(
"nickname"
).
toJSONString
(),
String
.
class
)){
if
(!
nickname
.
equals
(
""
))
{
if
(!
nickname
.
equals
(
""
))
{
nameSet
.
append
(
"+"
).
append
(
nickname
);
POS
.
append
(
"="
).
append
(
nickname
).
append
(
"|地名\r\n"
);
POS
.
append
(
"="
).
append
(
nickname
).
append
(
"|地名\r\n"
);
name2nickname
.
get
(
locationName
).
add
(
nickname
);
name2nickname
.
get
(
locationName
).
add
(
nickname
);
}
}
}
}
}
}
jobj
.
put
(
"nameSet"
,
nameSet
.
toString
());
locationId
=
(
Integer
)
jobj
.
get
(
"id"
);
locationId
=
(
Integer
)
jobj
.
get
(
"id"
);
id2j
.
put
(
locationId
,
jobj
);
id2j
.
put
(
locationId
,
jobj
);
}
}
//邻接矩阵初始化
matrix
=
new
int
[
locationNum
][
locationNum
];
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
for
(
int
j
=
0
;
j
<
locationNum
;
j
++)
{
matrix
[
i
][
j
]
=
Integer
.
MAX_VALUE
;
}
}
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
List
<
Integer
>
neighbours
=
JSONArray
.
parseArray
(
locations
.
getJSONObject
(
i
).
getJSONArray
(
"neighbours"
).
toJSONString
(),
Integer
.
class
);
for
(
int
neighbourId
:
neighbours
)
{
JSONObject
neighbourObject
=
id2j
.
get
(
neighbourId
);
//System.out.println(neighbourObject);
index
=
(
Integer
)
neighbourObject
.
get
(
"index"
);
matrix
[
i
][
index
]
=
1
;
matrix
[
index
][
i
]
=
1
;
}
}
}
}
...
@@ -121,16 +94,13 @@ public class MapConstructor extends ElementConstructor {
...
@@ -121,16 +94,13 @@ public class MapConstructor extends ElementConstructor {
}
}
JSONArray
locations
=
map
.
getJSONArray
(
"locations"
);
JSONArray
locations
=
map
.
getJSONArray
(
"locations"
);
String
userName
=
gameElements
.
getString
(
"userName"
),
locationName
;
String
locationName
;
this
.
locations
=
locations
;
this
.
locations
=
locations
;
this
.
question2keyword
=
question2keyword
;
this
.
question2keyword
=
question2keyword
;
//通过邻接表构造邻接矩阵
//通过邻接表构造邻接矩阵
constructGreph
(
locations
);
constructGreph
(
locations
);
//用弗洛伊德算法求最短路径
//Floyd floyd = new Floyd();
//floyd.findShortestPath(matrix, locationNum);
//floyd.printPath(matrix, locationNum);
generateWantToThere
(
gameElements
,
keywordMap
);
generateWantToThere
(
gameElements
,
keywordMap
);
generateHowToThere
(
gameElements
,
keywordMap
);
generateHowToThere
(
gameElements
,
keywordMap
);
...
@@ -190,7 +160,6 @@ public class MapConstructor extends ElementConstructor {
...
@@ -190,7 +160,6 @@ public class MapConstructor extends ElementConstructor {
String
conditionNameList
[]
=
keywordMap
.
get
(
intent
).
toString
().
split
(
","
);
String
conditionNameList
[]
=
keywordMap
.
get
(
intent
).
toString
().
split
(
","
);
StringBuffer
placeKeywords
=
new
StringBuffer
();
StringBuffer
placeKeywords
=
new
StringBuffer
();
String
nameSet
;
for
(
String
conditionName:
conditionNameList
)
{
for
(
String
conditionName:
conditionNameList
)
{
...
@@ -217,10 +186,6 @@ public class MapConstructor extends ElementConstructor {
...
@@ -217,10 +186,6 @@ public class MapConstructor extends ElementConstructor {
placeKeywords
.
append
(
gotoSite
);
placeKeywords
.
append
(
gotoSite
);
//toSitekeywords.append(gotoSite);
//toSitekeywords.append(gotoSite);
}
}
//nameSet = (String) locations.getJSONObject(i).get("nameSet");
//placeKeywords.append("+").append(nameSet);
}
}
...
...
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