mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-02 14:45:20 +02:00
Bug fix for validator execution before the bot initialization
This commit is contained in:
parent
1195a194d5
commit
7c96cca59c
1 changed files with 22 additions and 10 deletions
|
@ -126,16 +126,25 @@ class CookingCraftingTaskValidator {
|
|||
this.data = data;
|
||||
this.agent = agent;
|
||||
}
|
||||
validate() {
|
||||
const result = checkItemPresence(this.data, this.agent);
|
||||
let score = 0;
|
||||
if (result.success) {
|
||||
score = 1;
|
||||
validate(has_initiated) {
|
||||
if (has_initiated) {
|
||||
|
||||
const result = checkItemPresence(this.data, this.agent);
|
||||
let score = 0;
|
||||
if (result.success) {
|
||||
score = 1;
|
||||
}
|
||||
return {
|
||||
"valid": result.success,
|
||||
"score": score,
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
"valid": false,
|
||||
"score": 0
|
||||
};
|
||||
}
|
||||
return {
|
||||
"valid": result.success,
|
||||
"score": score,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,6 +197,7 @@ export class Task {
|
|||
|
||||
this.name = this.agent.name;
|
||||
this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
|
||||
this.agent_initialized = false;
|
||||
}
|
||||
|
||||
getAgentGoal() {
|
||||
|
@ -239,7 +249,7 @@ export class Task {
|
|||
isDone() {
|
||||
let res = null;
|
||||
if (this.validator)
|
||||
res = this.validator.validate();
|
||||
res = this.validator.validate(this.agent_initialized);
|
||||
if (res && res.valid) {
|
||||
return {"message": 'Task successful', "score": res.score};
|
||||
}
|
||||
|
@ -311,6 +321,8 @@ export class Task {
|
|||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
|
||||
this.agent_initialized = true;
|
||||
|
||||
if (this.initiator) {
|
||||
await this.initiator.init();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue