Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39,107 changes: 39,107 additions & 0 deletions 100_debug.txt

Large diffs are not rendered by default.

38,835 changes: 38,835 additions & 0 deletions 11000_debug.txt

Large diffs are not rendered by default.

38,805 changes: 38,805 additions & 0 deletions 14713_debug.txt

Large diffs are not rendered by default.

38,913 changes: 38,913 additions & 0 deletions 15000_debug.txt

Large diffs are not rendered by default.

38,726 changes: 38,726 additions & 0 deletions 7000_debug.txt

Large diffs are not rendered by default.

38,681 changes: 38,681 additions & 0 deletions 7249_debug.txt

Large diffs are not rendered by default.

38,786 changes: 38,786 additions & 0 deletions 9000_debug.txt

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions behavior/abehavior.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@



/**
* Created by bricks on 6/19/2018.
*/

//import { NamedModulesPlugin } from "webpack";
import Vector3 from "@crowdedjs/math"

class ABehavior {

index;
location;
agents;
positions;
msec;


constructor(myIndex) {
this.index = myIndex;
}

update(agents, positions, msec) {
//Do nothing since this is the default "none" behavior.

let idx = agents[this.index].idx;
let position = positions.find(a=>a.id == this.index);
if(!position || position.length == 0) return null; //Most likely our first tick and the simulation hasn't given us an official position yet
let x = position.x;
let y = position.y;
let z = position.z;

console.log(new Vector3(x,y,z))
this.location = new Vector3(x, y, z);
this.agents = agents;
this.positions = positions;
this.msec = msec;

return this.checkEndOfSimulation();

}


}
export default ABehavior;
29 changes: 29 additions & 0 deletions behavior/add-patient-to-ct-queue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import fluentBehaviorTree from "@crowdedjs/fluent-behavior-tree"

class AssignPatientToCTQueue {
constructor(myIndex, bed, hospital) {
this.index = myIndex;
this.hospital = hospital;

const builder = new fluentBehaviorTree.BehaviorTreeBuilder();

let self = this;
let me = () => this.hospital.agentConstants.find(a => a.id == myIndex);;

this.tree = builder
.sequence("Assign Patient To CT Queue")
.do("Assign Patient", (t) => {

let myPatient = me().getCurrentPatient();
this.hospital.getCTQueue().add(myPatient);
console.log(this.hospital.getCTQueue());

return fluentBehaviorTree.BehaviorTreeStatus.Success;
})
.end()
.build();
}

}

export default AssignPatientToCTQueue;
36 changes: 36 additions & 0 deletions behavior/assign-bed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fluentBehaviorTree from "@crowdedjs/fluent-behavior-tree"
import Vector3 from "@crowdedjs/math"

class AssignBed {
constructor(myIndex, bed, hospital) {
this.index = myIndex;
this.bed = bed;
this.hospital = hospital;

const builder = new fluentBehaviorTree.BehaviorTreeBuilder();
let self = this;//Since we need to reference this in anonymous functions, we need a reference

this.tree = builder

// FINDS FIRST AVAILABLE BED, THEN ADDS ROOM TO NURSE'S LIST
// NEED TO HAVE LIST OF AVAILABLE BEDS/ROOMS THEN FIND
// ONE THAT IS AVAILABLE, AND ADD TO NURSE'S LIST

// CURRENTLY USER FEEDS LOCATION TO THIS BEHAVIOR, THEN IT
// ADDS VECTOR3 TO NURSE'S LIST

.sequence("Assign Bed")
.do("Set Bed Location", (t) => {
let agent = this.hospital.agentConstants.find(a => a.id == myIndex);
agent.addRoom(Vector3.fromObject(this.bed));
//console.log("Assigning bed " + myIndex);

return fluentBehaviorTree.BehaviorTreeStatus.Success;
})
.end()
.build();
}

}

export default AssignBed;
33 changes: 33 additions & 0 deletions behavior/assign-computer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fluentBehaviorTree from "@crowdedjs/fluent-behavior-tree"
import Vector3 from "@crowdedjs/math"


class AssignComputer {

constructor(myIndex, room, hospital) {
this.index = myIndex;
this.room = room;
this.hospital = hospital;


const builder = new fluentBehaviorTree.BehaviorTreeBuilder();
let self = this;//Since we need to reference this in anonymous functions, we need a reference

this.tree = builder
.sequence("Assign Computer")
//Set the computer. This is a one-shot behavior since we only want to
//update the return value once
.do("Set Computer Location", (t) => {
let agent = this.hospital.agentConstants.find(a => a.id == myIndex);

agent.Computer = Vector3.fromObject(this.room)

return fluentBehaviorTree.BehaviorTreeStatus.Success;
})
.end()
.build();
}

}

export default AssignComputer;
69 changes: 69 additions & 0 deletions behavior/assign-patient-to-triage-nurse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import PatientTempState from "../support/patient-temp-state.js";
import fluentBehaviorTree from "@crowdedjs/fluent-behavior-tree"
import Vector3 from "@crowdedjs/math"

class AssignPatientToTriageNurse {

constructor(myIndex, hospital) {
this.index = myIndex;
this.hospital = hospital;


const builder = new fluentBehaviorTree.BehaviorTreeBuilder();

let self = this;
let me = () => this.hospital.agentConstants.find(a => a.id == myIndex);;

this.tree = builder
.sequence("Assign Patient To Triage Nurse")
.do("Assign Patient", (t) => {
let agent = this.hospital.agentConstants.find(a => a.id == self.index);
let simulationAgent = t.crowd[this.hospital.idIdxTracker[self.index]];
let myLocation = new Vector3(simulationAgent.location.x, simulationAgent.location.y, simulationAgent.location.z);

/*
List<IPerson> people = hospital.activePeople;
IMedicalStaff closestTriageNurse = (IMedicalStaff) people.stream()
.filter(i->i instanceof IMedicalStaff
&& ((IMedicalStaff)i).getMedicalStaffType() == MedicalStaffClass.NURSE
&& ((IMedicalStaff)i).getDoctorType() == MedicalStaffSubclass.TRIAGE_NURSE
&&((IMedicalStaff)i).getCurrentPatient() == null)
.sorted((a,b)->(int)(a.getLocation().distanceTo(myLocation) - b.getLocation().distanceTo(myLocation)))
.findFirst()
.orElse(null);
if(closestTriageNurse == null || closestTriageNurse.getLocation().distanceTo(myLocation) > 3)
return Status.RUNNING; //No triage nurse is available or close enough
*/
let closestTriageNurses = this.hospital.agentConstants.filter(a => a.medicalStaffType == "Nurse" && a.medicalStaffSubclass == "Triage Nurse" && a.getCurrentPatient() == null);
let closestTriageNursesSorted = closestTriageNurses.sort((a, b) => {
let aLoc = new Vector3(a.location.x, a.location.y, a.location.z)
let bLoc = new Vector3(b.location.x, b.location.y, b.location.z)
return aLoc.distanceTo(myLocation) - bLoc.distanceTo(myLocation)
});
let closestTriageNurse = closestTriageNursesSorted[0];
if (!closestTriageNurse) return fluentBehaviorTree.BehaviorTreeStatus.Running;

let myPatient = me().getCurrentPatient();

// temporary fix if there is a single greeter nurse
if (closestTriageNurse.getBusy()) {
return fluentBehaviorTree.BehaviorTreeStatus.Failure;
}
else {
closestTriageNurse.setCurrentPatient(myPatient);
myPatient.setInstructor(closestTriageNurse);
myPatient.setPatientTempState(PatientTempState.FOLLOWING);
me().setCurrentPatient(null);
//hospital.addComment(me, myPatient, "Follow that nurse.");

return fluentBehaviorTree.BehaviorTreeStatus.Success;
}
})
.end()
.build();
}


}

export default AssignPatientToTriageNurse;
75 changes: 75 additions & 0 deletions behavior/back-and-forth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import Vector3 from "@crowdedjs/math";
//import * as fluentBehaviorTree from "../lib/fluent-behavior-tree-browser.js"
import fluentBehaviorTree from "@crowdedjs/fluent-behavior-tree"

