# 𧬠Self-Parking Car Evolution
Training the car to do self-parking using a genetic algorithm.
> - ð [Launch the demo](https://trekhleb.dev/self-parking-car-evolution)
> - ð [Read about how it works](https://trekhleb.dev/blog/2021/self-parking-car-evolution/)
[![Self-Parking Car Evolution](./public/site-meta-image-02.jpg)](https://trekhleb.dev/self-parking-car-evolution)
This is an experimental project with the aim to learn the basics of how [genetic algorithm](https://en.wikipedia.org/wiki/Genetic_algorithm) works by teaching the cars to do the self-parking. The evolution process is happening directly in the browser. You may check the [evolution source-code](https://github.com/trekhleb/self-parking-car-evolution/tree/master/src/libs) (in TypeScript) or read the [explanation of how it works](https://trekhleb.dev/blog/2021/self-parking-car-evolution/) in my blog-post.
**At the beginning of the evolution** the generation of cars has random genomes which make them behave something like this:
![Self-parking cars at the beginning of the evolution](./public/01-cars-before-01.gif)
**On the 40th generation** the cars start learning what the self-parking is and start getting closer to the parking spot (although hitting the other cars along the way):
![Self-parking car in ](./public/02-car-after-01.gif)
Another example with a bit more challenging starting point:
![Self-parking car in ](./public/02-car-after-03.gif)
## Genetic Source-Code
The `â92%` of the code in this repository relates to the UI logic (3D simulation of the cars world, form controls for the evolution training process, etc.).
However, the actual [code that implements a genetic algorithm](https://github.com/trekhleb/self-parking-car-evolution/tree/master/src/libs) takes less than `<500` lines of code.
## Development Details
The project is a [React](https://create-react-app.dev/) application written on TypeScript. Styled with [BaseWeb](https://baseweb.design/).
The 3D world simulation is made with [Three.js](https://threejs.org/) library using [@react-three/fiber](https://github.com/pmndrs/react-three-fiber) wrapper. The physics is simulated with [Cannon.js](https://github.com/schteppe/cannon.js) using [cannon-es](https://github.com/pmndrs/cannon-es) wrapper.
The whole evolution simulation is happening directly in the browser.
To launch the project, fork/clone it and run the following commands:
```shell
npm install
npm run start
```
The website will be available on `http://localhost:3000/self-parking-car-evolution`.
**Hints:**
- You may upload one of the [pre-trained checkpoints](https://github.com/trekhleb/self-parking-car-evolution/tree/master/src/checkpoints) to avoid starting the evolution from scratch.
- Use the `?debug=true` URL param to see the FPS performance monitor and debugging logs in the console (i.e. `http://localhost:3000/self-parking-car-evolution?debug=true`).
- Training progress is being saved to the local storage for each generation (not for each batch/group).
快撑死的鱼
- 粉丝: 2w+
- 资源: 9156
最新资源
- 2kw, 2.4kw, 3.6kw全系列双向储能电源解决方案,c语言源代码仿真,电池充电1200w, 离网逆变2kw,并网逆变2kw,全程工作最优模式
- 基于comsol的高频振动击碎微颗粒的乳化仿真 采用较高频率振动,击碎微颗粒,达到均质或其他目的 本模型计算了整个击碎的微观过程 通过comsol的流固耦合和两相流进行计算,合理的设置调试后,可以
- 基于范围选择的多目标进化算法,多目标优化算法程序代码,PESA-II,采用pesa2求解多目标优化问题,求解得到pareto最优解 基于matlab的.m程序,采用模块化编程,便于修改,注释率高,易
- 松下FP-XH PLC程序 旋转上下料机 松下FP-XH系列PLC程序,等输入输出模块 四轴轴脉冲控制伺服电机,绝对定位,真空报警、正负极限位报警、气缸报警,位置控制模式采用数据表设置模式
- 汽车制动盘热仿真分析matlab源代码 可用于不同材料,不同体积汽车制动盘的热性能仿真对比分析 适用于赛道刹车盘热工况,AMS工况热容量仿真分析等
- 转动惯量离线辨识算法仿真 1.模型简介 模型为永磁同步电机伺服控制仿真,采用Matlab R2018a Simulink搭建 模型内主要包含DC直流电压源、三相逆变器、永磁同步电机、采样模块、SVP
- 三菱FX5U系列程序 三菱FX5U程序,FX5U-80MT ES,FX5-16ET ES-H*4共12轴运动控制,FX5-32ET ES等输入输出模块 尺寸检测机 轴JOG,回原点,绝对定
- MATLAB代码:考虑电动汽车负荷随机性的蓄电池容量优化配置 关键词:蓄电池容量优化配置 储能优化配置 中长期配置 并网波动性 参考文档:《不确定环境下并网型光储微电网的容量规划》考虑电动汽车
- MATLAB代码:基于改进萤火虫算法的分布式电源选址定容-IEEE33节点 关键词:改进萤火虫算法 选址定容 分布式电源 参考文档:《基于改进萤火虫算法的分布式电源的选址和定容-史吏》基本复现
- MATLAB代码:基于NSGA-II的风光水多能互补协调优化调度 关键词:NSGA-II算法 多目标优化 水电-光伏多能互补 参考文档:《店主自写文档》基本复现; 仿真平台:MATLAB 主要
- 基于改进鲸鱼优化算法的冷热电联供微网多时间尺度优化调度模型 关键词:改进鲸鱼算法 冷热电联供微网 优化调度 多时间尺度 容量配置 主要内容:代码主要做的是一个冷热电联供微网的优化调度问题,为了优化其
- MATLAB代码:基于遗传算法的电动汽车有序充放电优化 关键词:遗传算法 电动汽车 有序充电 优化调度 参考文档:《精英自适应混合遗传算法及其实现-江建》 MATLAB 利用遗传算法对电动汽车有序
- MATLAB代码:基于MATLAB的三母线高斯赛德尔潮流分析计算 关键词:潮流计算 电力系统 高斯赛德尔迭代法 MATLAB 参考文献+自制详细实验文档 仿真平台:MATLAB 主要内容:潮流计算是判
- STM32 EtherCAT EtherCAT通信,量产伺服驱动器 采用STM32作为主控 支持ethercat从站IO,模拟输入 已实现底层驱动,中断处理,数据通信 包括原理图,源代码,说明文档 已
- 西门子smart 200 rtu方式通讯四台三菱E700变频器资料 硬件:smart plc.三菱E700变频器,mcgs触摸屏(电脑仿真也可) 功能:指针写法,通过modbus rtu方式,实现对
- 模块化多电平变器MMC的pi 无源控制 滑模控制策略实现(交流7kV-直流20kV整流)仿真,三个仿真均为外环pi控制输出稳压20kV,内环分别采用pi 无源控制 滑模控制 单桥臂二十子模块(子模块
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