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
6321ac3c
Commit
6321ac3c
authored
Apr 16, 2019
by
hxw2303632
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of 192.168.1.81:hxw2303632/webapp
parents
947af96a
f79bd39c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
290 additions
and
236 deletions
+290
-236
ActionUtils.java
...qiwu/chatbotbackend/actiongenerate/utils/ActionUtils.java
+3
-3
ConfigTermUtils.java
.../chatbotbackend/actiongenerate/utils/ConfigTermUtils.java
+0
-0
ConfigTermText.java
...n/java/com/qiwu/chatbotbackend/entity/ConfigTermText.java
+15
-13
Premise.java
src/main/java/com/qiwu/chatbotbackend/entity/Premise.java
+123
-63
ListeningConstructor.java
.../qiwu/chatbotbackend/gameDesign/ListeningConstructor.java
+126
-124
PlotConstructor2.java
.../com/qiwu/chatbotbackend/gameDesign/PlotConstructor2.java
+23
-33
功能文档.docx
参数和接口文档/功能文档.docx
+0
-0
No files found.
src/main/java/com/qiwu/chatbotbackend/actiongenerate/utils/ActionUtils.java
View file @
6321ac3c
...
@@ -846,18 +846,18 @@ public class ActionUtils {
...
@@ -846,18 +846,18 @@ public class ActionUtils {
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_head"
,
new
HashSet
<
String
>());
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_head"
,
new
HashSet
<
String
>());
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_tail"
,
new
HashSet
<
String
>());
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_tail"
,
new
HashSet
<
String
>());
for
(
int
i
=
1
;
i
<
10
;
i
++){
for
(
int
i
=
1
;
i
<
10
0
;
i
++){
//给condition的名字添加后缀,因为游戏中可能用到condition的复制,但值域和名字不一样
//给condition的名字添加后缀,因为游戏中可能用到condition的复制,但值域和名字不一样
if
(
i
==
1
)
if
(
i
==
1
)
postfix
=
""
;
postfix
=
""
;
else
else
postfix
=
String
.
valueOf
(
i
);
postfix
=
"_"
+
String
.
valueOf
(
i
);
activeFlag
=
"0"
;
activeFlag
=
"0"
;
conditionJson
=
(
JSONObject
)
patternConditionJson
.
clone
();
conditionJson
=
(
JSONObject
)
patternConditionJson
.
clone
();
conditionName
=
conditionJson
.
getString
(
"conditionName"
)
+
postfix
;
conditionName
=
conditionJson
.
getString
(
"conditionName"
)
+
postfix
;
conditionName2
=
conditionName
+
"_indep
endent
"
;
conditionName2
=
conditionName
+
"_indep"
;
if
(!
conditionExtraKeywords
.
containsKey
(
conditionName
+
"_tail"
)){
//如果没有用到这个condition,就跳过
if
(!
conditionExtraKeywords
.
containsKey
(
conditionName
+
"_tail"
)){
//如果没有用到这个condition,就跳过
if
(!
conditionExtraKeywords
.
containsKey
(
conditionName2
+
"_tail"
))
if
(!
conditionExtraKeywords
.
containsKey
(
conditionName2
+
"_tail"
))
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/utils/ConfigTermUtils.java
View file @
6321ac3c
This diff is collapsed.
Click to expand it.
src/main/java/com/qiwu/chatbotbackend/entity/ConfigTermText.java
View file @
6321ac3c
...
@@ -167,9 +167,9 @@ public class ConfigTermText implements Cloneable{
...
@@ -167,9 +167,9 @@ public class ConfigTermText implements Cloneable{
}
}
public
ConfigTermText
(
List
<
Premise
>
curPremise
,
List
<
Premise
>
hisPremise
,
Map
<
String
,
String
>
updateKnowledge
,
String
extraCP
,
String
extraHP
,
String
extraUK
,
String
feature
,
String
reply
,
String
nextStep
,
String
auxiliaryPriority
)
{
public
ConfigTermText
(
List
<
Premise
>
curPremise
,
List
<
Premise
>
hisPremise
,
Map
<
String
,
String
>
updateKnowledge
,
String
extraCP
,
String
extraHP
,
String
extraUK
,
String
feature
,
String
reply
,
String
nextStep
,
String
auxiliaryPriority
,
Map
<
String
,
Integer
>
gNameCount
)
{
this
.
curPremise
=
appendPremiseStr
(
curPremise
,
extraCP
);
this
.
curPremise
=
appendPremiseStr
(
curPremise
,
extraCP
,
gNameCount
);
this
.
hisPremise
=
appendPremiseStr
(
hisPremise
,
extraHP
);
this
.
hisPremise
=
appendPremiseStr
(
hisPremise
,
extraHP
,
gNameCount
);
this
.
updateKnowledge
=
appendKnowledgeStr
(
updateKnowledge
,
extraUK
);
this
.
updateKnowledge
=
appendKnowledgeStr
(
updateKnowledge
,
extraUK
);
this
.
feature
=
feature
;
this
.
feature
=
feature
;
this
.
reply
=
reply
;
this
.
reply
=
reply
;
...
@@ -177,26 +177,28 @@ public class ConfigTermText implements Cloneable{
...
@@ -177,26 +177,28 @@ public class ConfigTermText implements Cloneable{
this
.
auxiliaryPriority
=
auxiliaryPriority
;
this
.
auxiliaryPriority
=
auxiliaryPriority
;
}
}
public
String
appendPremiseStr
(
List
<
Premise
>
premises
,
String
extraPremise
)
{
public
String
appendPremiseStr
(
List
<
Premise
>
premises
,
String
extraPremise
,
Map
<
String
,
Integer
>
gNameCount
)
{
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
String
premiseStr
=
""
,
conditionName
;
String
premiseStr
=
""
,
conditionName
;
Map
<
String
,
Integer
>
nameCount
=
new
HashMap
<
String
,
Integer
>();
for
(
Premise
premise
:
premises
){
for
(
Premise
premise
:
premises
){
conditionName
=
premise
.
getConditionName
();
conditionName
=
premise
.
getConditionName
();
if
(
conditionName
.
startsWith
(
"npc_"
)
||
if
(
conditionName
.
startsWith
(
"npc_"
)
||
conditionName
.
startsWith
(
"goods_"
)
||
conditionName
.
startsWith
(
"goods_"
)
||
conditionName
.
startsWith
(
"globalVariable_"
)
||
conditionName
.
startsWith
(
"globalVariable_"
)
||
conditionName
.
startsWith
(
"map_"
))
conditionName
.
startsWith
(
"map_"
)
||
conditionName
.
startsWith
(
"start_options"
)
||
conditionName
.
startsWith
(
"load_game_by_site"
)
)
{}
{}
else
{
else
{
nameCount
.
putIfAbsent
(
conditionName
,
0
);
gNameCount
.
putIfAbsent
(
conditionName
,
0
);
//nameCount加一
gNameCount
.
put
(
conditionName
,
gNameCount
.
get
(
conditionName
)
+
1
);
nameCount
.
put
(
conditionName
,
nameCount
.
get
(
conditionName
)
+
1
);
if
(
gNameCount
.
get
(
conditionName
)
>
1
&&
premise
.
getAccurateMatch
())
{
//在conditionName后添加count
premise
.
setConditionName
(
conditionName
+
"_"
+
gNameCount
.
get
(
conditionName
));
if
(
nameCount
.
get
(
conditionName
)
>
1
)
{
premise
.
setAccurateName
();
premise
.
setConditionName
(
conditionName
+
nameCount
.
get
(
conditionName
)
+
"_independent"
);
}
}
}
}
sb
.
append
(
","
);
sb
.
append
(
","
);
...
...
src/main/java/com/qiwu/chatbotbackend/entity/Premise.java
View file @
6321ac3c
package
com
.
qiwu
.
chatbotbackend
.
entity
;
package
com
.
qiwu
.
chatbotbackend
.
entity
;
public
class
Premise
{
public
class
Premise
{
private
String
conditionName
=
""
;
private
String
conditionName
=
""
;
private
String
cmpType
=
""
;
private
String
cmpType
=
""
;
private
String
operator
=
""
;
private
String
operator
=
""
;
private
String
keyword
=
""
;
private
String
keyword
=
""
;
private
Boolean
accurateMatch
=
false
;
public
Premise
(
String
conditionName
,
String
cmpType
,
String
operator
,
String
keyword
)
{
private
String
plot
=
""
;
private
int
branch
=
0
;
this
.
conditionName
=
conditionName
;
this
.
cmpType
=
cmpType
;
public
String
getPlot
()
{
this
.
operator
=
operator
;
return
plot
;
this
.
keyword
=
keyword
;
}
if
(
cmpType
==
null
){
public
void
setPlot
(
String
plot
)
{
this
.
cmpType
=
"match"
;
this
.
plot
=
plot
;
}
else
{
}
this
.
cmpType
=
cmpType
;
}
public
int
getBranch
()
{
return
branch
;
if
(
operator
==
null
){
}
this
.
operator
=
"Include"
;
}
else
{
public
void
setBranch
(
int
branch
)
{
this
.
operator
=
operator
;
this
.
branch
=
branch
;
}
}
if
(
cmpType
.
equals
(
"any"
)){
this
.
operator
=
"Include"
;
public
Boolean
getAccurateMatch
()
{
}
return
accurateMatch
;
}
}
public
String
getConditionName
()
{
public
void
setAccurateMatch
(
Boolean
accurateMatch
)
{
return
conditionName
;
this
.
accurateMatch
=
accurateMatch
;
}
}
public
void
setConditionName
(
String
conditionName
)
{
public
Premise
(
String
conditionName
,
String
cmpType
,
String
operator
,
String
keyword
,
Boolean
accurateMatch
)
{
this
.
conditionName
=
conditionName
;
}
this
.
conditionName
=
conditionName
;
this
.
cmpType
=
cmpType
;
public
String
getCmpType
()
{
this
.
operator
=
operator
;
return
cmpType
;
this
.
keyword
=
keyword
;
}
this
.
accurateMatch
=
accurateMatch
;
public
void
setCmpType
(
String
cmpType
)
{
if
(
cmpType
==
null
){
this
.
cmpType
=
cmpType
;
this
.
cmpType
=
"match"
;
}
}
else
{
this
.
cmpType
=
cmpType
;
public
String
getOperator
()
{
}
return
operator
;
}
if
(
operator
==
null
){
this
.
operator
=
"Include"
;
public
void
setOperator
(
String
operator
)
{
}
else
{
this
.
operator
=
operator
;
this
.
operator
=
operator
;
}
}
if
(
cmpType
.
equals
(
"any"
)){
public
String
getKeyword
()
{
this
.
operator
=
"Include"
;
return
keyword
;
}
}
if
(
accurateMatch
==
null
)
{
public
void
setKeyword
(
String
keyword
)
{
this
.
accurateMatch
=
false
;
this
.
keyword
=
keyword
;
}
}
}
}
public
Premise
(
String
conditionName
,
String
cmpType
,
String
operator
,
String
keyword
)
{
this
.
conditionName
=
conditionName
;
this
.
cmpType
=
cmpType
;
this
.
operator
=
operator
;
this
.
keyword
=
keyword
;
this
.
accurateMatch
=
false
;
if
(
cmpType
==
null
){
this
.
cmpType
=
"match"
;
}
else
{
this
.
cmpType
=
cmpType
;
}
if
(
operator
==
null
){
this
.
operator
=
"Include"
;
}
else
{
this
.
operator
=
operator
;
}
if
(
cmpType
.
equals
(
"any"
)){
this
.
operator
=
"Include"
;
}
}
public
String
getConditionName
()
{
return
conditionName
;
}
public
void
setConditionName
(
String
conditionName
)
{
this
.
conditionName
=
conditionName
;
}
public
String
getCmpType
()
{
return
cmpType
;
}
public
void
setCmpType
(
String
cmpType
)
{
this
.
cmpType
=
cmpType
;
}
public
String
getOperator
()
{
return
operator
;
}
public
void
setOperator
(
String
operator
)
{
this
.
operator
=
operator
;
}
public
String
getKeyword
()
{
return
keyword
;
}
public
void
setKeyword
(
String
keyword
)
{
this
.
keyword
=
keyword
;
}
public
void
setAccurateName
()
{
this
.
conditionName
=
this
.
conditionName
+
"_indep"
;
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/ListeningConstructor.java
View file @
6321ac3c
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.ConfigTermText
;
import
com.qiwu.chatbotbackend.entity.ConfigTermText
;
import
com.qiwu.chatbotbackend.entity.Premise
;
import
com.qiwu.chatbotbackend.entity.Premise
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.*
;
import
java.util.*
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.*;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.*;
public
class
ListeningConstructor
extends
ElementConstructor
{
public
class
ListeningConstructor
extends
ElementConstructor
{
public
ListeningConstructor
(
SqlHelper
helper
,
int
botId
,
String
botAccount
,
Map
<
String
,
StringBuffer
>
keywordMap
,
HashSet
<
String
>
exceptRelation
,
StringBuffer
POS
)
{
public
ListeningConstructor
(
SqlHelper
helper
,
int
botId
,
String
botAccount
,
Map
<
String
,
StringBuffer
>
keywordMap
,
HashSet
<
String
>
exceptRelation
,
StringBuffer
POS
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
botAccount
=
botAccount
;
this
.
botAccount
=
botAccount
;
this
.
exceptRelation
=
exceptRelation
;
this
.
exceptRelation
=
exceptRelation
;
this
.
keywordMap
=
keywordMap
;
this
.
keywordMap
=
keywordMap
;
this
.
POS
=
POS
;
this
.
POS
=
POS
;
}
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
}
}
public
static
void
cc
(
String
botAccount
,
JSONObject
gameELments
,
HashMap
<
String
,
JSONObject
>
plotIndex
,
List
<
ConfigTermText
>
configTermTextList
){
public
static
void
cc
(
String
botAccount
,
JSONObject
gameELments
,
HashMap
<
String
,
JSONObject
>
plotIndex
,
List
<
ConfigTermText
>
configTermTextList
){
int
size
=
0
;
int
size
=
0
;
String
feature
,
nextPlotId
,
reply
=
""
,
nextCondition
=
""
,
nextLocation
=
""
,
priority
;
String
feature
,
nextPlotId
,
reply
=
""
,
nextCondition
=
""
,
nextLocation
=
""
,
priority
;
String
nTaskLineName
,
lastTaskCondition
,
lastTaskReply
,
nextGameStep
;
String
nTaskLineName
,
lastTaskCondition
,
lastTaskReply
,
nextGameStep
;
Boolean
autoJump
=
false
;
Boolean
autoJump
=
false
;
List
<
Premise
>
curPremiseList
=
new
ArrayList
<
Premise
>();
List
<
Premise
>
curPremiseList
=
new
ArrayList
<
Premise
>();
List
<
Premise
>
hisPremiseList
=
new
ArrayList
<
Premise
>();
List
<
Premise
>
hisPremiseList
=
new
ArrayList
<
Premise
>();
JSONArray
listeningActions
=
gameELments
.
getJSONArray
(
"listeningActions"
);
JSONArray
listeningActions
=
gameELments
.
getJSONArray
(
"listeningActions"
);
JSONObject
plotNode
=
null
;
JSONObject
plotNode
=
null
;
if
(
listeningActions
==
null
)
if
(
listeningActions
==
null
)
return
;
return
;
size
=
listeningActions
.
size
();
size
=
listeningActions
.
size
();
JSONObject
config
=
null
;
JSONObject
config
=
null
;
for
(
int
i
=
0
;
i
<
size
;
i
++){
for
(
int
i
=
0
;
i
<
size
;
i
++){
plotNode
=
null
;
plotNode
=
null
;
autoJump
=
false
;
autoJump
=
false
;
priority
=
"2"
;
priority
=
"2"
;
feature
=
"match"
;
feature
=
"match"
;
config
=
listeningActions
.
getJSONObject
(
i
);
config
=
listeningActions
.
getJSONObject
(
i
);
curPremiseList
=
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
Premise
.
class
);
curPremiseList
=
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
Premise
.
class
);
hisPremiseList
=
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
Premise
.
class
);
hisPremiseList
=
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
Premise
.
class
);
Map
<
String
,
String
>
updateKnowledge
=
JSONObject
.
parseObject
(
config
.
getJSONObject
(
"updateKnowledge"
).
toJSONString
(),
Map
.
class
);
Map
<
String
,
String
>
updateKnowledge
=
JSONObject
.
parseObject
(
config
.
getJSONObject
(
"updateKnowledge"
).
toJSONString
(),
Map
.
class
);
nextPlotId
=
config
.
getString
(
"nextPlotId"
);
nextPlotId
=
config
.
getString
(
"nextPlotId"
);
if
(
nextPlotId
!=
null
){
if
(
nextPlotId
!=
null
){
plotNode
=
plotIndex
.
get
(
nextPlotId
);
plotNode
=
plotIndex
.
get
(
nextPlotId
);
}
}
if
(
plotNode
!=
null
){
if
(
plotNode
!=
null
){
reply
=
plotNode
.
getString
(
"plotText"
);
reply
=
plotNode
.
getString
(
"plotText"
);
nextCondition
=
plotNode
.
getString
(
"conditionName"
);
nextCondition
=
plotNode
.
getString
(
"conditionName"
);
nextLocation
=
plotNode
.
getString
(
"place"
);
nextLocation
=
plotNode
.
getString
(
"place"
);
autoJump
=
plotNode
.
getBoolean
(
"autoJump"
);
autoJump
=
plotNode
.
getBoolean
(
"autoJump"
);
if
(
nextCondition
==
null
||
nextCondition
.
equals
(
""
)){
if
(
nextCondition
==
null
||
nextCondition
.
equals
(
""
)){
nextCondition
=
DEFAULT_CONDITION
;
nextCondition
=
DEFAULT_CONDITION
;
}
}
if
(
autoJump
){
if
(
autoJump
){
feature
=
"match,activate:after"
;
feature
=
"match,activate:after"
;
updateKnowledge
.
put
(
"plot_jump_text"
,
"str+"
+
reply
);
updateKnowledge
.
put
(
"plot_jump_text"
,
"str+"
+
reply
);
nextCondition
=
"plot_"
+
nextPlotId
;
nextCondition
=
"plot_"
+
nextPlotId
;
reply
=
""
;
reply
=
""
;
}
else
{
}
else
{
feature
=
"match"
;
feature
=
"match"
;
}
}
if
(
config
.
getString
(
"priority"
)
!=
null
)
if
(
config
.
getString
(
"priority"
)
!=
null
)
priority
=
config
.
getString
(
"priority"
);
priority
=
config
.
getString
(
"priority"
);
updateKnowledge
.
put
(
nextLocation
+
"_activate_by"
,
""
);
updateKnowledge
.
put
(
nextLocation
+
"_activate_by"
,
""
);
updateKnowledge
.
put
(
nextLocation
+
"_activate_ready"
,
"0"
);
updateKnowledge
.
put
(
nextLocation
+
"_activate_ready"
,
"0"
);
updateKnowledge
.
put
(
"site"
,
nextLocation
);
updateKnowledge
.
put
(
"site"
,
nextLocation
);
nTaskLineName
=
String
.
format
(
TASK_LINE
,
nextLocation
);
nTaskLineName
=
String
.
format
(
TASK_LINE
,
nextLocation
);
//任务线最后一个condition
//任务线最后一个condition
lastTaskCondition
=
String
.
format
(
TASK_CONDITION
,
nextLocation
);
lastTaskCondition
=
String
.
format
(
TASK_CONDITION
,
nextLocation
);
lastTaskReply
=
String
.
format
(
TASK_REPLY
,
nextLocation
);
lastTaskReply
=
String
.
format
(
TASK_REPLY
,
nextLocation
);
nextGameStep
=
String
.
format
(
GAME_STEP_FORMAT
,
botAccount
,
nextPlotId
);
nextGameStep
=
String
.
format
(
GAME_STEP_FORMAT
,
botAccount
,
nextPlotId
);
updateKnowledge
.
put
(
lastTaskCondition
,
nextCondition
);
updateKnowledge
.
put
(
lastTaskCondition
,
nextCondition
);
updateKnowledge
.
put
(
lastTaskReply
,
reply
);
updateKnowledge
.
put
(
lastTaskReply
,
reply
);
updateKnowledge
.
put
(
nextPlotId
,
"1"
);
//下一步设为1
updateKnowledge
.
put
(
nextPlotId
,
"1"
);
//下一步设为1
updateKnowledge
.
put
(
nTaskLineName
,
nextGameStep
);
updateKnowledge
.
put
(
nTaskLineName
,
nextGameStep
);
updateKnowledge
.
put
(
"game_step"
,
nextGameStep
);
updateKnowledge
.
put
(
"game_step"
,
nextGameStep
);
}
else
{
}
else
{
feature
=
"match,return-0"
;
feature
=
"match,return-0"
;
}
}
ConfigTermText
configTermText
=
new
ConfigTermText
(
Map
<
String
,
Integer
>
gNameCount
=
new
HashMap
<
String
,
Integer
>();
curPremiseList
,
hisPremiseList
,
ConfigTermText
configTermText
=
new
ConfigTermText
(
updateKnowledge
,
curPremiseList
,
""
,
""
,
""
,
feature
,
reply
,
nextCondition
,
priority
hisPremiseList
,
);
updateKnowledge
,
""
,
""
,
""
,
feature
,
reply
,
nextCondition
,
priority
,
gNameCount
// System.out.println("生成:" + curPremiseList.get(0));
);
configTermTextList
.
add
(
configTermText
);
}
// System.out.println("生成:" + curPremiseList.get(0));
}
configTermTextList
.
add
(
configTermText
);
}
}
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/PlotConstructor2.java
View file @
6321ac3c
...
@@ -220,6 +220,9 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -220,6 +220,9 @@ public class PlotConstructor2 extends ElementConstructor {
int
branchSize
;
int
branchSize
;
List
<
Premise
>
curPremiseList
,
historyPremiseList
;
List
<
Premise
>
curPremiseList
,
historyPremiseList
;
//condition name 计数
Map
<
String
,
Integer
>
gNameCount
=
new
HashMap
<
String
,
Integer
>();
//设置初始化unknown文本
//设置初始化unknown文本
...
@@ -487,16 +490,12 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -487,16 +490,12 @@ public class PlotConstructor2 extends ElementConstructor {
}
}
//下一部剧情在不同地点时,为了防止到配置文件重复执行,需要加一个标志表示下一步剧情是否已经发生过
//下一部剧情在不同地点时,为了防止到配置文件重复执行,需要加一个标志表示下一步剧情是否已经发生过
// activate_by 下一个地点的剧情是由当前剧情激活的
// activate_by 下一个地点的剧情是由当前剧情激活的
//_activate_ready 下一个地点的剧情等待被激活
//_activate_ready 下一个地点的剧情等待被激活
appendKnowledge
(
extraUK
,
nextLocation
+
"_activate_by"
,
id
);
appendKnowledge
(
extraUK
,
nextLocation
+
"_activate_by"
,
id
);
appendKnowledge
(
extraUK
,
nextLocation
+
"_activate_ready"
,
"1"
);
appendKnowledge
(
extraUK
,
nextLocation
+
"_activate_ready"
,
"1"
);
// 如果不能直接到达所在地点,说明剧情1-1和1-2直接存在一个中间结点,这些更新操作会放在中间结点执行(动态生成,方法名:arriveActivatePlot2 这个中间结点会被当做一个监听剧情来处理)
// 如果不能直接到达所在地点,说明剧情1-1和1-2直接存在一个中间结点,这些更新操作会放在中间结点执行(动态生成,方法名:arriveActivatePlot2 这个中间结点会被当做一个监听剧情来处理)
arriveActivatePlot2
(
jsonObject
,
id
,
nextId
,
nextLocation
);
arriveActivatePlot2
(
jsonObject
,
id
,
nextId
,
nextLocation
);
...
@@ -506,13 +505,12 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -506,13 +505,12 @@ public class PlotConstructor2 extends ElementConstructor {
}
}
}
}
//System.out.println(branchNode);
//取出作者设定的剧情条件
//取出作者设定的剧情条件
curPremiseList
=
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
Premise
.
class
);
curPremiseList
=
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
Premise
.
class
);
historyPremiseList
=
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
Premise
.
class
);
historyPremiseList
=
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
Premise
.
class
);
addContext
(
curPremiseList
,
node
.
getString
(
"id"
),
i
);
addContext
(
historyPremiseList
,
node
.
getString
(
"id"
),
i
);
//是否将当前识别到的数据加入到已知数据列表
//是否将当前识别到的数据加入到已知数据列表
if
((
Boolean
)
branchNode
.
get
(
"includeCurInfo"
)){
if
((
Boolean
)
branchNode
.
get
(
"includeCurInfo"
)){
...
@@ -525,7 +523,6 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -525,7 +523,6 @@ public class PlotConstructor2 extends ElementConstructor {
appendFeature
(
extraFT
,
branchNode
.
getString
(
"extraFeature"
));
appendFeature
(
extraFT
,
branchNode
.
getString
(
"extraFeature"
));
}
}
//如果符合激活下一个剧情配置文件的操作
//如果符合激活下一个剧情配置文件的操作
if
(
doActivatePlot
(
nextAutoJump
,
location
,
nextLocation
,
moveWithPlot
)
){
if
(
doActivatePlot
(
nextAutoJump
,
location
,
nextLocation
,
moveWithPlot
)
){
//在配置文件中添加激活的操作
//在配置文件中添加激活的操作
...
@@ -540,7 +537,7 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -540,7 +537,7 @@ public class PlotConstructor2 extends ElementConstructor {
historyPremiseList
,
historyPremiseList
,
updateKnowledge
,
updateKnowledge
,
""
,
extraHP
.
toString
(),
extraUK
.
toString
(),
""
,
extraHP
.
toString
(),
extraUK
.
toString
(),
extraFT
.
toString
(),
reply
,
nextCondition
,
"1"
extraFT
.
toString
(),
reply
,
nextCondition
,
"1"
,
gNameCount
);
);
configTermText
.
setConfigName
(
"plot_"
+
id
,
false
);
configTermText
.
setConfigName
(
"plot_"
+
id
,
false
);
...
@@ -569,8 +566,6 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -569,8 +566,6 @@ public class PlotConstructor2 extends ElementConstructor {
configTermText
.
setAuxiliaryPriority
(
"3"
);
configTermText
.
setAuxiliaryPriority
(
"3"
);
configTermTextList
.
add
(
configTermText
);
configTermTextList
.
add
(
configTermText
);
//将子结点加入队列
//将子结点加入队列
adjId
=
nextId
;
adjId
=
nextId
;
plotEnQueue
(
queue
,
id
,
adjId
,
nextUnknownText
,
curAutoJump
);
plotEnQueue
(
queue
,
id
,
adjId
,
nextUnknownText
,
curAutoJump
);
...
@@ -585,19 +580,8 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -585,19 +580,8 @@ public class PlotConstructor2 extends ElementConstructor {
extraUK
.
setLength
(
0
);
extraUK
.
setLength
(
0
);
skipText
.
setLength
(
0
);
skipText
.
setLength
(
0
);
arriveUK
.
setLength
(
0
);
arriveUK
.
setLength
(
0
);
}
}
}
}
/**
/**
* ----------------------------------------------------------------------------------------------------
* ----------------------------------------------------------------------------------------------------
* 剧情不设条件时的处理
* 剧情不设条件时的处理
...
@@ -923,10 +907,10 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -923,10 +907,10 @@ public class PlotConstructor2 extends ElementConstructor {
//激活下一步剧情的几个条件:1. condition 到沙滩 2. 沙滩_activate_by 沙滩的剧情是有当前剧情激活的 3. 沙滩的剧情处于等待激活的状态 4. 当前地点和沙滩地点相邻或可以直接到达
//激活下一步剧情的几个条件:1. condition 到沙滩 2. 沙滩_activate_by 沙滩的剧情是有当前剧情激活的 3. 沙滩的剧情处于等待激活的状态 4. 当前地点和沙滩地点相邻或可以直接到达
// 2.3 两个条件是特意加的
// 2.3 两个条件是特意加的
curPremiseList
.
add
(
new
Premise
(
GOTO_CONDITION
,
"match"
,
"Include"
,
nextLocation
));
curPremiseList
.
add
(
new
Premise
(
GOTO_CONDITION
,
"match"
,
"Include"
,
nextLocation
,
false
));
hisPremiseList
.
add
(
new
Premise
(
nextLocation
+
"_activate_by"
,
"match"
,
"Include"
,
plotId
));
hisPremiseList
.
add
(
new
Premise
(
nextLocation
+
"_activate_by"
,
"match"
,
"Include"
,
plotId
,
false
));
hisPremiseList
.
add
(
new
Premise
(
nextLocation
+
"_activate_ready"
,
"match"
,
"Include"
,
"1"
));
hisPremiseList
.
add
(
new
Premise
(
nextLocation
+
"_activate_ready"
,
"match"
,
"Include"
,
"1"
,
false
));
hisPremiseList
.
add
(
new
Premise
(
"isNeighbour:"
+
GOTO_CONDITION
,
"match"
,
"Include"
,
"1+3+4"
));
hisPremiseList
.
add
(
new
Premise
(
"isNeighbour:"
+
GOTO_CONDITION
,
"match"
,
"Include"
,
"1+3+4"
,
false
));
//无匹配次数清零
//无匹配次数清零
...
@@ -1003,20 +987,26 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -1003,20 +987,26 @@ public class PlotConstructor2 extends ElementConstructor {
}
}
private
ConfigTermText
createTermExtra2
(
ConfigTermText
term
)
{
private
ConfigTermText
createTermExtra2
(
ConfigTermText
term
)
{
String
hPremise
=
"qa_score::number-Smaller=98"
;
String
hPremise
=
"qa_score::number-Smaller=98"
;
String
featureStr
=
"match"
;
// String featureStr = ",match,includeCurInfo,activate:after";
String
nextStr
=
" "
;
String
configName
=
term
.
getConfigName
()+
"_qa2"
;
String
configName
=
term
.
getConfigName
()+
"_qa2"
;
if
(
term
.
getFeature
().
indexOf
(
"activate"
)
!=
-
1
)
{
String
nextStr
=
term
.
getNextStep
();
nextStr
=
term
.
getNextStep
()
+
","
+
nextStr
;
}
ConfigTermText
newTerm
=
(
ConfigTermText
)
term
.
clone
();
ConfigTermText
newTerm
=
(
ConfigTermText
)
term
.
clone
();
newTerm
.
setHisPremise
(
hPremise
);
newTerm
.
setHisPremise
(
hPremise
);
newTerm
.
setConfigName
(
configName
,
false
);
newTerm
.
setConfigName
(
configName
,
false
);
newTerm
.
setFeature
(
featureStr
);
//
newTerm.setFeature(featureStr);
newTerm
.
setNextStep
(
nextStr
);
newTerm
.
setNextStep
(
nextStr
);
newTerm
.
setStatus
(
"sleeping"
);
newTerm
.
setStatus
(
"sleeping"
);
//newTerm.setReply("");
return
newTerm
;
return
newTerm
;
}
}
private
void
addContext
(
List
<
Premise
>
premises
,
String
plot
,
int
branch
)
{
for
(
Premise
pre
:
premises
)
{
pre
.
setPlot
(
plot
);
pre
.
setBranch
(
branch
);
}
}
}
}
参数和接口文档/功能文档.docx
deleted
100644 → 0
View file @
947af96a
File deleted
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