class BackAndForth {

constructor(myIndex, start, end, hospital) {
this.index = myIndex;
this.hospital = hospital;
this.waypoints = [];
this.waypoints.push(start);
this.waypoints.push(end);

const builder = new fluentBehaviorTree.BehaviorTreeBuilder();
let self = this;//Since we need to reference this in anonymous functions, we need a reference

this.tree = builder
.sequence("Back and Forth")
//Set the destination. This is a one-shot behavior since we only want to
//update the return value once
.do("Set destination to end", (t) => {
let agent = this.hospital.agentConstants.find(a => a.id == self.index);
agent.destination = new Vector3(self.waypoints[1]);
return fluentBehaviorTree.BehaviorTreeStatus.Success;
})
//Now return null as we head to that destination
//We return running until we're close to it.
.do("Traveling to end", (t) => {
let a = this.hospital.agentConstants.find(a => a.id == self.index);
a.destination = new Vector3(self.waypoints[1]);
let agent = t.positions.find(a => a.id == self.index);
let loc = new Vector3(agent.x, agent.y, agent.z);
let waypoint = new Vector3(self.waypoints[1]);

let difference = Vector3.subtract(loc, waypoint)
let distanceToWaypoint = difference.length();

if (distanceToWaypoint < 2)
return fluentBehaviorTree.BehaviorTreeStatus.Success;
return fluentBehaviorTree.BehaviorTreeStatus.Running;
})
//Set the destination. This is a one-shot behavior since we only want to
//update the return value once
.do("Set destination to start", (t) => {
let agent = this.hospital.agentConstants.find(a => a.id == self.index);
agent.destination = new Vector3(self.waypoints[0]);
return fluentBehaviorTree.BehaviorTreeStatus.Success;
})
//Now return null as we head to that destination
//We return running until we're close to it.
.do("Travel to End", (t) => {
let a = this.hospital.agentConstants.find(a => a.id == self.index);
a.destination = new Vector3(self.waypoints[0]);
let agent = t.positions.find(a => a.id == self.index);
let loc = new Vector3(agent.x, agent.y, agent.z);
let waypoint = new Vector3(self.waypoints[0]);

let difference = Vector3.subtract(loc, waypoint)
let distanceToWaypoint = difference.length();

if (distanceToWaypoint < 2)
return fluentBehaviorTree.BehaviorTreeStatus.Success;
return fluentBehaviorTree.BehaviorTreeStatus.Running;
})
.end()
.build();
}

async update( positions, msec) {
await this.tree.tick({ positions, msec }) //Call the behavior tree
}

}

export default BackAndForth;
75 changes: 75 additions & 0 deletions behavior/computer-assign-patient-room.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import LocationStatus from "../support/location-status.js";
import RoomType from "../support/room-type.js"
import fluentBehaviorTree from "@crowdedjs/fluent-behavior-tree"

class ComputerAssignPatientRoom {

constructor(myIndex, hospital) {
this.index = myIndex;
this.hospital = hospital;


const builder = new fluentBehaviorTree.BehaviorTreeBuilder();

let self = this;
let me = () => this.hospital.agentConstants.find(a => a.id == myIndex);

this.tree = builder
.sequence("Computer Assign Patient Room")
.do("Assign Room", (t) => {
let patient = me().getCurrentPatient();
let entry = this.hospital.computer.getEntry(patient);


// get rooms C_ROOM
// if you get back LocationStatus.NONE then return Running
/*List<IRoom> cRooms = this.hospitalModel.get().getLocations(RoomType.C_ROOM);
if(!cRooms.stream().anyMatch(i->i.getLocationStatus() == LocationStatus.NONE))
return Status.RUNNING;//They are all occupied, so we have to wait.
IRoom chosenRoom = cRooms.stream().filter(i->i.getLocationStatus()==LocationStatus.NONE).findFirst().get();
*/
let rooms;

if (patient.getSeverity() == "ESI1") {
// what rooms do we send ESI1 PATIENTS?
rooms = this.hospital.locations.filter(l => l.roomType == RoomType.TRAUMA_BAY && l.locationStatus == LocationStatus.NONE);
}
// BOOK INTO MAIN HOSPITAL - NEEDS EDITS TO PARAMETERS
else if (patient.getSeverity() == "ESI2") {
rooms = this.hospital.locations.find(l => l.name == "Main Entrance");
//entry.getPatient().setPatientTempState(PatientTempState.BOOKED);
}
else
rooms = this.hospital.locations.filter(l => l.roomType == RoomType.C_ROOM && l.locationStatus == LocationStatus.NONE);

if (rooms.length == 0) {
// patient.setAssignedRoom(waitingRoom);
// patient.setPermanentRoom(waitingRoom);
// entry.setBed(waitingRoom);
return fluentBehaviorTree.BehaviorTreeStatus.Running;
}

// need to set room as claimed
if (rooms.name != "Main Entrance") {
rooms[0].setLocationStatus(LocationStatus.CLAIMED);
patient.setAssignedRoom(rooms[0]);
patient.setPermanentRoom(rooms[0]);
entry.setBed(rooms[0]);
}
else {
patient.setAssignedRoom(rooms);
patient.setPermanentRoom(rooms);
entry.setBed(rooms);
}

return fluentBehaviorTree.BehaviorTreeStatus.Success;

})
.end()
.build();
}


}

export default ComputerAssignPatientRoom;
Loading