use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project java-dialogflow by googleapis.
the class ITSystemTest method searchAgentsTest.
@Test
public void searchAgentsTest() {
SearchAgentsRequest request = SearchAgentsRequest.newBuilder().setParent(PROJECT_NAME.toString()).build();
for (Agent actualAgent : agentsClient.searchAgents(request).iterateAll()) {
assertEquals(PROJECT_NAME.toString(), actualAgent.getParent());
assertEquals(DISPLAY_NAME, actualAgent.getDisplayName());
assertEquals(DEFAULT_LANGUAGE_CODE, actualAgent.getDefaultLanguageCode());
assertEquals(TIME_ZONE, actualAgent.getTimeZone());
assertEquals(Agent.MatchMode.MATCH_MODE_HYBRID, actualAgent.getMatchMode());
assertEquals(Agent.ApiVersion.API_VERSION_V2, actualAgent.getApiVersion());
assertEquals(Agent.Tier.TIER_STANDARD, actualAgent.getTier());
}
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project study-prj by SaminZou.
the class Client method main.
public static void main(String[] args) {
// style1
// 代理者和被代理者必须实现同一个接口 代理者的目的是隐藏被代理者的行为
Subject star = new Star();
Subject proxy = new Agent(star);
proxy.movie();
System.out.println("-------------------------------------------------------");
// style2
// 这种方式是客户端直接访问被代理角色,代理由被代理角色指定。
// 前面的一种方式则是客户端不能访问直接访问被代理角色,只能访问代理。
Subject2 star2 = new Star2();
Subject2 proxy2 = star2.getAgent();
proxy2.movie();
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project cg by nmahoude.
the class MoveAI method think.
public void think(State currentState) {
state.copyFrom(currentState);
Agent agent = state.agents[0];
BFS bfs = new BFS();
bfs.process(state, agent.pos, MAX_MOVE);
Route emptyRoute = new Route();
emptyRoute.state.copyFrom(currentState);
List<Route> allRoutes = new ArrayList<>();
allRoutes.add(emptyRoute);
boolean foundNewRoutes = true;
while (foundNewRoutes) {
List<Route> newRoutesToCheck = new ArrayList<>();
foundNewRoutes = false;
System.err.println("Total routes : " + allRoutes.size());
for (Route route : allRoutes) {
if (route.explored)
continue;
route.explored = true;
List<Route> newRoutes = route.findRouteToAnyQuestItem();
System.err.println("Checking route : " + route.debug());
System.err.println(" => found " + newRoutes.size() + " new routes to questItems");
if (!newRoutes.isEmpty()) {
foundNewRoutes = true;
newRoutesToCheck.addAll(newRoutes);
}
}
allRoutes.addAll(newRoutesToCheck);
}
// now find the best route ...
double bestScore = Double.NEGATIVE_INFINITY;
Route best = null;
for (Route route : allRoutes) {
double score = route.questItemsFound * 100;
if (score > bestScore) {
bestScore = score;
best = route;
}
}
if (best != null && !best.route.isEmpty()) {
// remove objects
best.state.applyMoves(best.route);
best = best.goToBestSpotForNextPush();
List<Pos> route = best.route;
actions = rebuildFromRoute(route);
return;
} else {
best = emptyRoute.goToBestSpotForNextPush();
List<Pos> route = best.route;
if (route.size() > 1) {
actions = rebuildFromRoute(route);
} else {
actions = PASS;
}
return;
}
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project cg by nmahoude.
the class Simulation method computePush.
private void computePush() {
Dir[] validDirs = move.dir1.pushDirections();
boolean validPushDirection = (move.dir2 == validDirs[0]) || (move.dir2 == validDirs[1]) || (move.dir2 == validDirs[2]);
if (!validPushDirection) {
// dir2 is invalid
move.dir2Invalid();
return;
}
int targetX = agent.x + move.dir1.dx;
int targetY = agent.y + move.dir1.dy;
Agent pushed = state.agents[state.occupiedBy(targetX, targetY)];
int pushToX = targetX + move.dir2.dx;
int pushToY = targetY + move.dir2.dy;
if ((!state.isValid(pushToX, pushToY)) || (state.isOccupied(move.id, pushToX, pushToY))) {
move.dir2Invalid();
return;
}
int pushToHeight = state.getHeight(pushToX, pushToY);
int pushFromHeight = state.getHeight(targetX, targetY);
if (pushToHeight >= FINAL_HEIGHT || pushToHeight > pushFromHeight + 1) {
move.dir2Invalid();
return;
}
// TODO check if we know a agent is at pushTo and would block the action ?
// move ok, update agent position & grid
agent.x = agent.x;
agent.y = agent.y;
state.setHeight(targetX, targetY, pushFromHeight + 1);
pushed.x = pushToX;
pushed.y = pushToY;
move.dir1X = targetX;
move.dir1Y = targetY;
move.dir1Height = pushFromHeight;
move.dir2X = pushToX;
move.dir2Y = pushToY;
move.dir2Height = pushToHeight;
move.allValid();
return;
}
use of com.google.cloud.dialogflow.cx.v3beta1.Agent in project cg by nmahoude.
the class MC2 method minimizeOpp.
private double minimizeOpp(Agent originalMe, Agent originalOpp) {
Agent me = new Agent(0);
Agent opp = new Agent(1);
// inverse both players
me.copyFrom(originalOpp);
opp.copyFrom(originalMe);
double minScore = scorer.score(originalMe, originalOpp);
for (int i = 0; i < 200; i++) {
oppCurrentActionsFE = 0;
boolean stop = false;
while (!stop) {
if (Player.random.nextInt(100) > 98) {
stop = true;
} else {
possibleActionsFE = 0;
computeAttacks(me, opp);
if (possibleActionsFE == 0) {
stop = true;
} else {
int rand = Player.random.nextInt(possibleActionsFE);
Action chosen = possibleActions[rand];
oppCurrentActions[oppCurrentActionsFE++] = chosen;
sim.run(me, opp, chosen);
}
}
}
minScore = Math.min(scorer.score(opp, me), minScore);
}
return minScore;
}
Aggregations