App World
My stream
Additionally, paste this code immediately after the opening
tag:This is an app to demonstrate how a genetic algorithm works. It basically consists of a bunch of rockets tha...
Free
This is an app to demonstrate how a genetic algorithm works.
It basically consists of a bunch of rockets that have to reach a goal, avoiding obstacles drawn by the user.
They have to learn the path to follow to win, by trying random directions at the beginning, and then selecting the ones that best fit the solution. They also have to adapt to the changing environment, just like living beings do during the centuries.
Modifying the parameters (the population size, mutation ratio, velocity and lifetime) you can see how they affects the evolution.
How does it work:
Each rocket has a DNA that sets its trajectory (affecting his velocity at every single frame). At the beginning this is randomly generated.
At each following generation, the DNA of the rockets is built from two 'parents' from the previous generation; the chances of a rocket being a parent for the next generation is proportional to various factors: victory, chance of overtaking an obstacle, death, distance to target, etc…
Variables that affect simulation:
- Life time: number of steps allowed to the rocket before dying.
- Mutation ration: every step has that chance to change its initial DNA and take a random direction in that point.
- Number of rockets: the higher the number is the better the system will adapt.
Setting menu:
- Skip generations: disables rendering and executes the simulation at its maximum speed (showing the results in a table or charts)
- Switch to mode: allows to switch from classic to GPU-Accelerated mode and vice versa. Warning: GPU-Accelerated mode is not well supported by all devices, so it may cause errors in the app.
- Reset rockets: reset the rockets state (DNA) to their initial state (without modifying obstacles and target)
- Load/export, Save and Import: with these three buttons you can load/save simulations, or export/import file (.srk) from the device internal memory.
- Other settings: accessible from setting icon on top of the screen or by clicking back button of the device, here you can edit the simulation settings chosen at the app start.
The GPGPU feature:
This app is also developed with Android Renderscript framework, that allows to exploit the GPU advantages in terms of parallel computing. Unfortunately it isn't well supported on all devices, so it might not work well; in that case use the classic mode only.
How does it work? The tasks to execute on each rocket are done in parallel on the GPU, whose architecture is designed to deal with many tasks at the same time (just think about an image rendering, every pixel of that image has to be evaluated individually).
Genetic algorithms normally have nothing to to with graphics, but their nature fits well with parallel computing: they are an example of a particularly successful implementation of GPGPU (Generic Programming on Graphics Processing Unit)
Saving files:
The latest version uses binary files instead of plain text, that allows to reduce up to ten times the memory used and the read/write time; you will still be able to load files (not export) from old versions.
Exported files are saved in default directory SmartRockets in the root of the internal storage. We tried several file managers and you should be able to load a .srk file just clicking on it (even from Google Drive, WhatsApp or Telegram, etc...) or selecting our app in the list displayed. The only one that gave us some problems is "My Files" from Samsung, which some times didn't open the files without even showing the option "open with"; in that case you can upload to Google Drive or open it through another file manager.
Last update
Feb. 28, 2020