Commit d30c1983 by 赵国君

停留,合并剧情等问题修复

parent 8b6893aa
...@@ -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 < 100;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 + "_independent"; 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"))
......
...@@ -202,7 +202,8 @@ public class ConfigTermUtils { ...@@ -202,7 +202,8 @@ public class ConfigTermUtils {
} }
} }
configTermText = new ConfigTermText(curPremiseList, hisPremiseList, updateKnowledge, "", "", "", featureText.toString(), reply, nextStepText.toString(), auxiliaryPriority); Map<String ,Integer> gNameCount = new HashMap<String , Integer>();
configTermText = new ConfigTermText(curPremiseList, hisPremiseList, updateKnowledge, "", "", "", featureText.toString(), reply, nextStepText.toString(), auxiliaryPriority, gNameCount);
configName = configJson.getString("configName"); configName = configJson.getString("configName");
if(configName != null && !configName.equals("")) { if(configName != null && !configName.equals("")) {
......
...@@ -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,25 +177,27 @@ public class ConfigTermText implements Cloneable{ ...@@ -177,25 +177,27 @@ 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");
} }
} }
......
...@@ -5,6 +5,61 @@ public class Premise { ...@@ -5,6 +5,61 @@ public class Premise {
private String cmpType = ""; private String cmpType = "";
private String operator = ""; private String operator = "";
private String keyword = ""; private String keyword = "";
private Boolean accurateMatch = false;
private String plot = "";
private int branch = 0;
public String getPlot() {
return plot;
}
public void setPlot(String plot) {
this.plot = plot;
}
public int getBranch() {
return branch;
}
public void setBranch(int branch) {
this.branch = branch;
}
public Boolean getAccurateMatch() {
return accurateMatch;
}
public void setAccurateMatch(Boolean accurateMatch) {
this.accurateMatch = accurateMatch;
}
public Premise(String conditionName, String cmpType, String operator, String keyword, Boolean accurateMatch) {
this.conditionName = conditionName;
this.cmpType = cmpType;
this.operator = operator;
this.keyword = keyword;
this.accurateMatch = accurateMatch;
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";
}
if(accurateMatch == null)
{
this.accurateMatch = false;
}
}
public Premise(String conditionName, String cmpType, String operator, String keyword) { public Premise(String conditionName, String cmpType, String operator, String keyword) {
...@@ -12,6 +67,7 @@ public class Premise { ...@@ -12,6 +67,7 @@ public class Premise {
this.cmpType = cmpType; this.cmpType = cmpType;
this.operator = operator; this.operator = operator;
this.keyword = keyword; this.keyword = keyword;
this.accurateMatch = false;
if(cmpType == null){ if(cmpType == null){
this.cmpType = "match"; this.cmpType = "match";
...@@ -60,4 +116,8 @@ public class Premise { ...@@ -60,4 +116,8 @@ public class Premise {
public void setKeyword(String keyword) { public void setKeyword(String keyword) {
this.keyword = keyword; this.keyword = keyword;
} }
public void setAccurateName() {
this.conditionName = this.conditionName + "_indep";
}
} }
...@@ -108,11 +108,13 @@ public class ListeningConstructor extends ElementConstructor{ ...@@ -108,11 +108,13 @@ public class ListeningConstructor extends ElementConstructor{
feature = "match,return-0"; feature = "match,return-0";
} }
Map<String ,Integer> gNameCount = new HashMap<String , Integer>();
ConfigTermText configTermText = new ConfigTermText( ConfigTermText configTermText = new ConfigTermText(
curPremiseList, curPremiseList,
hisPremiseList, hisPremiseList,
updateKnowledge, updateKnowledge,
"", "", "", feature, reply, nextCondition, priority "", "", "", feature, reply, nextCondition, priority, gNameCount
); );
// System.out.println("生成:" + curPremiseList.get(0)); // System.out.println("生成:" + curPremiseList.get(0));
......
...@@ -221,6 +221,9 @@ public class PlotConstructor2 extends ElementConstructor { ...@@ -221,6 +221,9 @@ public class PlotConstructor2 extends ElementConstructor {
List<Premise> curPremiseList, historyPremiseList; List<Premise> curPremiseList, historyPremiseList;
//condition name 计数
Map<String ,Integer> gNameCount = new HashMap<String , Integer>();
//设置初始化unknown文本 //设置初始化unknown文本
root.put("nextUnknownText", varInitialMap.get("unknownText")); root.put("nextUnknownText", varInitialMap.get("unknownText"));
...@@ -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);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment