├── .circleci └── config.yml ├── .eslintrc.js ├── .gitignore ├── Attic ├── .nojekyll └── index.html ├── CNAME ├── LICENSE ├── README.md ├── bin ├── README.md ├── bbox2osm ├── demultiline ├── flatten ├── json2roads ├── minifyjson ├── models2html ├── modelsinbrowser ├── openfiles ├── rel2fixed ├── runnode ├── runnodemodels └── src2md ├── config ├── cleantheme │ ├── jsdoc.json │ ├── static │ │ ├── AnimatorConsole.jpg │ │ ├── ChromeHelpDev.jpg │ │ ├── CircleTurtles.jpg │ │ ├── CodePenHTML.jpg │ │ ├── CodePenInit.jpg │ │ ├── CodePenJS.jpg │ │ ├── CodePenLayout.jpg │ │ ├── CodePenRunBtn.jpg │ │ ├── CodePenURL.jpg │ │ ├── DevConsole.jpg │ │ ├── DevConsole2.jpg │ │ ├── DevConsole3.jpg │ │ ├── DevConsole4.jpg │ │ ├── DevConsoleCode.jpg │ │ ├── DownloadModel.jpg │ │ ├── Eloquent.jpg │ │ ├── FileURL.jpg │ │ ├── FileUrlFails.jpg │ │ ├── GithubSource.jpg │ │ ├── GuiDropdown.jpg │ │ ├── GuiFolder.jpg │ │ ├── JS14Min1.jpg │ │ ├── JS14Min2.jpg │ │ ├── JS14Min3.jpg │ │ ├── LinkTravel.jpg │ │ ├── MDN1.jpg │ │ ├── MDN2.jpg │ │ ├── MVC.jpg │ │ ├── MVC0.jpg │ │ ├── ModelViewFinal.jpg │ │ ├── ModelViewFinal0.jpg │ │ ├── ModelViewOriginal.jpg │ │ ├── ModelsDir.jpg │ │ ├── ModelsFolder.jpg │ │ ├── Modern1.jpg │ │ ├── Modern2.jpg │ │ ├── NoLinks.jpg │ │ ├── Pheromone.jpg │ │ ├── PheromoneDownload.jpg │ │ ├── PheromoneFileUrl.jpg │ │ ├── PheromoneHtml.jpg │ │ ├── PheromoneView.jpg │ │ ├── PheromoneYellow.jpg │ │ ├── RandomSample.jpg │ │ ├── RestartAnim.jpg │ │ ├── ShowStats.jpg │ │ ├── Snippets.jpg │ │ ├── SystemFolder.jpg │ │ ├── TurtlesColorPatches.jpg │ │ ├── TurtlesPlus1.jpg │ │ ├── TurtlesRandomZ.jpg │ │ ├── TurtlesRedPatches.jpg │ │ ├── TurtlesSize4.jpg │ │ ├── TwoDraw0.jpg │ │ ├── ViewFragment.jpg │ │ ├── ViewSource.jpg │ │ ├── ViewSource1.jpg │ │ ├── Views2.jpg │ │ ├── Views25Html.jpg │ │ ├── VscodeAndFolder.jpg │ │ ├── VscodeAndFolderxx.jpg │ │ ├── VscodeDev.jpg │ │ ├── VscodeDev1xx.jpg │ │ ├── WideViewLeftPanes.jpg │ │ └── xxJS14Min1.jpg │ └── tutorials │ │ ├── 1 - AgentScript.md │ │ ├── 2 - JavaScript.md │ │ ├── 3 - Browser.md │ │ ├── 4 - Model.md │ │ ├── 5 - View.md │ │ ├── 6.1 - AnimatorController.md │ │ ├── 6.2 - KeyboardController.md │ │ ├── 6.3 - GuiController.md │ │ ├── 6.4 - MouseController.md │ │ └── 7 - CodePenServer.md ├── rollup.dist.mjs ├── rollup.vendor.mjs ├── three.all.js └── turfImports.js ├── docs ├── AgentArray.html ├── AgentArray.js.html ├── AgentList.html ├── AgentList.js.html ├── AgentSet.html ├── AgentSet.js.html ├── Animator.html ├── Animator.js.html ├── Color.html ├── Color.js.html ├── ColorMap.html ├── ColorMap.js.html ├── DataSet.html ├── DataSet.js.html ├── GUI.html ├── GUI.js.html ├── GeoDataSet.html ├── GeoDataSet.js.html ├── Keyboard.html ├── Keyboard.js.html ├── Link.html ├── Link.js.html ├── Links.html ├── Links.js.html ├── Model.html ├── Model.js.html ├── Model3D.html ├── Model3D.js.html ├── Mouse.html ├── Mouse.js.html ├── Patch.html ├── Patch.js.html ├── Patches.html ├── Patches.js.html ├── RGBDataSet.html ├── RGBDataSet.js.html ├── ThreeDraw.html ├── ThreeDraw.js.html ├── Turtle.html ├── Turtle.js.html ├── Turtle3D.html ├── Turtle3D.js.html ├── Turtles.html ├── Turtles.js.html ├── TwoDraw.html ├── TwoDraw.js.html ├── World.html ├── World.js.html ├── config │ └── cleantheme │ │ └── static │ │ ├── AnimatorConsole.jpg │ │ ├── ChromeHelpDev.jpg │ │ ├── CircleTurtles.jpg │ │ ├── CodePenHTML.jpg │ │ ├── CodePenInit.jpg │ │ ├── CodePenJS.jpg │ │ ├── CodePenLayout.jpg │ │ ├── CodePenRunBtn.jpg │ │ ├── CodePenURL.jpg │ │ ├── DevConsole.jpg │ │ ├── DevConsole2.jpg │ │ ├── DevConsole3.jpg │ │ ├── DevConsole4.jpg │ │ ├── DevConsoleCode.jpg │ │ ├── DownloadModel.jpg │ │ ├── Eloquent.jpg │ │ ├── FileURL.jpg │ │ ├── FileUrlFails.jpg │ │ ├── GithubSource.jpg │ │ ├── GuiDropdown.jpg │ │ ├── GuiFolder.jpg │ │ ├── JS14Min1.jpg │ │ ├── JS14Min2.jpg │ │ ├── JS14Min3.jpg │ │ ├── LinkTravel.jpg │ │ ├── MDN1.jpg │ │ ├── MDN2.jpg │ │ ├── MVC.jpg │ │ ├── MVC0.jpg │ │ ├── ModelViewFinal.jpg │ │ ├── ModelViewFinal0.jpg │ │ ├── ModelViewOriginal.jpg │ │ ├── ModelsDir.jpg │ │ ├── ModelsFolder.jpg │ │ ├── Modern1.jpg │ │ ├── Modern2.jpg │ │ ├── NoLinks.jpg │ │ ├── Pheromone.jpg │ │ ├── PheromoneDownload.jpg │ │ ├── PheromoneFileUrl.jpg │ │ ├── PheromoneHtml.jpg │ │ ├── PheromoneView.jpg │ │ ├── PheromoneYellow.jpg │ │ ├── RandomSample.jpg │ │ ├── RestartAnim.jpg │ │ ├── ShowStats.jpg │ │ ├── Snippets.jpg │ │ ├── SystemFolder.jpg │ │ ├── TurtlesColorPatches.jpg │ │ ├── TurtlesPlus1.jpg │ │ ├── TurtlesRandomZ.jpg │ │ ├── TurtlesRedPatches.jpg │ │ ├── TurtlesSize4.jpg │ │ ├── TwoDraw0.jpg │ │ ├── ViewFragment.jpg │ │ ├── ViewSource.jpg │ │ ├── ViewSource1.jpg │ │ ├── Views2.jpg │ │ ├── Views25Html.jpg │ │ ├── VscodeAndFolder.jpg │ │ ├── VscodeAndFolderxx.jpg │ │ ├── VscodeDev.jpg │ │ ├── VscodeDev1xx.jpg │ │ ├── WideViewLeftPanes.jpg │ │ └── xxJS14Min1.jpg ├── data │ └── search.json ├── fonts │ ├── Inconsolata-Regular.ttf │ ├── OpenSans-Regular.ttf │ └── WorkSans-Bold.ttf ├── geojson.js.html ├── gis.js.html ├── index.html ├── module-src_geojson.html ├── module-src_gis.html ├── module-src_utils.html ├── scripts │ ├── core.js │ ├── core.min.js │ ├── resize.js │ ├── search.js │ ├── search.min.js │ └── third-party │ │ ├── Apache-License-2.0.txt │ │ ├── fuse.js │ │ ├── hljs-line-num-original.js │ │ ├── hljs-line-num.js │ │ ├── hljs-original.js │ │ ├── hljs.js │ │ ├── popper.js │ │ ├── tippy.js │ │ ├── tocbot.js │ │ └── tocbot.min.js ├── styles │ ├── clean-jsdoc-theme-base.css │ ├── clean-jsdoc-theme-dark.css │ ├── clean-jsdoc-theme-light.css │ ├── clean-jsdoc-theme-scrollbar.css │ ├── clean-jsdoc-theme-without-scrollbar.min.css │ └── clean-jsdoc-theme.min.css ├── tutorial-1 - AgentScript.html ├── tutorial-2 - JavaScript.html ├── tutorial-3 - Browser.html ├── tutorial-4 - Model.html ├── tutorial-5 - View.html ├── tutorial-6.1 - AnimatorController.html ├── tutorial-6.2 - KeyboardController.html ├── tutorial-6.3 - GuiController.html ├── tutorial-6.4 - MouseController.html ├── tutorial-7 - CodePenServer.html └── utils.js.html ├── favicon.ico ├── fb ├── Config.js ├── DefineTransform.js ├── Transforms.js ├── convergence.html ├── density.html ├── flock.html ├── flockxfm.html ├── hello.html └── xymeans.html ├── ide ├── Ants.js ├── Darts.js ├── Snippets.html ├── examples.html ├── index.html ├── style.css └── thumbs │ ├── ants.png │ ├── antselements.jpg │ ├── diffuse.png │ ├── fire.png │ ├── flock.png │ ├── kelpforest.png │ ├── kelpforestmvc.jpg │ ├── slimemold.png │ ├── template.png │ ├── tsp-mvc.jpg │ ├── tsp.png │ ├── tspelements.jpg │ └── virus.png ├── leaflet ├── README.md ├── countywalker.html ├── countywalker0.html ├── droplets.html ├── hellogeo.html ├── leaflet.html ├── leafletInit.js ├── leafletUtils.js ├── map.css ├── overlay.html ├── showtiles.html ├── tiledroplets.html └── virus.html ├── maplibre ├── README.md ├── countiesmap.html ├── countywalker.html ├── countywalker0.html ├── dropletsdrag.html ├── dropletsscreen.html ├── dropletsstatic.html ├── hello.html ├── hello0.html ├── mltools.js ├── rectdrag.html ├── rectscreen.html ├── rectstatic.html ├── streets.html ├── streetsdata.html └── vectormap.html ├── models ├── AntsModel.js ├── AvalancheModel.js ├── ButtonsModel.js ├── Camera3DModel.js ├── CountiesModel.js ├── DiffuseModel.js ├── DropletsModel.js ├── ExitModel.js ├── FireModel.js ├── FlockModel.js ├── GridPathModel.js ├── Hello3DModel.js ├── Hello3ZModel.js ├── HelloModel.js ├── HelloPlusModel.js ├── KelpForestModel.js ├── LifeModel.js ├── LinkTravelModel.js ├── MinModel.js ├── OrbitModel.js ├── PheromoneModel.js ├── README.md ├── RoadsModel.js ├── ShapesModel.js ├── SlimeMoldModel.js ├── TemplateModel.js ├── TspModel.js ├── VirusModel.js ├── WallFollowerModel.js ├── Wander3DModel.js ├── WaterModel.js ├── data │ ├── nmcounties.json │ ├── redfish.png │ ├── roads14.png │ ├── santafe14roads.json │ ├── santaferoads.json │ ├── statecodes.js │ ├── tile101x101.js │ └── twitter.png ├── run.html ├── runWorker.js ├── test.html └── worker.html ├── mvc ├── README.md ├── ants.html ├── camera.html ├── flock.html ├── gui.html ├── helloButtons.html ├── helloElements.html ├── helloElements.js ├── helloGui.html ├── helloKeys.html ├── helloMouse.html ├── kelpforest.html ├── minElements.js ├── mouse.html ├── navigate3d.html └── tsp.html ├── package.json ├── src ├── AS.js ├── AS2D.js ├── AgentArray.js ├── AgentList.js ├── AgentSet.js ├── AgentscriptAll.js ├── Animator.js ├── BBoxDataSet.js ├── Buttons.js ├── Color.js ├── ColorMap.js ├── DataSet.js ├── Evented.js ├── FileAccess.js ├── GUI.js ├── GeoDataSet.js ├── GeoWorld.js ├── Keyboard.js ├── Link.js ├── Links.js ├── MapDraw.js ├── Model.js ├── Model3D.js ├── Mouse.js ├── Patch.js ├── Patches.js ├── PatchesView.js ├── Plot.js ├── RGBADataSet.js ├── RGBDataSet.js ├── Shapes.js ├── SpriteSheet.js ├── ThreeDraw.js ├── ThreeMeshes.js ├── ThreeView.js ├── TileData.js ├── Turtle.js ├── Turtle3D.js ├── Turtles.js ├── TurtlesView.js ├── TwoDraw.js ├── TwoView.js ├── World.js ├── emoji.js ├── geofilters.js ├── geojson.js ├── gis.js ├── steg.js └── utils.js ├── uielements ├── README.md ├── ants.html ├── antsElements.js ├── min.html ├── minElements.js ├── notes.txt ├── orbit.html ├── orbitElements.js ├── tsp.html ├── tspElements.js ├── uielements.css ├── uielements.html ├── uielements.html.js └── uielements.js ├── vendor ├── Object3D.js ├── Object3D.min.js ├── dat.gui.js ├── dat.gui.min.js ├── elementOverlay.js ├── stats.js ├── three.js ├── three.min.js ├── turfImports.js ├── turfImports.min.js ├── uPlot.css ├── uPlot.js └── uPlot.min.js ├── views1 ├── README.md ├── ants.html ├── avalanche.html ├── buttons.html ├── camera3d.html ├── counties.html ├── diffuse.html ├── droplets.html ├── exit.html ├── fire.html ├── flock.html ├── gridpath.html ├── hello.html ├── hello3d.html ├── hello3z.html ├── helloplus.html ├── kelpforest.html ├── life.html ├── linktravel.html ├── min.html ├── orbit.html ├── pheromone.html ├── roads.html ├── shapes.html ├── slimemold.html ├── template.html ├── tsp.html ├── virus.html ├── wallfollower.html ├── wander3d.html └── water.html ├── views2 ├── README.md ├── ants.html ├── avalanche.html ├── buttons.html ├── diffuse.html ├── droplets.html ├── exit.html ├── fire.html ├── flock.html ├── gridpath.html ├── hello.html ├── hellotext.html ├── kelpforest.html ├── life.html ├── linktravel.html ├── min.html ├── orbit.html ├── pheromone.html ├── roads.html ├── shapes.html ├── slimemold.html ├── template.html ├── tsp.html ├── virus.html ├── wallfollower.html └── water.html ├── views25 ├── README.md ├── ants.html ├── buttons.html ├── diffuse.html ├── droplets.html ├── exit.html ├── fire.html ├── flock.html ├── gridpath.html ├── hello.html ├── hello3d.html ├── hello3z.html ├── helloPatches.html ├── helloplus.html ├── life.html ├── linktravel.html ├── roads.html ├── shapes.html ├── tsp.html ├── virus.html ├── wallfollower.html └── water.html ├── views2full ├── README.md ├── antsfull.html ├── diffusefull.html ├── exitfull.html ├── firefull.html ├── hellofull.html ├── shapesfull.html ├── tspfull.html └── waterfull.html ├── views2mv ├── README.md ├── ants.html ├── antsOptions.js ├── avalanche.html ├── avalancheOptions.js ├── buttons.html ├── buttonsOptions.js ├── diffuse.html ├── diffuseOptions.js ├── droplets.html ├── dropletsOptions.js ├── exit.html ├── exitOptions.js ├── fire.html ├── fireOptions.js ├── flock.html ├── flockOptions.js ├── gridpath.html ├── gridpathOptions.js ├── hello.html ├── helloOptions.js ├── hellotext.html ├── hellotextOptions.js ├── life.html ├── lifeOptions.js ├── linktravel.html ├── linktravelOptions.js ├── pheromone.html ├── pheromoneOptions.js ├── roads.html ├── roads.js ├── roadsOptions.js ├── shapes.html ├── shapesOptions.js ├── slimemold.html ├── slimemold.js ├── slimemoldOptions.js ├── template.html ├── templateOptions.js ├── tsp.html ├── tspOptions.js ├── virus.html ├── virusOptions.js ├── wallfollower.html ├── wallfollower.js ├── wallfollowerOptions.js ├── water.html └── waterOptions.js ├── views3 ├── Attic │ ├── height.html │ └── threeUtils.js ├── README.md ├── avalanche.html ├── camera.html ├── cameraplot.html ├── exit.html ├── hello.html ├── hello3d.html ├── shapes.html ├── terrain.html ├── terrain1.html ├── terrain2.html └── wander.html └── webdav ├── cpanel-server.js ├── curl.sh ├── deno-server.js ├── glitch-server.js └── webdav-client.html /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | orbs: 3 | browser-tools: circleci/browser-tools@1.4.6 4 | 5 | jobs: 6 | build: 7 | docker: 8 | - image: cimg/node:current-browsers 9 | 10 | working_directory: ~/repo 11 | 12 | steps: 13 | - checkout 14 | 15 | - restore_cache: 16 | keys: 17 | - v1-dependencies-{{ checksum "package.json" }} 18 | 19 | - run: yarn install 20 | 21 | - run: yarn build 22 | 23 | # Install Deno 24 | # - run: curl -fsSL https://deno.land/x/install/install.sh | sudo DENO_INSTALL=/usr/local sh 25 | 26 | # Cache dependencies and update the lock file 27 | # - run: 28 | # name: Cache dependencies 29 | # command: deno cache --lock=lock.json --lock-write test/denomodels.js test/deno3Dgeom.js 30 | 31 | - run: 32 | command: mkdir -p ~/reports 33 | 34 | # - run: yarn test 35 | 36 | - store_test_results: 37 | path: ~/reports 38 | 39 | - store_artifacts: 40 | path: ~/reports 41 | 42 | - save_cache: 43 | paths: 44 | - node_modules 45 | key: v1-dependencies-{{ checksum "package.json" }} 46 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // .eslintrc.js 2 | // Also see .prettierrc.js 3 | module.exports = { 4 | env: { 5 | browser: true, 6 | es6: true, 7 | node: true, 8 | }, 9 | extends: 'eslint:recommended', 10 | parserOptions: { 11 | ecmaVersion: 2017, 12 | sourceType: 'module', 13 | }, 14 | rules: { 15 | curly: ['error', 'multi-line', 'consistent'], 16 | 'prefer-const': ['error'], 17 | 'no-console': ['error', { allow: ['log', 'warn', 'error'] }], 18 | 19 | // Prettier prefers no space after function 20 | // 'space-before-function-paren': 'error', 21 | // 'space-before-function-paren': ['error', 'never'], 22 | 23 | // Here to match our Prettier options 24 | semi: ['error', 'never'], 25 | quotes: ['error', 'single'], 26 | indent: ['error', 4], 27 | 'comma-dangle': ['error', 'always-multiline'], 28 | 'arrow-parens': ['error', 'as-needed'], 29 | }, 30 | } 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files to not include in git. See 2 | # https://git-scm.com/docs/gitignore 3 | # https://gist.github.com/octocat/9257657 4 | 5 | # Derived files other than docs/ 6 | /dist/ 7 | 8 | node_modules 9 | web_modules 10 | npm-debug.log 11 | yarn-error.log 12 | package-lock.json 13 | **/.DS_Store 14 | .vscode 15 | 16 | 17 | /Attic/ 18 | **/Attic 19 | # /test/samples.json 20 | /test/ 21 | /tests/ 22 | /simple/ 23 | /controls/ 24 | /vscode/ 25 | vscode.zip 26 | /views2x/ 27 | /uielements0/ 28 | 29 | deno.lock 30 | lock.json 31 | yarn.lock 32 | 33 | maplibre0 34 | # package-lock.json 35 | # yarn.lock 36 | 37 | # .github/workflows/pages.yml 38 | -------------------------------------------------------------------------------- /Attic/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/Attic/.nojekyll -------------------------------------------------------------------------------- /Attic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Redirecting to IDE 9 | 10 | 11 | 12 |

