Compare commits
No commits in common. "011084b8ecc59475994692b740d40067eccd24ad" and "1927c922d72acef7681e52b7f020211f5c6eb891" have entirely different histories.
011084b8ec
...
1927c922d7
@ -3,17 +3,17 @@ import { Group } from "@Model/Group";
|
|||||||
import { Individual } from "@Model/Individual";
|
import { Individual } from "@Model/Individual";
|
||||||
import { Model } from "@Model/Model";
|
import { Model } from "@Model/Model";
|
||||||
|
|
||||||
type IContactAttackingBehaviorParameter = {
|
type IAttackingBehaviorParameter = {
|
||||||
target: "CLG",
|
target: "CLG",
|
||||||
success: "number",
|
success: "number",
|
||||||
range: "number"
|
range: "number"
|
||||||
}
|
}
|
||||||
|
|
||||||
type IContactAttackingBehaviorEvent = {}
|
type IAttackingBehaviorEvent = {}
|
||||||
|
|
||||||
class ContactAttacking extends Behavior<IContactAttackingBehaviorParameter, IContactAttackingBehaviorEvent> {
|
class Attacking extends Behavior<IAttackingBehaviorParameter, IAttackingBehaviorEvent> {
|
||||||
|
|
||||||
public override behaviorId: string = "ContactAttacking";
|
public override behaviorId: string = "Attacking";
|
||||||
|
|
||||||
public override behaviorName: string = "$Title";
|
public override behaviorName: string = "$Title";
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ class ContactAttacking extends Behavior<IContactAttackingBehaviorParameter, ICon
|
|||||||
|
|
||||||
public override terms: Record<string, Record<string, string>> = {
|
public override terms: Record<string, Record<string, string>> = {
|
||||||
"$Title": {
|
"$Title": {
|
||||||
"ZH_CN": "接触攻击",
|
"ZH_CN": "攻击",
|
||||||
"EN_US": "Contact Attacking"
|
"EN_US": "Attacking"
|
||||||
},
|
},
|
||||||
"$Target": {
|
"$Target": {
|
||||||
"ZH_CN": "攻击目标",
|
"ZH_CN": "攻击目标",
|
||||||
@ -76,4 +76,4 @@ class ContactAttacking extends Behavior<IContactAttackingBehaviorParameter, ICon
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ContactAttacking };
|
export { Attacking };
|
@ -4,9 +4,7 @@ import { PhysicsDynamics } from "@Behavior/PhysicsDynamics";
|
|||||||
import { Brownian } from "@Behavior/Brownian";
|
import { Brownian } from "@Behavior/Brownian";
|
||||||
import { BoundaryConstraint } from "@Behavior/BoundaryConstraint";
|
import { BoundaryConstraint } from "@Behavior/BoundaryConstraint";
|
||||||
import { Tracking } from "@Behavior/Tracking";
|
import { Tracking } from "@Behavior/Tracking";
|
||||||
import { ContactAttacking } from "@Behavior/ContactAttacking";
|
import { Attacking } from "@Behavior/Attacking";
|
||||||
import { ContactAssimilate } from "@Behavior/ContactAssimilate";
|
|
||||||
import { DelayAssimilate } from "@Behavior/DelayAssimilate";
|
|
||||||
|
|
||||||
const AllBehaviors: IAnyBehaviorRecorder[] = [
|
const AllBehaviors: IAnyBehaviorRecorder[] = [
|
||||||
new BehaviorRecorder(Template),
|
new BehaviorRecorder(Template),
|
||||||
@ -14,9 +12,7 @@ const AllBehaviors: IAnyBehaviorRecorder[] = [
|
|||||||
new BehaviorRecorder(Brownian),
|
new BehaviorRecorder(Brownian),
|
||||||
new BehaviorRecorder(BoundaryConstraint),
|
new BehaviorRecorder(BoundaryConstraint),
|
||||||
new BehaviorRecorder(Tracking),
|
new BehaviorRecorder(Tracking),
|
||||||
new BehaviorRecorder(ContactAttacking),
|
new BehaviorRecorder(Attacking),
|
||||||
new BehaviorRecorder(ContactAssimilate),
|
|
||||||
new BehaviorRecorder(DelayAssimilate),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
import { Behavior } from "@Model/Behavior";
|
|
||||||
import { Group } from "@Model/Group";
|
|
||||||
import { Individual } from "@Model/Individual";
|
|
||||||
import { Model } from "@Model/Model";
|
|
||||||
|
|
||||||
type IContactAssimilateBehaviorParameter = {
|
|
||||||
target: "CLG",
|
|
||||||
assimilate: "CG",
|
|
||||||
success: "number",
|
|
||||||
range: "number"
|
|
||||||
}
|
|
||||||
|
|
||||||
type IContactAssimilateBehaviorEvent = {}
|
|
||||||
|
|
||||||
class ContactAssimilate extends Behavior<IContactAssimilateBehaviorParameter, IContactAssimilateBehaviorEvent> {
|
|
||||||
|
|
||||||
public override behaviorId: string = "ContactAssimilate";
|
|
||||||
|
|
||||||
public override behaviorName: string = "$Title";
|
|
||||||
|
|
||||||
public override iconName: string = "SyncStatus";
|
|
||||||
|
|
||||||
public override describe: string = "$Intro";
|
|
||||||
|
|
||||||
public override category: string = "$Interactive";
|
|
||||||
|
|
||||||
public override parameterOption = {
|
|
||||||
target: { type: "CLG", name: "$Target" },
|
|
||||||
assimilate: { type: "CG", name: "$Assimilate" },
|
|
||||||
range: { type: "number", name: "$Range", defaultValue: .05, numberMin: 0, numberStep: .01 },
|
|
||||||
success: { type: "number", name: "$Success", defaultValue: 90, numberMin: 0, numberMax: 100, numberStep: 5 }
|
|
||||||
};
|
|
||||||
|
|
||||||
public effect = (individual: Individual, group: Group, model: Model, t: number): void => {
|
|
||||||
|
|
||||||
let assimilateGroup = this.parameter.assimilate.objects;
|
|
||||||
if (!assimilateGroup) return;
|
|
||||||
|
|
||||||
for (let i = 0; i < this.parameter.target.objects.length; i++) {
|
|
||||||
const targetGroup = this.parameter.target.objects[i];
|
|
||||||
|
|
||||||
targetGroup.individuals.forEach((targetIndividual) => {
|
|
||||||
|
|
||||||
// 排除自己
|
|
||||||
if (targetIndividual === individual) return;
|
|
||||||
let dis = targetIndividual.distanceTo(individual);
|
|
||||||
|
|
||||||
// 进入同化范围
|
|
||||||
if (dis <= this.parameter.range) {
|
|
||||||
|
|
||||||
// 成功判定
|
|
||||||
if (Math.random() * 100 < this.parameter.success) {
|
|
||||||
targetIndividual.transfer(assimilateGroup!);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override terms: Record<string, Record<string, string>> = {
|
|
||||||
"$Title": {
|
|
||||||
"ZH_CN": "接触同化",
|
|
||||||
"EN_US": "Contact Assimilate"
|
|
||||||
},
|
|
||||||
"$Target": {
|
|
||||||
"ZH_CN": "从哪个群...",
|
|
||||||
"EN_US": "From group..."
|
|
||||||
},
|
|
||||||
"$Assimilate": {
|
|
||||||
"ZH_CN": "到哪个群...",
|
|
||||||
"EN_US": "To group..."
|
|
||||||
},
|
|
||||||
"$Range": {
|
|
||||||
"ZH_CN": "同化范围 (m)",
|
|
||||||
"EN_US": "Assimilate range (m)"
|
|
||||||
},
|
|
||||||
"$Success": {
|
|
||||||
"ZH_CN": "成功率 (%)",
|
|
||||||
"EN_US": "Success rate (%)"
|
|
||||||
},
|
|
||||||
"$Intro": {
|
|
||||||
"ZH_CN": "将进入同化范围内的个体同化至另一个群",
|
|
||||||
"EN_US": "Assimilate individuals who enter the assimilation range to another group"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export { ContactAssimilate };
|
|
@ -1,96 +0,0 @@
|
|||||||
import { Behavior } from "@Model/Behavior";
|
|
||||||
import { Group } from "@Model/Group";
|
|
||||||
import { Individual } from "@Model/Individual";
|
|
||||||
import { Model } from "@Model/Model";
|
|
||||||
|
|
||||||
type IDelayAssimilateBehaviorParameter = {
|
|
||||||
target: "CG",
|
|
||||||
maxDelay: "number",
|
|
||||||
minDelay: "number",
|
|
||||||
success: "number"
|
|
||||||
}
|
|
||||||
|
|
||||||
type IDelayAssimilateBehaviorEvent = {}
|
|
||||||
|
|
||||||
class DelayAssimilate extends Behavior<IDelayAssimilateBehaviorParameter, IDelayAssimilateBehaviorEvent> {
|
|
||||||
|
|
||||||
public override behaviorId: string = "DelayAssimilate";
|
|
||||||
|
|
||||||
public override behaviorName: string = "$Title";
|
|
||||||
|
|
||||||
public override iconName: string = "FunctionalManagerDashboard";
|
|
||||||
|
|
||||||
public override describe: string = "$Intro";
|
|
||||||
|
|
||||||
public override category: string = "$Initiative";
|
|
||||||
|
|
||||||
public override parameterOption = {
|
|
||||||
target: { type: "CG", name: "$Target" },
|
|
||||||
maxDelay: { type: "number", name: "$Max.Delay", defaultValue: 20, numberStep: 1, numberMin: 0 },
|
|
||||||
minDelay: { type: "number", name: "$Min.Delay", defaultValue: 5, numberStep: 1, numberMin: 0 },
|
|
||||||
success: { type: "number", name: "$Success", defaultValue: 90, numberStep: 5, numberMin: 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
public effect = (individual: Individual, group: Group, model: Model, t: number): void => {
|
|
||||||
|
|
||||||
let assimilateGroup = this.parameter.target.objects;
|
|
||||||
if (!assimilateGroup) return;
|
|
||||||
|
|
||||||
const {maxDelay, minDelay, success} = this.parameter;
|
|
||||||
|
|
||||||
let nextTime = individual.getData("DelayAssimilate.nextTime") ??
|
|
||||||
minDelay + Math.random() * (maxDelay - minDelay);
|
|
||||||
let currentTime = individual.getData("DelayAssimilate.currentTime") ?? 0;
|
|
||||||
|
|
||||||
currentTime += t;
|
|
||||||
if (currentTime > nextTime) {
|
|
||||||
|
|
||||||
// 成功判定
|
|
||||||
if (Math.random() * 100 < success) {
|
|
||||||
individual.transfer(assimilateGroup);
|
|
||||||
nextTime = undefined;
|
|
||||||
currentTime = undefined;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
nextTime = minDelay + Math.random() * (maxDelay - minDelay);
|
|
||||||
currentTime = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
individual.setData("DelayAssimilate.nextTime", nextTime);
|
|
||||||
individual.setData("DelayAssimilate.currentTime", currentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override terms: Record<string, Record<string, string>> = {
|
|
||||||
"$Title": {
|
|
||||||
"ZH_CN": "延迟同化",
|
|
||||||
"EN_US": "Delayed assimilation"
|
|
||||||
},
|
|
||||||
"$Intro": {
|
|
||||||
"ZH_CN": "随着时间的推移,个体逐渐向另一个群同化。",
|
|
||||||
"EN_US": "Over time, individuals gradually assimilate to another group."
|
|
||||||
},
|
|
||||||
"$Target": {
|
|
||||||
"ZH_CN": "同化目标",
|
|
||||||
"EN_US": "Assimilation target"
|
|
||||||
},
|
|
||||||
"$Max.Delay": {
|
|
||||||
"ZH_CN": "最长时间",
|
|
||||||
"EN_US": "Longest time"
|
|
||||||
},
|
|
||||||
"$Min.Delay": {
|
|
||||||
"ZH_CN": "最短时间",
|
|
||||||
"EN_US": "Shortest time"
|
|
||||||
},
|
|
||||||
"$Success": {
|
|
||||||
"ZH_CN": "成功率",
|
|
||||||
"EN_US": "Minimum strength"
|
|
||||||
},
|
|
||||||
"$Initiative": {
|
|
||||||
"ZH_CN": "主动",
|
|
||||||
"EN_US": "Initiative"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export { DelayAssimilate };
|
|
@ -131,8 +131,8 @@ class SimulatorWeb extends Component {
|
|||||||
tracking.name = "Tracking"; tracking.color = [80, 200, 250];
|
tracking.name = "Tracking"; tracking.color = [80, 200, 250];
|
||||||
tracking.parameter.target.picker = fishLabel;
|
tracking.parameter.target.picker = fishLabel;
|
||||||
|
|
||||||
let attacking = this.status.model.addBehavior(getBehaviorById("ContactAttacking"));
|
let attacking = this.status.model.addBehavior(getBehaviorById("Attacking"));
|
||||||
attacking.name = "Contact Attacking"; attacking.color = [120, 100, 250];
|
attacking.name = "Attacking"; attacking.color = [120, 100, 250];
|
||||||
attacking.parameter.target.picker = fishLabel;
|
attacking.parameter.target.picker = fishLabel;
|
||||||
|
|
||||||
fish1.addBehavior(dynamicFish);
|
fish1.addBehavior(dynamicFish);
|
||||||
|
Loading…
Reference in New Issue
Block a user