Code Monkey home page Code Monkey logo

algorithmics-project's Introduction

The Mysterious Jaak

HTML5 arcade game showing Particle Swarm Optimization algorithm in practice. Built with Phaser for MTAT.03.238 Advanced Algorithmics course project at University of Tartu.

Getting started

Clone and open index.html in browser.

git clone https://github.com/kopylash/algorithmics-project.git

Or play here.

Algorithm

PSO is a population based stochastic optimization technique which simulates the social behavior of species in nature. A good example is a flock of birds or school of fish. PSO is initialized with a group of random particles (solutions) and then searches for optima by updating generations. All particles try to optimize fitness function. They explore solution space moving to the current known optimum. In every iteration, each particle velocity is recalculated based on two "best" values. The first one is the best fitness achieved by particle itself. This value is called pbest. Second one is the best fitness achieved by swarm in total, called gBest. It represents the concept of shared memory in population. After finding these two values, particle updates its velocity and positions with following equations (a) and (b).

a) v[] = v[] + c1 * rand() * (pbest[] - present[]) + c2 * rand() * (gbest[] - present[])
b) present[] = persent[] + v[]

v[] is the particle velocity, persent[] is the current particle position (solution). pbest[] and gbest[] are defined as stated before. rand() is a random number between (0,1). c1, c2 are learning factors. usually c1 = c2 = 2. Particles' velocities on each dimension are clamped to a maximum velocity Vmax. If the sum of accelerations would cause the velocity on that dimension to exceed Vmax, which is a parameter specified by the user. Then the velocity on that dimension is limited to Vmax.

PSO examples

Game

Game

The game tells us the story of young Jaak. Because of the global laziness, students transformed into baddies. Only Jaak can save the situation, but he has to get the Ph.D first. Students don't want this to happen so they are trying to catch him (using Particle Swarm Optimization) and make Jaak lazy. The game consists of two phases: getting of the Ph.D and saving of the world.

First mode PSO in action

Second mode Baddies escape following the maximum distance greedy algorithm

Credits

A lot of assets taken from different resources related to game development.

Thanks for inspirations to Cult of the Party Parrot, Sabaton and sleepless nights.

Univerity of Tartu logo

algorithmics-project's People

Contributors

kopylash avatar artemzajtsev avatar vleno avatar

Stargazers

Vaibhav Raj avatar

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.