Redirecting to IDE...

13 | 14 | 15 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | code.agentscript.org 2 | -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | ## bin/ 2 | 3 | This dir contains misc node based utilities used for transforming 4 | gis data, experiments, workflow, gis transforms (OSM to geojson etc). 5 | 6 | They are not used by Agentscript models, and we may remove several of these as obsolete. 7 | -------------------------------------------------------------------------------- /bin/bbox2osm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // const gis = require('./gis.umd.js') 4 | const esmImport = require('esm')(module) 5 | const gis = esmImport('../src/gis.js') 6 | 7 | const https = require('https') 8 | 9 | const bbox = process.argv[2] 10 | // console.log(bbox) 11 | 12 | // const [, south, west, north, east] = bbox.match( 13 | // /([^,]+),([^,]+),([^,]+),([^,]+)/ 14 | // ) 15 | // Our bbox is west, south, east, north 16 | const [, west, south, east, north] = bbox.match(/(.+),(.+),(.+),(.+)/) 17 | 18 | // // convert to numbers! 19 | // const [west, south, east, north] = gis.xyz2bbox(+x, +y, +z) 20 | 21 | // Use + to convert to numbers! Osm uses less standard directions 22 | const url = gis.getOsmURL(+south, +west, +north, +east) 23 | // console.log(url) 24 | 25 | https.get(url, res => { 26 | res.setEncoding('utf8') 27 | res.on('data', data => { 28 | process.stdout.write(data) 29 | }) 30 | res.on('end', () => {}) 31 | }) 32 | -------------------------------------------------------------------------------- /bin/demultiline: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const process = require('process') 4 | const esmImport = require('esm')(module) 5 | const gis = esmImport('../src/gis.js') 6 | 7 | let data = '' 8 | process.stdin.on('readable', () => { 9 | while ((chunk = process.stdin.read()) !== null) { 10 | data += chunk 11 | } 12 | }) 13 | 14 | process.stdin.on('end', () => { 15 | process.stdout.write(processData(data)) 16 | }) 17 | 18 | function processData(data) { 19 | const json = JSON.parse(data) 20 | gis.flattenMultiLineStrings(json) 21 | return JSON.stringify(json, null, 2) 22 | } 23 | -------------------------------------------------------------------------------- /bin/flatten: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const process = require('process') 4 | const esmImport = require('esm')(module) 5 | const geojson = esmImport('../src/geojson.js') 6 | 7 | let data = '' 8 | process.stdin.on('readable', () => { 9 | while ((chunk = process.stdin.read()) !== null) { 10 | data += chunk 11 | } 12 | }) 13 | 14 | process.stdin.on('end', () => { 15 | process.stdout.write(processData(data)) 16 | }) 17 | 18 | function processData(data) { 19 | const json = JSON.parse(data) 20 | geojson.flatten(json) 21 | return JSON.stringify(json, null, 2) 22 | } 23 | -------------------------------------------------------------------------------- /bin/json2roads: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const process = require('process') 4 | const esmImport = require('esm')(module) 5 | 6 | const geofilters = esmImport('../src/geofilters.js') 7 | 8 | let data = '' 9 | process.stdin.on('readable', () => { 10 | while ((chunk = process.stdin.read()) !== null) { 11 | data += chunk 12 | } 13 | }) 14 | 15 | process.stdin.on('end', () => { 16 | process.stdout.write(processData(data)) 17 | }) 18 | 19 | function processData(data) { 20 | const json = JSON.parse(data) 21 | const streets = geofilters.streetsFilter(json) 22 | return JSON.stringify(streets, null, 2) 23 | } 24 | -------------------------------------------------------------------------------- /bin/minifyjson: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const process = require('process') 4 | 5 | const esmImport = require('esm')(module) 6 | const geojson = esmImport('../src/geojson.js') 7 | 8 | let data = '' 9 | process.stdin.on('readable', () => { 10 | while ((chunk = process.stdin.read()) !== null) { 11 | data += chunk 12 | } 13 | }) 14 | 15 | process.stdin.on('end', () => { 16 | process.stdout.write(processData(data)) 17 | }) 18 | 19 | function processData(data) { 20 | const json = JSON.parse(data) 21 | return geojson.minify(json) 22 | } 23 | -------------------------------------------------------------------------------- /bin/models2html: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Convert all our es6 models to html files running the models 4 | 5 | const shell = require('shelljs') 6 | 7 | const dir = 'views1' 8 | shell.rm('-rf', `${dir}/`) 9 | shell.mkdir(`${dir}`) 10 | 11 | const models = shell.ls('models/[A-Z]*Model.js') 12 | 13 | models.forEach(model => { 14 | // shell.echo(model) 15 | const title = model.replace('models/', '').replace('Model.js', '') 16 | shell.echo(model, title) 17 | 18 | const html = makeHtml(title, model) 19 | 20 | // shell.echo(makeHtml(model)) 21 | const htmlFile = model 22 | .replace('models/', dir + '/') 23 | // .toLowerCase() 24 | .replace('Model.js', '.html') 25 | .toLowerCase() 26 | 27 | shell.echo(htmlFile) 28 | // shell.echo(html) 29 | new shell.ShellString(html).to(htmlFile) 30 | }) 31 | 32 | function makeHtml(title, model) { 33 | return ` 34 | 35 | ${title} 36 | 37 | 38 | 53 | 54 | 55 | ` 56 | } 57 | -------------------------------------------------------------------------------- /bin/modelsinbrowser: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // const esmImport = require('esm')(module, { mode: 'all' }) 4 | const esmImport = require('esm')(module) 5 | 6 | // esmImport solves the live-server CRLF problem, apparently 7 | const liveServer = esmImport('live-server') 8 | const shell = esmImport('shelljs') 9 | const utils = esmImport('../src/utils.js') 10 | 11 | const dir = process.argv[2] 12 | if (!dir) throw Error('Needs dir name argument') 13 | const browser = process.argv[3] || 'Google Chrome' 14 | 15 | console.log('dir:', dir, 'browser', browser) 16 | 17 | liveServer.start({ 18 | open: false, 19 | // logLevel: 0, 20 | // ignore: '*', 21 | port: 9090, 22 | }) 23 | const root = 'http://127.0.0.1:9090' 24 | 25 | // https://developer.chrome.com/docs/devtools/open/ 26 | async function run() { 27 | const models = shell.ls(`${dir}/*.html`) // Just the Model files 28 | 29 | models.forEach(model => shell.echo(model)) 30 | // auto-open-devtools-for-tabs only works on a fresh browser. 31 | shell.exec( 32 | // `open --new -a "${browser}" --args --new-window --auto-open-devtools-for-tabs` 33 | `open --new -a "${browser}" --args --auto-open-devtools-for-tabs` 34 | ) 35 | await utils.pause(4000) 36 | 37 | models.forEach(model => 38 | shell.exec( 39 | // `open -a "${browser}" --auto-open-devtools-for-tabs ${root}/${model}` 40 | `open -a "${browser}" ${root}/${model}` 41 | ) 42 | ) 43 | } 44 | run() 45 | -------------------------------------------------------------------------------- /bin/openfiles: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // const esmImport = require('esm')(module, { mode: 'all' }) 4 | const esmImport = require('esm')(module) 5 | 6 | // esmImport solves the live-server CRLF problem, apparently 7 | // const liveServer = esmImport('live-server') 8 | const shell = esmImport('shelljs') 9 | const utils = esmImport('../src/utils.js') 10 | 11 | const dir = process.argv[2] 12 | if (!dir) throw Error('Needs dir name argument') 13 | const browser = process.argv[3] || 'Google Chrome' 14 | 15 | console.log('dir:', dir, 'browser', browser) 16 | 17 | // liveServer.start({ 18 | // open: false, 19 | // // logLevel: 0, 20 | // // ignore: '*', 21 | // port: 9090, 22 | // }) 23 | // const root = 'http://127.0.0.1:9090' 24 | const root = 'file:///Users/owen/Dropbox/src/agentscript' 25 | 26 | // https://developer.chrome.com/docs/devtools/open/ 27 | async function run() { 28 | const models = shell.ls(`${dir}/*.html`) // Just the Model files 29 | 30 | models.forEach(model => shell.echo(model)) 31 | // auto-open-devtools-for-tabs only works on a fresh browser. 32 | shell.exec( 33 | // `open --new -a "${browser}" --args --new-window --auto-open-devtools-for-tabs` 34 | `open --new -a "${browser}"` 35 | ) 36 | await utils.pause(4000) 37 | 38 | models.forEach(model => 39 | shell.exec( 40 | // `open -a "${browser}" --auto-open-devtools-for-tabs ${root}/${model}` 41 | // `open -a "${browser}" ${root}/${model}` 42 | `open -a "${browser}" ${root}/${model}` 43 | ) 44 | ) 45 | } 46 | run() 47 | -------------------------------------------------------------------------------- /bin/rel2fixed: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const shell = require('shelljs') 4 | // shell.config.silent = true 5 | 6 | let dir = process.argv[2] 7 | if (!dir) throw Error('Needs dir argument') 8 | 9 | shell.cd(dir) 10 | // shell.cd('views2mv') 11 | const files = shell.ls('*html') 12 | 13 | files.forEach(file => { 14 | shell.echo(file) 15 | shell.sed('-i', `'../`, `'https://code.agentscript.org/`, file) 16 | // .to('code' + file) 17 | }) 18 | // const urlRoot = `https://code.agentscript.org/${dir}/` 19 | -------------------------------------------------------------------------------- /bin/runnode: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // const esmImport = require('esm')(module, { mode: 'all' }) 4 | const esmImport = require('esm')(module) 5 | const str = process.argv[2] || 'hello' 6 | const className = str.charAt(0).toUpperCase() + str.slice(1) + 'Model' 7 | 8 | console.log('\nRunning', className) 9 | 10 | const Model = esmImport(`../models/${className}.js`).default 11 | const utils = esmImport('../src/utils.js') 12 | 13 | const model = new Model() 14 | async function run() { 15 | await model.startup() 16 | model.setup() 17 | await utils.timeoutLoop(() => { 18 | model.step() 19 | }, 500) 20 | const sample = utils.sampleModel(model) 21 | console.log(sample) 22 | } 23 | run().catch(e => { 24 | console.log(`\n!Error: ${className} failed to run: ${e}\n`) 25 | }) 26 | -------------------------------------------------------------------------------- /bin/runnodemodels: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const shell = require('shelljs') 4 | 5 | const dir = './models' 6 | 7 | let models 8 | models = shell 9 | .ls(`${dir}/*Model.js`) 10 | // OK if first char is capitolized, index.html will just recap 11 | .sed(/Model/, '') 12 | 13 | models = models 14 | .sed(/^.*\//, '') 15 | .sed(/.js$/, '') 16 | .replace(/\n+$/, '') 17 | .split('\n') 18 | .map(str => str.charAt(0).toLowerCase() + str.slice(1)) 19 | 20 | shell.echo('models:', models) 21 | models.forEach(model => shell.exec(`./bin/runnode ${model}`)) 22 | -------------------------------------------------------------------------------- /config/cleantheme/static/AnimatorConsole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/AnimatorConsole.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ChromeHelpDev.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ChromeHelpDev.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/CircleTurtles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/CircleTurtles.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/CodePenHTML.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/CodePenHTML.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/CodePenInit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/CodePenInit.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/CodePenJS.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/CodePenJS.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/CodePenLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/CodePenLayout.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/CodePenRunBtn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/CodePenRunBtn.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/CodePenURL.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/CodePenURL.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/DevConsole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/DevConsole.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/DevConsole2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/DevConsole2.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/DevConsole3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/DevConsole3.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/DevConsole4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/DevConsole4.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/DevConsoleCode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/DevConsoleCode.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/DownloadModel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/DownloadModel.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/Eloquent.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/Eloquent.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/FileURL.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/FileURL.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/FileUrlFails.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/FileUrlFails.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/GithubSource.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/GithubSource.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/GuiDropdown.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/GuiDropdown.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/GuiFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/GuiFolder.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/JS14Min1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/JS14Min1.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/JS14Min2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/JS14Min2.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/JS14Min3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/JS14Min3.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/LinkTravel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/LinkTravel.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/MDN1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/MDN1.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/MDN2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/MDN2.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/MVC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/MVC.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/MVC0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/MVC0.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ModelViewFinal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ModelViewFinal.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ModelViewFinal0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ModelViewFinal0.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ModelViewOriginal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ModelViewOriginal.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ModelsDir.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ModelsDir.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ModelsFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ModelsFolder.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/Modern1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/Modern1.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/Modern2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/Modern2.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/NoLinks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/NoLinks.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/Pheromone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/Pheromone.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/PheromoneDownload.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/PheromoneDownload.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/PheromoneFileUrl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/PheromoneFileUrl.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/PheromoneHtml.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/PheromoneHtml.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/PheromoneView.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/PheromoneView.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/PheromoneYellow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/PheromoneYellow.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/RandomSample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/RandomSample.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/RestartAnim.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/RestartAnim.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ShowStats.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ShowStats.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/Snippets.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/Snippets.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/SystemFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/SystemFolder.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/TurtlesColorPatches.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/TurtlesColorPatches.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/TurtlesPlus1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/TurtlesPlus1.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/TurtlesRandomZ.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/TurtlesRandomZ.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/TurtlesRedPatches.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/TurtlesRedPatches.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/TurtlesSize4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/TurtlesSize4.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/TwoDraw0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/TwoDraw0.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ViewFragment.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ViewFragment.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ViewSource.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ViewSource.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/ViewSource1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/ViewSource1.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/Views2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/Views2.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/Views25Html.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/Views25Html.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/VscodeAndFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/VscodeAndFolder.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/VscodeAndFolderxx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/VscodeAndFolderxx.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/VscodeDev.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/VscodeDev.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/VscodeDev1xx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/VscodeDev1xx.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/WideViewLeftPanes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/WideViewLeftPanes.jpg -------------------------------------------------------------------------------- /config/cleantheme/static/xxJS14Min1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/config/cleantheme/static/xxJS14Min1.jpg -------------------------------------------------------------------------------- /config/cleantheme/tutorials/6.4 - MouseController.md: -------------------------------------------------------------------------------- 1 | The mouse control has a very simple api: 2 | 3 | ```javascript 4 | const mouse = new Mouse(model, view, callback) 5 | ``` 6 | 7 | where callback is a function that is called each event of the mouse. 8 | The callback should manage three events: `mousedown, mousedrag, mouseup`. 9 | 10 | Here is a common mouse usage: grab the nearest turtle and move it while the 11 | mouse is dragged, and stops when the moused button is let up. 12 | 13 | It works by having a variable, `selectedTurtle` that is calculated each mousedown. 14 | It moves the selectedTurtle during mousedrag. It quits on mouseup. 15 | 16 | ```javascript 17 | let selectedTurtle 18 | const mouse = new Mouse(model, view, mouse => { 19 | const { x, y, action } = mouse 20 | switch (action) { 21 | case 'mousedown': 22 | selectedTurtle = model.turtles.minOneOf(t => t.distanceXY(x, y)) 23 | break 24 | 25 | case 'mousedrag': 26 | if (selectedTurtle) selectedTurtle.setxy(x, y) 27 | 28 | case 'mousemove': 29 | selectedLink = model.links.minOneOf(l => l.distanceXY(x, y)) 30 | break 31 | 32 | case 'mouseup': 33 | selectedTurtle = null 34 | break 35 | } 36 | }).start() 37 | ``` 38 | 39 | [This model](https://code.agentscript.org/mvc/helloMouse.html) shows the Mouse control usage. 40 | -------------------------------------------------------------------------------- /config/three.all.js: -------------------------------------------------------------------------------- 1 | // Rollup entry point of all our THREE dependencies 2 | // Needed due to THREE modules having direct paths 3 | // Otherwise we'd need to include a node_modules sub-tree! 4 | 5 | import * as THREE from '../node_modules/three/build/three.module.js' 6 | import { OrbitControls } from '../node_modules/three/examples/jsm/controls/OrbitControls.js' 7 | 8 | export { THREE, OrbitControls } 9 | -------------------------------------------------------------------------------- /docs/config/cleantheme/static/AnimatorConsole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/AnimatorConsole.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ChromeHelpDev.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ChromeHelpDev.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/CircleTurtles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/CircleTurtles.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/CodePenHTML.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/CodePenHTML.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/CodePenInit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/CodePenInit.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/CodePenJS.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/CodePenJS.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/CodePenLayout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/CodePenLayout.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/CodePenRunBtn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/CodePenRunBtn.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/CodePenURL.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/CodePenURL.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/DevConsole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/DevConsole.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/DevConsole2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/DevConsole2.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/DevConsole3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/DevConsole3.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/DevConsole4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/DevConsole4.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/DevConsoleCode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/DevConsoleCode.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/DownloadModel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/DownloadModel.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/Eloquent.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/Eloquent.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/FileURL.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/FileURL.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/FileUrlFails.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/FileUrlFails.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/GithubSource.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/GithubSource.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/GuiDropdown.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/GuiDropdown.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/GuiFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/GuiFolder.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/JS14Min1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/JS14Min1.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/JS14Min2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/JS14Min2.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/JS14Min3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/JS14Min3.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/LinkTravel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/LinkTravel.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/MDN1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/MDN1.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/MDN2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/MDN2.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/MVC.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/MVC.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/MVC0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/MVC0.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ModelViewFinal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ModelViewFinal.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ModelViewFinal0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ModelViewFinal0.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ModelViewOriginal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ModelViewOriginal.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ModelsDir.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ModelsDir.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ModelsFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ModelsFolder.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/Modern1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/Modern1.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/Modern2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/Modern2.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/NoLinks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/NoLinks.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/Pheromone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/Pheromone.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/PheromoneDownload.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/PheromoneDownload.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/PheromoneFileUrl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/PheromoneFileUrl.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/PheromoneHtml.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/PheromoneHtml.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/PheromoneView.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/PheromoneView.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/PheromoneYellow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/PheromoneYellow.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/RandomSample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/RandomSample.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/RestartAnim.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/RestartAnim.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ShowStats.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ShowStats.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/Snippets.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/Snippets.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/SystemFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/SystemFolder.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/TurtlesColorPatches.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/TurtlesColorPatches.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/TurtlesPlus1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/TurtlesPlus1.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/TurtlesRandomZ.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/TurtlesRandomZ.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/TurtlesRedPatches.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/TurtlesRedPatches.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/TurtlesSize4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/TurtlesSize4.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/TwoDraw0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/TwoDraw0.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ViewFragment.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ViewFragment.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ViewSource.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ViewSource.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/ViewSource1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/ViewSource1.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/Views2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/Views2.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/Views25Html.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/Views25Html.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/VscodeAndFolder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/VscodeAndFolder.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/VscodeAndFolderxx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/VscodeAndFolderxx.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/VscodeDev.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/VscodeDev.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/VscodeDev1xx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/VscodeDev1xx.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/WideViewLeftPanes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/WideViewLeftPanes.jpg -------------------------------------------------------------------------------- /docs/config/cleantheme/static/xxJS14Min1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/config/cleantheme/static/xxJS14Min1.jpg -------------------------------------------------------------------------------- /docs/fonts/Inconsolata-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/fonts/Inconsolata-Regular.ttf -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /docs/fonts/WorkSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/docs/fonts/WorkSans-Bold.ttf -------------------------------------------------------------------------------- /docs/styles/clean-jsdoc-theme-scrollbar.css: -------------------------------------------------------------------------------- 1 | ::-webkit-scrollbar { 2 | height: 0.3125rem; 3 | width: 0.3125rem; 4 | 5 | } 6 | 7 | ::-webkit-scrollbar-thumb, 8 | ::-webkit-scrollbar-track { 9 | border-radius: 1rem; 10 | } 11 | 12 | ::-webkit-scrollbar-track { 13 | background: #333; 14 | } 15 | 16 | ::-webkit-scrollbar-thumb { 17 | background: #555; 18 | outline: 0.06125rem solid #555; 19 | } 20 | 21 | 22 | .light ::-webkit-scrollbar-track { 23 | background: #ddd; 24 | 25 | } 26 | 27 | .light ::-webkit-scrollbar-thumb { 28 | background: #aaa; 29 | outline: 0.06125rem solid #aaa; 30 | } -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/favicon.ico -------------------------------------------------------------------------------- /fb/Config.js: -------------------------------------------------------------------------------- 1 | const string = 2 | 'eyJhcGlLZXkiOiJBSXphU3lBYXM5R2tldmhMajNrNlBTYUdNMzZoTlFRVVRtTWJ6b1kiLCJwcm9qZWN0SWQiOiJmaXJlYmFzZS1iYWNrc3BhY2VzIiwiZGF0YWJhc2VVUkwiOiJodHRwczovL2JhY2tzcGFjZXMuZmlyZWJhc2Vpby5jb20ifQ==' 3 | const text = atob(string) 4 | const obj = JSON.parse(text) 5 | export default obj 6 | -------------------------------------------------------------------------------- /fb/DefineTransform.js: -------------------------------------------------------------------------------- 1 | import firebase from 'https://cdn.skypack.dev/@firebase/app@8.0.0' 2 | import 'https://cdn.skypack.dev/@firebase/database' 3 | import config from './Config.js' 4 | 5 | export default class DefineTransform { 6 | constructor(root = '') { 7 | firebase.initializeApp(config) 8 | this.database = firebase.database() 9 | this.modelsRoot = `${root}/agentscript/models` 10 | } 11 | 12 | transformsRef(modelName) { 13 | return this.database.ref(`${this.modelsRoot}/${modelName}/transforms`) 14 | } 15 | 16 | defineTransform(modelName, transformName, fcn) { 17 | fcn = fcn.replace(/ */g, ' ') 18 | const xfm = { function: fcn } 19 | 20 | this.transformsRef(modelName).child(transformName).set(xfm) 21 | 22 | // Used by onValue() below 23 | const resultsRef = this.transformsRef(modelName).child( 24 | transformName + '/result' 25 | ) 26 | 27 | function onValue(fcn) { 28 | resultsRef.on('value', ev => { 29 | const val = ev.val() 30 | if (val) fcn(val) 31 | }) 32 | } 33 | return onValue 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /fb/convergence.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Convergence 5 | 6 | 7 | 8 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /fb/density.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Density 4 | 5 | 6 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /fb/flock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Flock 5 | 6 | 7 | 8 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /fb/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello 5 | 6 | 7 | 8 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /fb/xymeans.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Means 4 | 5 | 6 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ide/Ants.js: -------------------------------------------------------------------------------- 1 | import AntsModel from 'https://code.agentscript.org/models/AntsModel.js' 2 | import Color from 'https://code.agentscript.org/src/Color.js' 3 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 4 | 5 | const inset = 3 6 | export class Model extends AntsModel { 7 | foodX = world => world.minX + world.numX / inset 8 | nestX = world => world.maxX - world.numX / inset 9 | // name = 'Ants' 10 | } 11 | 12 | export const patchSize = 10 13 | 14 | // const nestColor = Color.typedColor('yellow') 15 | const nestColor = Color.typedColor('orange') 16 | const foodColor = Color.typedColor('blue') 17 | const nestColorMap = ColorMap.gradientColorMap(20, ['white', nestColor]) 18 | const foodColorMap = ColorMap.gradientColorMap(20, ['white', foodColor]) 19 | 20 | export const drawOptions = { 21 | patchesColor: p => { 22 | if (p.isNest) return nestColor 23 | if (p.isFood) return foodColor 24 | return p.foodPheromone > p.nestPheromone 25 | ? foodColorMap.scaleColor(p.foodPheromone, 0, 1) 26 | : nestColorMap.scaleColor(p.nestPheromone, 0, 1) 27 | }, 28 | turtlesShape: 'bug', 29 | turtlesSize: 5, 30 | turtlesColor: t => (t.carryingFood ? nestColor : foodColor), 31 | } 32 | 33 | export default { Model, patchSize, drawOptions } 34 | -------------------------------------------------------------------------------- /ide/Darts.js: -------------------------------------------------------------------------------- 1 | import HelloModel from 'https://code.agentscript.org/models/HelloModel.js' 2 | 3 | export class Model extends HelloModel { 4 | population = 40 // number of turtles 5 | speed = 0.3 // step size in patch units 6 | wiggleAngle = 10 // wiggle angle in degrees 7 | linksToo = false // handy to show just turtles if false 8 | // name = 'Darts' 9 | } 10 | 11 | export const patchSize = 20 12 | 13 | export const drawOptions = { 14 | turtlesSize: 4, 15 | patchesColor: 'white', 16 | } 17 | 18 | export default { Model, patchSize, drawOptions } 19 | -------------------------------------------------------------------------------- /ide/thumbs/ants.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/ants.png -------------------------------------------------------------------------------- /ide/thumbs/antselements.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/antselements.jpg -------------------------------------------------------------------------------- /ide/thumbs/diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/diffuse.png -------------------------------------------------------------------------------- /ide/thumbs/fire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/fire.png -------------------------------------------------------------------------------- /ide/thumbs/flock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/flock.png -------------------------------------------------------------------------------- /ide/thumbs/kelpforest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/kelpforest.png -------------------------------------------------------------------------------- /ide/thumbs/kelpforestmvc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/kelpforestmvc.jpg -------------------------------------------------------------------------------- /ide/thumbs/slimemold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/slimemold.png -------------------------------------------------------------------------------- /ide/thumbs/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/template.png -------------------------------------------------------------------------------- /ide/thumbs/tsp-mvc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/tsp-mvc.jpg -------------------------------------------------------------------------------- /ide/thumbs/tsp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/tsp.png -------------------------------------------------------------------------------- /ide/thumbs/tspelements.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/tspelements.jpg -------------------------------------------------------------------------------- /ide/thumbs/virus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/ide/thumbs/virus.png -------------------------------------------------------------------------------- /leaflet/map.css: -------------------------------------------------------------------------------- 1 | /* 2 | To change the tile borders: 3 | let root = document.documentElement 4 | root.style.setProperty('--tile-border', "solid red 4px") 5 | root.style.getPropertyValue('--tile-border') 6 | Use "0px" for none 7 | Similar for width/height 8 | */ 9 | 10 | :root { 11 | --tile-border: solid red 2px; 12 | --map-height: 100vh; 13 | --map-width: 100vw; 14 | } 15 | 16 | * { 17 | padding: 0; 18 | margin: 0; 19 | } 20 | 21 | #map { 22 | height: var(--map-height); 23 | width: var(--map-width); 24 | } 25 | 26 | /* https://gis.stackexchange.com/questions/149062/display-tile-grid-borders-with-leaflet-visual-debugging */ 27 | .leaflet-tile { 28 | border: var(--tile-border); 29 | } 30 | 31 | /* Needed when usinng dat.gui to put it on top of map */ 32 | .leaflet-container { 33 | isolation: isolate; 34 | } 35 | -------------------------------------------------------------------------------- /maplibre/countiesmap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | USCounties 5 | 6 | 7 | 8 |
9 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /maplibre/rectdrag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RectDrag 5 | 6 | 7 | 8 |
9 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /maplibre/rectscreen.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RectScreen 5 | 6 | 7 | 8 |
9 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /maplibre/rectstatic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RectStatic 5 | 6 | 7 | 8 |
9 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /maplibre/streetsdata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | StreetData 5 | 6 | 7 | 8 |
9 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /maplibre/vectormap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | VectorMap 5 | 6 | 7 | 8 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /models/ButtonsModel.js: -------------------------------------------------------------------------------- 1 | import Model from 'https://code.agentscript.org/src/Model.js' 2 | 3 | export default class ButtonsModel extends Model { 4 | population = 200 // number of buttons 5 | 6 | // ====================== 7 | 8 | // We can use Model's constructor, due to using Model's default World. 9 | // If you pass in world options, Model will use them 10 | // constructor() { 11 | // super() // use default world options. 12 | // } 13 | 14 | setup() { 15 | this.turtles.setDefault('theta', 0) // override promotion to random angle 16 | 17 | this.cluster = new Set() 18 | 19 | this.turtles.create(this.population, t => 20 | t.setxy(...this.world.randomPatchPoint()) 21 | ) 22 | } 23 | 24 | step() { 25 | if (this.done) return 26 | 27 | const b1 = this.turtles.oneOf() 28 | const b2 = this.turtles.otherOneOf(b1) 29 | 30 | this.links.create(b1, b2) 31 | 32 | const vertices = this.graphOf(b1) 33 | if (vertices.size > this.cluster.size) this.cluster = vertices 34 | 35 | this.done = this.cluster.size === this.turtles.length 36 | if (this.done) console.log(`Model done at tick: ${this.ticks}`) 37 | } 38 | 39 | graphOf(t) { 40 | const vertices = new Set() 41 | this.addNeighbors(t, vertices) 42 | return vertices 43 | } 44 | addNeighbors(t, vertices) { 45 | vertices.add(t) 46 | t.linkNeighbors().ask(n => { 47 | if (!vertices.has(n)) this.addNeighbors(n, vertices) 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /models/DiffuseModel.js: -------------------------------------------------------------------------------- 1 | import World from 'https://code.agentscript.org/src/World.js' 2 | import Model from 'https://code.agentscript.org/src/Model.js' 3 | import * as util from 'https://code.agentscript.org/src/utils.js' 4 | 5 | export default class DiffuseModel extends Model { 6 | population = 2 7 | speed = 0.5 8 | wiggleAngle = 10 9 | radius = 6 10 | diffuseRate = 0.05 11 | seedDelta = 0.1 12 | seedMax = 0.8 13 | 14 | // ====================== 15 | 16 | constructor(worldOptions = World.defaultOptions(100)) { 17 | super(worldOptions) 18 | } 19 | 20 | setup() { 21 | this.turtles.setDefault('speed', this.speed) 22 | 23 | this.patches.ask(p => { 24 | p.ran = util.randomFloat(1.0) 25 | }) 26 | 27 | this.patches.nOf(this.population).ask(p => { 28 | p.sprout(1, this.turtles) 29 | }) 30 | } 31 | step() { 32 | this.turtles.ask(t => { 33 | t.heading += util.randomCentered(this.wiggleAngle) 34 | t.forward(t.speed) 35 | this.patches.inRadius(t.patch, this.radius, true).ask(p => { 36 | p.ran = Math.min(p.ran + this.seedDelta, this.seedMax) 37 | }) 38 | }) 39 | 40 | this.patches.diffuse('ran', this.diffuseRate) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /models/Hello3DModel.js: -------------------------------------------------------------------------------- 1 | import * as util from 'https://code.agentscript.org/src/utils.js' 2 | import Model from 'https://code.agentscript.org/src/Model3D.js' 3 | 4 | export default class Hello3DModel extends Model { 5 | population = 100 6 | speed = 0.1 // patches per step 7 | wiggleAngle = 10 // degrees 8 | linksToo = true // handy to show just turtles if false 9 | 10 | // ====================== 11 | 12 | // We can use Model's constructor, due to using Model's default World. 13 | // If you pass in world options, Model will use them 14 | constructor() { 15 | super() // use default world options. 16 | } 17 | setup() { 18 | this.turtles.setDefault('atEdge', 'bounce') 19 | 20 | this.turtles.create(this.population, t => { 21 | t.setxyz(...this.world.random3DPoint()) 22 | }) 23 | 24 | if (this.linksToo) 25 | this.turtles.ask(t => { 26 | if (this.population > 1) 27 | this.links.create(t, this.turtles.otherOneOf(t)) 28 | }) 29 | } 30 | 31 | step() { 32 | this.turtles.ask(t => { 33 | t.left(util.randomCentered(this.wiggleAngle)) 34 | t.forward(this.speed) 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /models/HelloModel.js: -------------------------------------------------------------------------------- 1 | import Model from 'https://code.agentscript.org/src/Model.js' 2 | import * as util from 'https://code.agentscript.org/src/utils.js' 3 | 4 | // Subclass class Model to create our new model, HelloModel 5 | class HelloModel extends Model { 6 | population = 10 // number of turtles 7 | speed = 0.1 // step size in patch units 8 | wiggleAngle = 10 // wiggle angle in degrees 9 | linksToo = true // handy to show just turtles if false 10 | 11 | // worldOptions = undefined, means use default worldOptions: 12 | // 33 x 33 patches with 0,0 origin at the center. 13 | constructor(worldOptions = undefined) { 14 | super(worldOptions) 15 | } 16 | 17 | setup() { 18 | // Have turtles "bounce" at the Patches edges. Default is to wrap 19 | this.turtles.setDefault('atEdge', 'bounce') 20 | 21 | // create "population" turtles placed on random patches 22 | this.turtles.create(this.population, t => 23 | t.moveTo(this.patches.oneOf()) 24 | ) 25 | 26 | // If links.too is true, create a link from every turtle to another turtle 27 | if (this.linksToo) { 28 | this.turtles.ask(t => { 29 | this.links.create(t, this.turtles.otherOneOf(t)) 30 | }) 31 | } 32 | } 33 | 34 | step() { 35 | // change heading randomly, moving forward by "speed" 36 | this.turtles.ask(t => { 37 | t.heading += util.randomCentered(this.wiggleAngle) 38 | t.forward(this.speed) 39 | }) 40 | } 41 | } 42 | 43 | export default HelloModel 44 | -------------------------------------------------------------------------------- /models/LifeModel.js: -------------------------------------------------------------------------------- 1 | import Model from 'https://code.agentscript.org/src/Model.js' 2 | import World from 'https://code.agentscript.org/src/World.js' 3 | import * as util from 'https://code.agentscript.org/src/utils.js' 4 | 5 | export default class LifeModel extends Model { 6 | population = 10 // number of turtles 7 | initialDensity = 30 // percent of active cells 8 | 9 | // ====================== 10 | 11 | constructor(worldOptions = World.defaultOptions(50)) { 12 | super(worldOptions) 13 | } 14 | 15 | setup() { 16 | this.patches.ask(p => { 17 | p.living = util.randomFloat(100) < this.initialDensity 18 | p.liveNeighbors = 0 19 | }) 20 | } 21 | 22 | get density() { 23 | const living = this.patches.with(p => p.living).length 24 | return living / this.patches.length 25 | } 26 | 27 | step() { 28 | // 29 | this.patches.ask(p => { 30 | p.liveNeighbors = p.neighbors.with(n => n.living).length 31 | }) 32 | this.patches.ask(p => { 33 | if (p.liveNeighbors === 3) p.living = true 34 | else if (p.liveNeighbors !== 2) p.living = false 35 | }) 36 | 37 | // console.log(this.density) 38 | } 39 | } 40 | 41 | // export default LifeModel 42 | -------------------------------------------------------------------------------- /models/MinModel.js: -------------------------------------------------------------------------------- 1 | import Model from 'https://code.agentscript.org/src/Model.js' 2 | 3 | // Subclass class Model to create our new model, HelloModel 4 | class MinModel extends Model { 5 | population = 10 // number of turtles 6 | speed = 0.25 // step size in patch units 7 | 8 | setup() { 9 | this.turtles.setDefault('atEdge', 'bounce') 10 | 11 | this.turtles.create(this.population, t => { 12 | t.setxy(0, 0) 13 | }) 14 | 15 | this.turtles.ask(t => { 16 | this.links.create(t, this.turtles.otherOneOf(t)) 17 | }) 18 | } 19 | 20 | step() { 21 | this.turtles.ask(t => { 22 | t.forward(this.speed) 23 | }) 24 | } 25 | } 26 | 27 | export default MinModel 28 | -------------------------------------------------------------------------------- /models/ShapesModel.js: -------------------------------------------------------------------------------- 1 | import HelloModel from 'https://code.agentscript.org/models/HelloModel.js' 2 | import World from 'https://code.agentscript.org/src/World.js' 3 | 4 | // We use a simple HelloModel subclass 5 | export default class ShapesModel extends HelloModel { 6 | population = 100 // override HelloModel's population & linkstoo 7 | linksToo = false 8 | 9 | constructor(worldOptions = World.defaultOptions(16)) { 10 | super(worldOptions) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /models/TemplateModel.js: -------------------------------------------------------------------------------- 1 | import World from 'https://code.agentscript.org/src/World.js' 2 | import Model from 'https://code.agentscript.org/src/Model.js' 3 | import * as util from 'https://code.agentscript.org/src/utils.js' 4 | 5 | export default class TemplateModel extends Model { 6 | population = 10 // number of turtles 7 | speed = 0.25 // step size in patch units 8 | wiggleAngle = 30 // wiggle angle in degrees 9 | 10 | // worldOptions: patches -16, 16 or 33 x 33 with 0,0 origin 11 | constructor(worldOptions = World.defaultOptions(16)) { 12 | super(worldOptions) 13 | } 14 | 15 | setup() { 16 | // Have turtles "bounce" at the Patches edges. Default is to wrap 17 | this.turtles.setDefault('atEdge', 'bounce') 18 | 19 | // create "population" turtles initially on the origin 20 | this.turtles.create(this.population, t => { 21 | t.setxy(0, 0) 22 | }) 23 | // have each turtle create a link to a random other turtle 24 | this.turtles.ask(t => { 25 | this.links.create(t, this.turtles.otherOneOf(t)) 26 | }) 27 | } 28 | 29 | step() { 30 | // change heading randomly, moving forward by "speed" 31 | this.turtles.ask(t => { 32 | t.heading += util.randomCentered(this.wiggleAngle) 33 | t.forward(this.speed) 34 | }) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /models/Wander3DModel.js: -------------------------------------------------------------------------------- 1 | import * as util from '../src/utils.js' 2 | import Model from '../src/Model3D.js' 3 | 4 | export default class Wander3DModel extends Model { 5 | population = 25 6 | speed = 0.1 // patches per step 7 | wiggleAngle = 30 // degrees 8 | rotateEvery = 15 9 | 10 | // ====================== 11 | 12 | // We can use Model's constructor, due to using Model's default World. 13 | // If you pass in world options, Model will use them 14 | constructor() { 15 | super() // use default world options. 16 | } 17 | 18 | setup() { 19 | this.turtles.setDefault('atEdge', 'bounce') 20 | 21 | this.turtles.create(this.population, t => { 22 | t.setxyz(this.world.random3DPoint()) 23 | }) 24 | } 25 | 26 | step() { 27 | const doRotations = this.ticks % this.rotateEvery === 0 28 | this.turtles.ask(t => { 29 | if (doRotations) { 30 | t.right(util.randomCentered(this.wiggleAngle)) 31 | t.tiltUp(util.randomCentered(this.wiggleAngle)) 32 | t.rollRight(util.randomCentered(this.wiggleAngle)) 33 | } 34 | t.forward(this.speed) 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /models/WaterModel.js: -------------------------------------------------------------------------------- 1 | import World from '../src/World.js' 2 | import Model from '../src/Model.js' 3 | 4 | // Derived from Cody's water model. 5 | export default class WaterModel extends Model { 6 | strength = 100 7 | surfaceTension = 56 8 | friction = 0.99 9 | drip = 30 // create new wave every drip steps 10 | 11 | // ====================== 12 | 13 | constructor(worldOptions = World.defaultOptions(120)) { 14 | super(worldOptions) 15 | } 16 | 17 | setup() { 18 | this.patches.ask(p => { 19 | p.zpos = 0 20 | p.deltaZ = 0 21 | }) 22 | } 23 | 24 | step() { 25 | if (this.ticks % this.drip === 0) this.createWave(this.patches.oneOf()) 26 | this.patches.ask(p => this.computeDeltaZ(p)) 27 | this.patches.ask(p => this.updateZ(p)) 28 | } 29 | 30 | createWave(p) { 31 | p.zpos = this.strength 32 | } 33 | computeDeltaZ(p) { 34 | const k = 1 - 0.01 * this.surfaceTension 35 | const n = p.neighbors4 36 | p.deltaZ = p.deltaZ + k * (n.sum('zpos') - n.length * p.zpos) 37 | } 38 | updateZ(p) { 39 | p.zpos = (p.zpos + p.deltaZ) * this.friction 40 | } 41 | 42 | // Used by modeler for reporting stats, not needed by model itself 43 | averageZpos() { 44 | return this.patches.props('zpos').sum() / this.patches.length 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /models/data/redfish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/models/data/redfish.png -------------------------------------------------------------------------------- /models/data/roads14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/models/data/roads14.png -------------------------------------------------------------------------------- /models/data/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backspaces/agentscript/1596fa32565943f7114b7d3a4c4e7ea332a53e75/models/data/twitter.png -------------------------------------------------------------------------------- /models/runWorker.js: -------------------------------------------------------------------------------- 1 | import * as util from '../src/utils.js' 2 | 3 | async function run(classPath) { 4 | console.log('worker: start', classPath) 5 | 6 | // note util.runModel will be run in the src/ dir, not the models/ dir 7 | // this is why we use import.meta.resolve for absolute paths 8 | const model = await util.runModel(classPath) 9 | 10 | self.postMessage(util.sampleModel(model)) 11 | self.close() 12 | } 13 | 14 | onmessage = e => { 15 | if (e.data.cmd === 'init') { 16 | run(e.data.classPath) // don't await, stops worker 17 | } else { 18 | console.log('Oops, unknown message: ', e) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /models/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test 5 | 6 | 7 | 8 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /models/worker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | test 5 | 6 | 7 | 8 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /src/AgentscriptAll.js: -------------------------------------------------------------------------------- 1 | import * as AS from './AS.js' 2 | Object.assign(window, AS) 3 | // console.log(AS, window) 4 | -------------------------------------------------------------------------------- /src/Buttons.js: -------------------------------------------------------------------------------- 1 | function createButton(div, name, cmd) { 2 | const button = document.createElement('button') 3 | button.textContent = name 4 | button.onclick = cmd 5 | 6 | button.style.backgroundColor = 'skyblue' 7 | button.style.padding = '10px 14px' 8 | button.style.fontSize = '18px' 9 | button.style.border = 'none' 10 | // button.style.borderRadius = "5px"; 11 | button.style.cursor = 'pointer' 12 | button.style.margin = '0 5px' // Add margin for spacing between buttons 13 | 14 | div.appendChild(button) 15 | return button 16 | } 17 | 18 | class Buttons { 19 | constructor(divId, buttonTemplates) { 20 | const div = document.getElementById(divId) 21 | this.buttons = {} 22 | buttonTemplates.forEach(obj => { 23 | let { name, cmd } = obj 24 | if (!(cmd && name)) throw Error('No cmd or name given for ' + obj) 25 | this.buttons[name] = createButton(div, name, cmd) 26 | }) 27 | } 28 | } 29 | 30 | export default Buttons 31 | -------------------------------------------------------------------------------- /src/Evented.js: -------------------------------------------------------------------------------- 1 | class Evented { 2 | events = {} 3 | 4 | // constructor() { 5 | // this.events = {} 6 | // } 7 | 8 | on(name, callback) { 9 | if (!this.events[name]) { 10 | this.events[name] = [] 11 | } 12 | this.events[name].push(callback) 13 | return callback // for when called with function/arrow literal 14 | } 15 | 16 | off(name, callback = null) { 17 | if (this.events[name]) { 18 | if (callback) { 19 | this.events[name] = this.events[name].filter( 20 | cb => cb !== callback 21 | ) 22 | } 23 | if (this.events[name].length === 0 || !callback) { 24 | delete this.events[name] 25 | } 26 | } 27 | } 28 | 29 | emit(name, ...args) { 30 | if (this.events[name]) { 31 | this.events[name].forEach(callback => callback(...args)) 32 | } 33 | } 34 | } 35 | export default Evented 36 | -------------------------------------------------------------------------------- /src/MapDraw.js: -------------------------------------------------------------------------------- 1 | import * as util from '../src/utils.js' 2 | import TwoDraw from '../src/TwoDraw.js' 3 | 4 | // make sure world is a geoworld 5 | // separate drawoptions from viewoptions if needed 6 | // default patch colors to transparent 7 | // default div to a canvas 8 | 9 | class MapDraw extends TwoDraw { 10 | constructor(model, viewOptions = {}, drawOptions = {}) { 11 | if (!model.world.bbox) throw Error('MapDraw: model must use GeoWorld') 12 | 13 | drawOptions = TwoDraw.separateDrawOptions(viewOptions, drawOptions) 14 | 15 | if (!drawOptions.patchesColor) { 16 | drawOptions.patchesColor = 'transparent' 17 | } 18 | if (!viewOptions.div) { 19 | viewOptions.div = util.createCanvas(0, 0) // the view will resize 20 | } 21 | 22 | super(model, viewOptions, drawOptions) 23 | } 24 | } 25 | 26 | export default MapDraw 27 | -------------------------------------------------------------------------------- /src/Model3D.js: -------------------------------------------------------------------------------- 1 | import Turtle3D from './Turtle3D.js' 2 | import Model from './Model.js' 3 | 4 | /** 5 | * Model3D uses Model with one change: 6 | * 7 | * - model.Turtles: an array {@link Turtles} of {@link Turtle3D} instances 8 | * 9 | * @param {Object|World} [worldOptions=World.defaultOptions()] 10 | * 11 | */ 12 | class Model3D extends Model { 13 | initAgentSet(name, AgentsetClass, AgentClass) { 14 | if (name === 'turtles') AgentClass = Turtle3D 15 | super.initAgentSet(name, AgentsetClass, AgentClass) 16 | } 17 | } 18 | 19 | export default Model3D 20 | -------------------------------------------------------------------------------- /uielements/README.md: -------------------------------------------------------------------------------- 1 | Code | Run demo 2 | ------- | ------ 3 | [ants](https://github.com/backspaces/agentscript/tree/master/uielements/ants.html#L1) | [https://code.agentscript.org/uielements/ants.html](https://code.agentscript.org/uielements/ants.html) 4 | [min](https://github.com/backspaces/agentscript/tree/master/uielements/min.html#L1) | [https://code.agentscript.org/uielements/min.html](https://code.agentscript.org/uielements/min.html) 5 | [orbit](https://github.com/backspaces/agentscript/tree/master/uielements/orbit.html#L1) | [https://code.agentscript.org/uielements/orbit.html](https://code.agentscript.org/uielements/orbit.html) 6 | [tsp](https://github.com/backspaces/agentscript/tree/master/uielements/tsp.html#L1) | [https://code.agentscript.org/uielements/tsp.html](https://code.agentscript.org/uielements/tsp.html) 7 | [uielements](https://github.com/backspaces/agentscript/tree/master/uielements/uielements.html#L1) | [https://code.agentscript.org/uielements/uielements.html](https://code.agentscript.org/uielements/uielements.html) 8 | -------------------------------------------------------------------------------- /uielements/minElements.js: -------------------------------------------------------------------------------- 1 | export default [ 2 | { 3 | id: 1729270887157, 4 | type: 'output', 5 | name: 'ticks', 6 | position: { 7 | x: 342, 8 | y: 21, 9 | }, 10 | monitor: 'model.ticks', 11 | fps: '10', 12 | command: null, 13 | }, 14 | { 15 | id: 1729463191305, 16 | type: 'range', 17 | name: 'patchesSize', 18 | command: "view.setValue('patchesSize', value)", 19 | position: { 20 | x: 172, 21 | y: 21, 22 | }, 23 | min: '1', 24 | max: '20', 25 | step: '1', 26 | value: '12', 27 | }, 28 | { 29 | id: 1730141024864, 30 | type: 'checkbox', 31 | name: 'Run', 32 | command: 'checked ? anim.start() : anim.stop()', 33 | position: { 34 | x: 20, 35 | y: 21, 36 | }, 37 | checked: false, 38 | }, 39 | { 40 | id: 1733442807622, 41 | type: 'dropdown', 42 | name: 'fps', 43 | command: 'anim.setFps(value)', 44 | position: { 45 | x: 100, 46 | y: 21, 47 | }, 48 | options: ['2', '5', '10', '20', '30', '60'], 49 | selected: '30', 50 | }, 51 | { 52 | id: 1729535684833, 53 | type: 'button', 54 | name: 'Save', 55 | command: 'downloadJson()', 56 | position: { 57 | x: 405, 58 | y: 21, 59 | }, 60 | }, 61 | ] 62 | -------------------------------------------------------------------------------- /uielements/uielements.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 22 | 23 | 24 | 31 | 32 | 33 |
-------------------------------------------------------------------------------- /uielements/uielements.html.js: -------------------------------------------------------------------------------- 1 | await fetch('https://code.agentscript.org/uielements/uielements.html') 2 | // await fetch('../uielements/uielements.html') 3 | .then(response => response.text()) 4 | .then(html => { 5 | // Insert the HTML content for the menu into the DOM 6 | document.body.insertAdjacentHTML('afterbegin', html) 7 | console.log('uielements.html loaded and parsed') 8 | }) 9 | -------------------------------------------------------------------------------- /views1/ants.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ants 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/avalanche.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Avalanche 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/buttons.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Buttons 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/camera3d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Camera3D 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/counties.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Counties 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/diffuse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Diffuse 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/droplets.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Droplets 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/exit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exit 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/fire.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Fire 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/flock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Flock 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/gridpath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | GridPath 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/hello3d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello3D 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/hello3z.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello3Z 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/helloplus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelloPlus 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/kelpforest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | KelpForest 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/life.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Life 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/linktravel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | LinkTravel 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/min.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Min 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/orbit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Orbit 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/pheromone.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Pheromone 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/roads.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Roads 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/shapes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Shapes 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/slimemold.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | SlimeMold 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Template 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/tsp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tsp 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/virus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Virus 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/wallfollower.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | WallFollower 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/wander3d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wander3D 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views1/water.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Water 4 | 5 | 6 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /views2/avalanche.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Avalanche 5 | 6 | 7 | 8 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /views2/buttons.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Buttons 5 | 6 | 7 | 8 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /views2/diffuse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Diffuse 5 | 6 | 7 | 8 | 36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /views2/flock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Flock 5 | 6 | 7 | 8 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /views2/gridpath.html: -------------------------------------------------------------------------------- 1 | 2 | GridPath 3 | 4 | 5 | 6 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /views2/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello 5 | 6 | 7 | 8 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /views2/hellotext.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HelloText 5 | 6 | 7 | 8 | 36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /views2/life.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Life 5 | 6 | 7 | 8 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /views2/linktravel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LinkTravel 5 | 6 | 7 | 8 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /views2/min.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Template 5 | 6 | 7 | 8 | 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /views2/pheromone.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Pheromone 5 | 6 | 7 | 8 | 36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /views2/slimemold.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SlimeMold 5 | 6 | 7 | 8 | 36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /views2/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Template 5 | 6 | 7 | 8 | 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /views2/tsp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tsp 5 | 6 | 7 | 8 | 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /views2/virus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Virus 5 | 6 | 7 | 8 | 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /views2/wallfollower.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WallFollower 5 | 6 | 7 | 8 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /views2/water.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Water 5 | 6 | 7 | 8 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /views25/buttons.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | buttons 5 | 6 | 7 | 8 | 45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /views25/diffuse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | diffuse 5 | 6 | 7 | 8 | 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /views25/flock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | flock 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views25/gridpath.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | gridpath 5 | 6 | 7 | 8 | 48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /views25/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hello 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views25/hello3d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hello3d 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views25/hello3z.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | helloz 5 | 6 | 7 | 8 | 44 |
45 | 46 | 47 | -------------------------------------------------------------------------------- /views25/helloPatches.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | helloPatches 5 | 6 | 7 | 8 | 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /views25/helloplus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hello 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views25/life.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Life 5 | 6 | 7 | 8 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /views25/linktravel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | linkTravel 5 | 6 | 7 | 8 | 45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /views25/tsp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | tsp 5 | 6 | 7 | 8 | 47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /views25/virus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | virus 5 | 6 | 7 | 8 | 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /views25/water.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | water 5 | 6 | 7 | 8 | 46 |
47 | 48 | 49 | -------------------------------------------------------------------------------- /views2full/antsfull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ants 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views2full/diffusefull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Diffuse 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views2full/exitfull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exit 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views2full/firefull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Fire 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views2full/hellofull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views2full/shapesfull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shapes 5 | 6 | 7 | 8 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /views2full/tspfull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tsp 5 | 6 | 7 | 8 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /views2full/waterfull.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Water 5 | 6 | 7 | 8 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /views2mv/ants.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ants 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/antsOptions.js: -------------------------------------------------------------------------------- 1 | import Color from 'https://code.agentscript.org/src/Color.js' 2 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 3 | 4 | export default function TwoDrawOptions(div, model, patchSize = 10) { 5 | const nestColor = Color.typedColor('yellow') 6 | const foodColor = Color.typedColor('blue') 7 | const nestColorMap = ColorMap.gradientColorMap(20, ['black', nestColor]) 8 | const foodColorMap = ColorMap.gradientColorMap(20, ['black', foodColor]) 9 | 10 | const drawOptions = { 11 | patchesColor: p => { 12 | if (p.isNest) return nestColor 13 | if (p.isFood) return foodColor 14 | return p.foodPheromone > p.nestPheromone 15 | ? foodColorMap.scaleColor(p.foodPheromone, 0, 1) 16 | : nestColorMap.scaleColor(p.nestPheromone, 0, 1) 17 | }, 18 | turtlesShape: 'bug', 19 | turtlesSize: 3, 20 | turtlesColor: t => (t.carryingFood ? nestColor : foodColor), 21 | } 22 | 23 | // ant shape difficult to draw, use sprites, small images 24 | return { div, useSprites: true, patchSize, drawOptions } 25 | } 26 | -------------------------------------------------------------------------------- /views2mv/avalanche.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Avalanche 5 | 6 | 7 | 8 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /views2mv/avalancheOptions.js: -------------------------------------------------------------------------------- 1 | import Color from 'https://code.agentscript.org/src/Color.js' 2 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 3 | 4 | export default function TwoDrawOptions(div, model, patchSize = 10) { 5 | const pi = Math.PI 6 | 7 | const snowColor = ColorMap.gradientColorMap(20, ['rgb(98,52,18)', 'white']) 8 | const drawOptions = { 9 | patchesColor: p => { 10 | const aspect2 = (p.aspect + 2 * pi) % (2 * pi) 11 | const k = (pi - Math.abs(aspect2 - pi)) / pi 12 | const snow = snowColor.scaleColor(p.snowDepth, 0, 6) 13 | const col = Color.typedColor(k * snow[0], k * snow[1], k * snow[2]) 14 | return col 15 | }, 16 | } 17 | 18 | return { div, patchSize, drawOptions } 19 | } 20 | -------------------------------------------------------------------------------- /views2mv/buttons.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Buttons 5 | 6 | 7 | 8 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /views2mv/buttonsOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 20) { 2 | const drawOptions = { 3 | turtlesColor: t => (model.cluster.has(t) ? 'red' : 'random'), 4 | turtlesShape: 'circle', 5 | turtlesSize: 2, 6 | linksColor: 'rgba(255, 255, 255, 0.50', 7 | } 8 | 9 | return { div, patchSize, drawOptions } 10 | } 11 | -------------------------------------------------------------------------------- /views2mv/diffuse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Diffuse 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/diffuseOptions.js: -------------------------------------------------------------------------------- 1 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 2 | 3 | export default function TwoDrawOptions(div, model, patchSize = 3) { 4 | const drawOptions = { 5 | patchesColor: p => ColorMap.Rgb256.scaleColor(p.ran, 0, 1), 6 | turtlesColor: 'red', 7 | turtlesSize: 8, 8 | } 9 | 10 | return { div, patchSize, drawOptions } 11 | } 12 | -------------------------------------------------------------------------------- /views2mv/droplets.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Droplets 5 | 6 | 7 | 8 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /views2mv/dropletsOptions.js: -------------------------------------------------------------------------------- 1 | import Color from 'https://code.agentscript.org/src/Color.js' 2 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 3 | 4 | export default function TwoDrawOptions(div, model, patchSize = 10) { 5 | const drawOptions = { 6 | turtlesShape: 'square', 7 | turtlesRotate: false, 8 | turtlesSize: 0.8, 9 | turtlesColor: 'yellow', 10 | initPatches: (model, view) => { 11 | const elevation = model.patches.exportDataSet('elevation') 12 | const grays = elevation.scale(0, 255).data 13 | const colors = grays.map(d => ColorMap.Gray[Math.round(d)]) 14 | const localMinColor = Color.typedColor(255, 0, 0) 15 | model.localMins.forEach(p => { 16 | colors[p.id] = localMinColor 17 | }) 18 | return colors 19 | }, 20 | } 21 | 22 | // many turtle shapes difficult to draw, use small images 23 | return { div, useSprites: true, patchSize, drawOptions } 24 | } 25 | -------------------------------------------------------------------------------- /views2mv/exit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exit 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/exitOptions.js: -------------------------------------------------------------------------------- 1 | import Color from 'https://code.agentscript.org/src/Color.js' 2 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 3 | 4 | export default function TwoDrawOptions(div, model, patchSize = 8) { 5 | const patchColors = model.patches.map(p => { 6 | switch (p.breed.name) { 7 | case 'exits': 8 | return ColorMap.Basic16.atIndex(p.exitNumber + 4) 9 | case 'inside': 10 | return Color.typedColor('black') 11 | case 'wall': 12 | return Color.typedColor('gray') 13 | default: 14 | return ColorMap.LightGray.randomColor() 15 | } 16 | }) 17 | const drawOptions = { 18 | turtlesShape: 'circle', 19 | turtlesColor: t => patchColors[t.exit.id], 20 | turtlesSize: 1, 21 | initPatches: (model, view) => patchColors, 22 | } 23 | 24 | return { div, patchSize, drawOptions } 25 | } 26 | -------------------------------------------------------------------------------- /views2mv/fire.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Fire 5 | 6 | 7 | 8 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /views2mv/fireOptions.js: -------------------------------------------------------------------------------- 1 | import Color from 'https://code.agentscript.org/src/Color.js' 2 | 3 | export default function TwoDrawOptions(div, model, patchSize = 4) { 4 | const typeColors = { 5 | dirt: Color.cssToPixel('yellow'), 6 | tree: Color.cssToPixel('green'), 7 | fire: Color.cssToPixel('red'), 8 | ember4: Color.rgbaToPixel(255 - 25, 0, 0), 9 | ember3: Color.rgbaToPixel(255 - 50, 0, 0), 10 | ember2: Color.rgbaToPixel(255 - 75, 0, 0), 11 | ember1: Color.rgbaToPixel(255 - 100, 0, 0), 12 | ember0: Color.rgbaToPixel(255 - 125, 0, 0), 13 | } 14 | const drawOptions = { 15 | patchesColor: p => typeColors[p.type], 16 | } 17 | 18 | return { div, patchSize, drawOptions } 19 | } 20 | -------------------------------------------------------------------------------- /views2mv/flock.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Flock 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/flockOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 15) { 2 | const drawOptions = { 3 | turtlesSize: 1.5, 4 | } 5 | 6 | return { div, patchSize, drawOptions } 7 | } 8 | -------------------------------------------------------------------------------- /views2mv/gridpath.html: -------------------------------------------------------------------------------- 1 | 2 | GridPath 3 | 4 | 5 | 6 | 28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /views2mv/gridpathOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 50) { 2 | const drawOptions = { 3 | turtlesShape: 'circle', 4 | turtlesColor: 'red', 5 | turtlesSize: 0.5, 6 | linksColor: 'red', 7 | patchesMap: 'LightGray', 8 | textProperty: 'choices', 9 | textColor: 'white', 10 | textSize: 0.3, 11 | } 12 | 13 | return { div, patchSize, drawOptions } 14 | } 15 | -------------------------------------------------------------------------------- /views2mv/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/helloOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 20) { 2 | const drawOptions = { 3 | // use the defaults. 4 | } 5 | 6 | return { div, patchSize, drawOptions } 7 | } 8 | -------------------------------------------------------------------------------- /views2mv/hellotext.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HelloText 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/hellotextOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 20) { 2 | const drawOptions = { 3 | turtlesShape: 'circle', 4 | turtlesSize: 2, // turtle size in patches 5 | textProperty: 'id', 6 | textSize: 0.8, // text size in patches 7 | } 8 | 9 | return { div, patchSize, drawOptions } 10 | } 11 | -------------------------------------------------------------------------------- /views2mv/life.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Life 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/lifeOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 6) { 2 | const drawOptions = { 3 | patchesColor: p => (p.living ? 'red' : 'rgba(255, 99, 71, 0.2)'), 4 | } 5 | 6 | return { div, patchSize, drawOptions } 7 | } 8 | -------------------------------------------------------------------------------- /views2mv/linktravel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LinkTravel 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/linktravelOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 20) { 2 | const isNode = t => t.breed.name === 'nodes' 3 | const drawOptions = { 4 | patchesColor: 'black', 5 | turtlesColor: t => (isNode(t) ? 'red' : 'random'), 6 | turtlesShape: t => (isNode(t) ? 'circle' : 'dart'), 7 | turtlesSize: t => (isNode(t) ? 0.5 : 1.25), 8 | } 9 | 10 | return { div, patchSize, drawOptions } 11 | } 12 | -------------------------------------------------------------------------------- /views2mv/pheromone.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Pheromone 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/pheromoneOptions.js: -------------------------------------------------------------------------------- 1 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 2 | 3 | export default function TwoDrawOptions(div, model, patchSize = 20) { 4 | const colorMap = ColorMap.gradientColorMap(8, ['black', 'purple', 'yellow']) 5 | 6 | const drawOptions = { 7 | turtlesSize: 2, 8 | patchesColor: p => colorMap.scaleColor(p.pheromone, 0, 100), 9 | } 10 | 11 | return { div, patchSize, drawOptions } 12 | } 13 | -------------------------------------------------------------------------------- /views2mv/roads.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Roads 5 | 6 | 7 | 8 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /views2mv/roadsOptions.js: -------------------------------------------------------------------------------- 1 | import * as util from 'https://code.agentscript.org/src/utils.js' 2 | 3 | const baseUrl = 'https://code.agentscript.org/models/data/roads14.png' 4 | const baseMapTile = await util.imagePromise(baseUrl) 5 | 6 | export default function TwoDrawOptions(div, model, patchSize = 4) { 7 | const breedColor = { 8 | nodes: 'red', 9 | intersections: 'blue', 10 | drivers: 'green', 11 | } 12 | const breedSize = { nodes: 1, intersections: 2, drivers: 5 } 13 | const breedShape = { 14 | nodes: 'circle', 15 | intersections: 'circle', 16 | drivers: 'dart', 17 | } 18 | const drawOptions = { 19 | patchesColor: baseMapTile, 20 | turtlesColor: t => breedColor[t.breed.name], 21 | turtlesSize: t => breedSize[t.breed.name], 22 | turtlesShape: t => breedShape[t.breed.name], 23 | linksColor: 'black', 24 | } 25 | 26 | return { div, patchSize, drawOptions } 27 | } 28 | -------------------------------------------------------------------------------- /views2mv/shapes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Shapes 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/shapesOptions.js: -------------------------------------------------------------------------------- 1 | import Shapes from 'https://code.agentscript.org/src/Shapes.js' 2 | 3 | // add an image and emoji shapes 4 | const shapes = new Shapes() 5 | await shapes.imagePathPromise( 6 | 'twitter', 7 | 'https://code.agentscript.org/models/data/twitter.png' 8 | ) 9 | 10 | export default function TwoDrawOptions(div, model, patchSize = 20) { 11 | shapes.createEmojiPath('tree', 0x1f332) 12 | 13 | function turtleName(t) { 14 | return shapes.nameAtIndex(t.id) 15 | } 16 | const drawOptions = { 17 | turtlesShape: t => turtleName(t), 18 | turtlesSize: t => 3, 19 | turtlesRotate: t => !['lion', 'smiley', 'tree'].includes(turtleName(t)), 20 | } 21 | 22 | return { div, patchSize, drawOptions } 23 | } 24 | 25 | // shapes.createEmojiPath('lion', 0x1f981) 26 | // shapes.createEmojiPath('smiley', 0x1f600) 27 | 28 | // await shapes.imagePathPromise( 29 | // 'redfish', 30 | // 'https://code.agentscript.org/models/data/redfish.png' 31 | // ) 32 | -------------------------------------------------------------------------------- /views2mv/slimemold.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SlimeMold 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/slimemold.js: -------------------------------------------------------------------------------- 1 | import TwoDraw from 'https://code.agentscript.org/src/TwoDraw.js' 2 | import Animator from 'https://code.agentscript.org/src/Animator.js' 3 | 4 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 5 | 6 | import Model from 'https://code.agentscript.org/models/SlimeMoldModel.js' 7 | 8 | export default async function runModel(div, steps = 500, fps = 30) { 9 | const model = new Model() // use model's default world options 10 | await model.startup() 11 | model.setup() 12 | 13 | // ============================== 14 | 15 | const colorMap = ColorMap.gradientColorMap(8, ['black', 'purple', 'yellow']) 16 | 17 | const drawOptions = { 18 | turtlesSize: 2, 19 | patchesColor: p => colorMap.scaleColor(p.pheromone, 0, 100), 20 | } 21 | 22 | const view = new TwoDraw(model, { 23 | div, 24 | patchSize: 15, 25 | drawOptions, 26 | }) 27 | 28 | // ============================== 29 | 30 | const anim = new Animator( 31 | () => { 32 | model.step() 33 | view.draw() 34 | }, 35 | steps, // how many steps 36 | fps // at fps steps/second 37 | ) 38 | 39 | return { model, view, anim } 40 | } 41 | -------------------------------------------------------------------------------- /views2mv/slimemoldOptions.js: -------------------------------------------------------------------------------- 1 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 2 | 3 | export default function TwoDrawOptions(div, model, patchSize = 15) { 4 | const colorMap = ColorMap.gradientColorMap(8, ['black', 'purple', 'yellow']) 5 | 6 | const drawOptions = { 7 | turtlesSize: 2, 8 | patchesColor: p => colorMap.scaleColor(p.pheromone, 0, 100), 9 | } 10 | 11 | return { div, patchSize, drawOptions } 12 | } 13 | -------------------------------------------------------------------------------- /views2mv/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Template 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/templateOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 20) { 2 | const drawOptions = { 3 | turtlesColor: 'yellow', 4 | turtlesSize: 3, 5 | turtlesShape: 'bug', 6 | linksColor: 'red', 7 | linksWidth: 3, 8 | // patchesMap: 'Jet', // for bright patch colors! 9 | } 10 | 11 | return { div, patchSize, drawOptions } 12 | } 13 | -------------------------------------------------------------------------------- /views2mv/tsp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tsp 5 | 6 | 7 | 8 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /views2mv/tspOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 6) { 2 | const drawOptions = { 3 | patchesColor: 'black', 4 | turtlesShape: 'circle', 5 | // turtlesSize of 0 will skip drawing this turle 6 | // here "travelers" are skipped 7 | turtlesSize: t => (t.breed.name === 'nodes' ? 2 : 0), 8 | turtlesColor: 'yellow', 9 | linksColor: 'red', 10 | linksWidth: 2, 11 | } 12 | 13 | return { div, patchSize, drawOptions } 14 | } 15 | -------------------------------------------------------------------------------- /views2mv/virus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Virus 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/virusOptions.js: -------------------------------------------------------------------------------- 1 | export default function TwoDrawOptions(div, model, patchSize = 10) { 2 | const turtleColors = { 3 | infected: 'red', 4 | susceptible: 'blue', 5 | resistant: 'gray', 6 | } 7 | const drawOptions = { 8 | patchesColor: 'black', 9 | turtlesShape: 'circle', 10 | turtlesSize: 1.5, 11 | turtlesColor: t => turtleColors[t.state], 12 | // linksColor: 'rgba(255, 255, 255, 0.50', 13 | linksColor: 'white', 14 | linksWidth: 2, 15 | } 16 | 17 | return { div, patchSize, drawOptions } 18 | } 19 | -------------------------------------------------------------------------------- /views2mv/wallfollower.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WallFollower 5 | 6 | 7 | 8 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /views2mv/wallfollower.js: -------------------------------------------------------------------------------- 1 | import TwoDraw from 'https://code.agentscript.org/src/TwoDraw.js' 2 | import Animator from 'https://code.agentscript.org/src/Animator.js' 3 | 4 | import Color from 'https://code.agentscript.org/src/Color.js' 5 | 6 | import Model from 'https://code.agentscript.org/models/WallFollowerModel.js' 7 | 8 | export default async function runModel(div, steps = 500, fps = 30) { 9 | const model = new Model() // use model's default world options 10 | await model.startup() 11 | model.setup() 12 | 13 | // ============================== 14 | 15 | const wallsColor = Color.typedColor(222, 184, 135) 16 | const backgroundColor = Color.typedColor('black') 17 | const drawOptions = { 18 | patchesColor: p => 19 | p.breed.name === 'walls' ? wallsColor : backgroundColor, 20 | turtlesShape: 'dart', 21 | turtlesSize: 2, 22 | turtlesColor: t => (t.breed.name === 'lefty' ? 'green' : 'red'), 23 | } 24 | 25 | const view = new TwoDraw(model, { div }, drawOptions) 26 | 27 | // ============================== 28 | 29 | const anim = new Animator( 30 | () => { 31 | model.step() 32 | view.draw() 33 | }, 34 | steps, // how many steps 35 | fps // at fps steps/second 36 | ) 37 | 38 | return { model, view, anim } 39 | } 40 | -------------------------------------------------------------------------------- /views2mv/wallfollowerOptions.js: -------------------------------------------------------------------------------- 1 | import Color from 'https://code.agentscript.org/src/Color.js' 2 | 3 | export default function TwoDrawOptions(div, model, patchSize = 10) { 4 | const wallsColor = Color.typedColor(222, 184, 135) 5 | const backgroundColor = Color.typedColor('black') 6 | const drawOptions = { 7 | patchesColor: p => 8 | p.breed.name === 'walls' ? wallsColor : backgroundColor, 9 | turtlesShape: 'dart', 10 | turtlesSize: 2, 11 | turtlesColor: t => (t.breed.name === 'lefty' ? 'green' : 'red'), 12 | } 13 | 14 | return { div, patchSize, drawOptions } 15 | } 16 | -------------------------------------------------------------------------------- /views2mv/water.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Water 5 | 6 | 7 | 8 | 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /views2mv/waterOptions.js: -------------------------------------------------------------------------------- 1 | import ColorMap from 'https://code.agentscript.org/src/ColorMap.js' 2 | 3 | export default function TwoDrawOptions(div, model, patchSize = 2) { 4 | const patchColors = ColorMap.gradientColorMap(256, ['navy', 'aqua']) 5 | const maxZ = 10 6 | const drawOptions = { 7 | // Patches only model: 8 | patchesColor: p => patchColors.scaleColor(p.zpos, -maxZ, maxZ), 9 | } 10 | 11 | return { div, patchSize, drawOptions } 12 | } 13 | -------------------------------------------------------------------------------- /views3/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hello3d 5 | 6 | 7 | 8 | 43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /views3/hello3d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | hello3d 5 | 6 | 7 | 8 | 43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /views3/shapes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | shapes3d 5 | 6 | 7 | 8 | 45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /views3/wander.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | wander3d 5 | 6 | 7 | 8 | 46 |
47 | 48 | 49 | --------------------------------------------------------------------------------