January 2019
Intermediate to advanced
236 pages
5h 41m
English
You can code this in JavaScript and display the routes with the HTML canvas. You can reuse the HMTL here. Add an input checkbox to decide if all the ants start in the same place, like this:
| | <input name="middle_start" id="middle_start" type="checkbox"> |
| | Start in middle? |
| | </input> |
The button calls init so you can set up your ACO, or stop if it is already running. Use the checked property to decide where to start, then begin:
| | var id = 0; |
| | var middle_start = false; |
| | |
| | function init() { |
| | if (id === 0) { |
| | document.getElementById("click_draw").innerHTML="stop"; |
| | var opt = document.getElementById("middle_start"); |
| | if (opt) { |
| | middle_start = opt.checked; |
| | } |
| | begin(); ... |
Read now
Unlock full access