Giter VIP home page Giter VIP logo

examples's Introduction

CrowdedJS Examples

A threaded, browser-based crowd simulation engine.

Contents

The repo provides a concrete implementation of the various libraries in the CrowdedJS repo.

The main files in this project are index.html and index.js

The open source support files are found in /lib and and governed by their respective licenses.

The support files include:

  • bundle.js, RecastDetour bundled as a web worker. See https://github.com/crowdedjs/worker

  • color-function.js, a function that maps agent names to colors

  • dynamic.js, a list of simulations to choose from when using index.multiple.html

  • replacer.js, a helper function to remove circular references. Use this as the second argument to a JSON.stringify call.

  • simulations.js, available simulations.

  • urlParser.js, a helper function that lets the user set the simulation parameters in the URL.

  • viewer.js, a series of functions that show the current state of the simulation using three.js

Use

Include the support libraries

<script src="./lib/axios.js"></script>  
<script src="./lib/bundle.js"></script> 
<script src="./bundle.js"></script>     

Include the fps counter (optional)

javascript: (function () { var script = document.createElement('script'); script.onload = function () { var stats = new Stats(); document.body.appendChild(stats.dom); requestAnimationFrame(function loop() { stats.update(); requestAnimationFrame(loop) }); }; script.src = '//mrdoob.github.io/stats.js/build/stats.min.js'; document.head.appendChild(script); })()

Run a development server

This project uses vite as its bundler. To run the dev server, use the start command, npm start.

Linking Peer Dependencies

There will be times when you want to edit multiple repos simultanesouly. To do this, clone all the required repos. Then use npm link to create the desired links. With links, any changes you make to the link repo locally will be reflected in your app.

Selinium Debugger

To run the selenium test, you need download the appropriate driver for your OS. You can find the Chrome driver here: https://sites.google.com/a/chromium.org/chromedriver/

examples's People

Contributors

bricksphd avatar rnarducci avatar sarathkshatri avatar waramsey avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

examples's Issues

Connect animation state with behavior tree

I've started to add animation state information into the behavior tree. Right now when a patient waits forever they switch to an idle animation. These animation updates needs to be integrated into all behaviors.

Add shift changes to the staff

6 am and 6 pm are shift changes (tentatively), 12 hour shifts. The greeter nurse only works from 9 to 5. There are one of three arrival times. Morning, Afternoon (swing), and Evening.

Convert to distanceToSquared and lengthSquared

See crowdedjs/math#1

In almost all places where we use distanceTo and length, we could use distanceToSquared and lengthSquared. Times include when we compared based on distance (x^2>y^2=>x>y) such as this updated line:

https://github.com/bricksphd/trash.recast-detour/blob/e9100c3f542e19f75c0314b82866d688d1d43157/src/behavior/look-for-arriving-patient.js#L28

Or when we compare to a constant such as this updated line:

https://github.com/bricksphd/trash.recast-detour/blob/e9100c3f542e19f75c0314b82866d688d1d43157/src/behavior/look-for-arriving-patient.js#L30

The only time we really need to use length instead of lengthSquared is when we normalize, so we need to keep it in for that.

Remove/Optimize Choke Points in Medical Agents' Behaviors

Wanted to note here while I'm thinking of it, this is seemingly the case for Sev A patients and normal patients, as there are several spots where having multiple medical agents doesn't help for one reason or another. Some of those reasons include:

  • When there are Sev A patients that need to be seen in the CT rooms, the tech that is NOT on the A team stops working (assuming all vitals have been taken already) and lets the A team tech take and retrieve the Sev A patients from the cat scan before they start helping again.
  • There is a choke point for the Resident agents too. Resident agents rely on Techs to do their tasks before they do theirs, so when the techs are constantly moving across the whole hospital floor to take patients to the CT Rooms, it often means only one Resident is active at a time, as there is not enough for them to do until the techs accomplish their tasks. For instance, the tech must take vitals and ekg before the resident can consult with the patient.
  • I believe that some of the patients/acknowledgements get piled onto one of the two medical agents of each type disproportionately sometimes, which means often throughout the simulation one of the two agents will be doing nothing when clearly they could technically be doing something, if only it were assigned to them.

Add additional patient proceedures

Patients often require:
A CAT scan
An EKG
An x-ray
A blood draw.
I believe we have the first two implemented, but not the latter two.

Agent location tracking

I think that we're tracking location in two places (my fault). I think we have the locations array and a location (which is the last frame). I think the location variable is redundant since the information is already in the locations array.

Update frame controller

Right now the frame controller has play (reverse), pause, play (forward), and three different speeds (x1, x5, x10).
I think the frame controller should also have a back one frame, forward one frame, go to beginning, go to end, and track last frame options.

Animation blending

We lost animation blending in the most recent version. We need to put that back in.

Fixe throw new [string] error

I wrote the code to throw exceptions incorrectly. The exceptions should read:
throw new Exception(string)
not
throw new [string]

Create patients using the patient object

Right now all people (including patients) are created in the Medician object. Patients should be created in the patient object. This will allow us to leverage OOP better.

Book patients in hospital

We need to have patients leave two ways--the way they came and by being booked into the main hospital.

Ticks v Milliseconds

In the assets repo, agents have their arrival encoded as a tick, e.g.
https://github.com/crowdedjs/assets/blob/c0841be5261f3762533a3a8c143a398b7f963619/arrivals/arrivalHospital.js#L4

Agents are spawned in crowd-setup based on their .startMSec attribute,
https://github.com/crowdedjs/crowd-setup/blob/12257fe45d6ad6abd108d7acfdcebd7c8d27184a/index.js#L75

The conversion from ticks to milliseconds take place in the agent constructors, e.g.

this.startMSec = agent.arrivalTick * 25; // We simulate 25 fps

Assign an A Team

When a sev 1 arrives and is sent to an A bed, there is usually already a team assigned that will drop what they are doing to assist. This usually includes a doctor, a resident, a nurse, and a tech. Often phlebotomy will send someone and someone from imaging will also be on hand.

Add more medical staff

A real ER is teaming with doctors, residents, nurses, and techs. Right now we have only one of each.

Match animation to speed

In alex-branch agents' animations were throttled by the distance the agent travelled. We lost that functionality when I merged.

Fix/Remove/Change Scoring Functions

After some changes a long while ago, our scoring functions stopped working and outputs multiple errors into the console when the simulation starts. It looks like it's not something I can just comment out on my end as it is apart of the node_modules folders.

examples/node_modules/@crowdedjs/crowd-setup/index.js

(The errors was at line 188, "can't access property "id", agentPositionsRef[j] is undefined")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.