Code Monkey home page Code Monkey logo

ai-learns-to-sail's Introduction

AI Learns to Sail

Code for the blog post "AI learns to sail upwind" on the ML&Neuro Blog.

channel results

A Q-learning implementation using average reward of the sailing upwind task. Tackles two tasks: open sea and sailing in the channel. The open sea just requires to select the appropriate angle to sail along. The channel task requires the agent to learn how to tack.

Demo

A live demo is available at DEMO.

Install

Clone the project.

git clone https://github.com/PPierzc/ai-learns-to-sail.git

open the cloned repository in a terminal

Tasks

There are currently 2 tasks: sailing in the open sea and in a channel. In both tasks the goal is to reach as far upwind as possible.

Open Sea

The first task is sailing on the open sea. Here you can go wherever you want since there are no obstacles. Below is a visualization of the task. Blue lines show random trajectories, while the black shows a converged trajectory.

open sea results

Run open sea task

To run the task execute:

python3 ./tasks/open_sea.py

You should get something like the result below.

Running: Random agent on open sea task: 100%|██████████| 100/100 [00:00<00:00, 275.73it/s]
Running: Train agent on open sea task: 100%|██████████| 500/500 [00:07<00:00, 67.93it/s]
Results from last 100 episodes
| ===== agent ===== | ===== mean ===== | ===== std ===== |
| Random            | 52.52            | 35.16           |
| Trained           | 107.89           | 10.36           |

Channel

The second task involves sailing in a tight channel. Following a straight line is no longer the optimal solution as it would lead to a crash with a side pier. Instead the agent has to learn how to tack to avoid getting destroyed.

Below you will find a visualisation of the task along with a random solution (blue) and an optimal solution (black).

channel results

Run channel task

To run the task execute:

python3 ./tasks/channel.py

You should get something like the result below.

Running: Random agent on channel sea task: 100%|██████████| 100/100 [00:00<00:00, 602.28it/s]
Running: Train agent on channel sea task: 100%|██████████| 1000/1000 [00:11<00:00, 86.73it/s]
Results from last 100 episodes
| ===== agent ===== | ===== mean ===== | ===== std ===== |
| Random            | 19.86            | 11.88           |
| Trained           | 63.94            | 19.47           |

License

Distributed under the MIT License

Contribution and Ideas

If you have any cool ideas that you think this agent should try then share them as an issue or create a pull request.

ai-learns-to-sail's People

Contributors

ppierzc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ai-learns-to-sail's Issues

Help us build an AI that wins races.

Hi Pawel,

I thought you may be interested in collaborating with me and a few other folks (with relevant GitHub repos) to build an AI that can win races. I left Google to work with some famous sailors (Stan Honey, Steve Benjamin, etc.) building out a sailing data platform. We have the largest data set of sailing races on earth and are building a platform to open it up to everyone. It’s billions of positions for hundreds of thousands of races across everything from numerous Vendée Globes to casual dinghy races. It's about 1tb of just position/timestamp data dating back the last 20 years. We also have terabytes of weather and sea state data for those races. I am finishing up the process now of converting the weather data to Zarr and writing routines to use it in Dask. I also have all 40k ORC polars. My vision is this: every race ever, with every polar ever and all weather data, all accessible in a RAPIDS Jupiter lab notebook with Dask accelerated routing and industry standard ML libraries. I am pretty close to that now, but I need help with the next step. What I find very interesting is, once we have this environment, can we build an AI agent who wins races? I’ve also been thinking about how we can integrate this with OpenAI Gym. The goal would be to train the agent and then compete in the races following the decisions of the agent and make everything open source. Anyway, let me know if you’re interested or want to hear more. My organization has aws budget and I can spin something up and give you and others access including possibly a small hpc cluster.

Jon

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.