{"id":112,"date":"2019-11-08T16:51:37","date_gmt":"2019-11-08T15:51:37","guid":{"rendered":"http:\/\/localhost\/CvWebsite\/?p=112"},"modified":"2020-12-15T16:16:19","modified_gmt":"2020-12-15T15:16:19","slug":"genetic-algorithm-doodle-jump","status":"publish","type":"post","link":"https:\/\/oussamaameur.fr\/index.php\/2019\/11\/08\/genetic-algorithm-doodle-jump\/","title":{"rendered":"Genetic Algorithm : Doodle Jump"},"content":{"rendered":"\n<div class=\"wp-block-cover alignfull has-background-dim has-parallax\" style=\"background-image:url(https:\/\/oussamaameur.fr\/wp-content\/uploads\/2020\/02\/photo-1515879218367-8466d910aaa4.jpeg);min-height:679px\"><div class=\"wp-block-cover__inner-container\">\n<p class=\"has-text-align-center has-huge-font-size\">Genetic Algorithm : Doodle Jump<\/p>\n<\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:#cbcbcb\">The project consists of 2 main components: A minimalist Doodle Game type of game, playable by the user as well as by a genetic algorithm. The latter must improve the performance of a bot each new game.<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-8001b618\"><h2 class=\"uagb-heading-text\">Game Description<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<p class=\"has-text-color\" style=\"color:#dcdcdc\">Doodle jump is a mobile game. The player controls an alien that needs to rise. Thus, he needs to bounce from platform to platform. The character bounces automatically and the player only needs to focus on the direction (left, right, stationary). There\u2019s also enemies and special platforms, but because of a tight schedule, we couldn\u2019t implement them.<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-2ddae15e\"><h2 class=\"uagb-heading-text\">Game Functions<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<p class=\"has-text-color\" style=\"color:#dcdcdc\">We have three commands: Left, Right and Down (landing). We have a mid-air time, after which the player falls down unless he hits a platform to reset his mid-air time. Every time the player reaches a platform, the score increases, and the platform loses its ability to grant points. When the Y-pos of the player equals 0, the player dies.<br>The platforms are generated randomly but they still need to be close to each other to be reachable by the player. When the players reach a certain height, everything scrolls down and platforms that are below a certain height are modified so they reappear at the top. Click <span style=\"color:#5dace1\" class=\"has-inline-color\"><a href=\"https:\/\/oussamaameur.fr\/index.php\/2020\/12\/15\/code-from-my-doodle-jump-genetic-algorithm\/#Game_Functions\" class=\"ek-link\">here <\/a><\/span>to see a sample of the code<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-dbf15dab\"><h2 class=\"uagb-heading-text\">Genome<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<p class=\"has-text-color\" style=\"color:#cbcbcb\">We created a 3x3x3 matrix that contains random float numbers [0;1]. They represent the probability of going left, right or down according to the X-position relative to the next platform and the mid-air time left. Click <span style=\"color:#5dace1\" class=\"has-inline-color\"><a href=\"https:\/\/oussamaameur.fr\/index.php\/2020\/12\/15\/code-from-my-doodle-jump-genetic-algorithm\/#Genome\" class=\"ek-link\">here <\/a><\/span>to see a sample of the code.<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-33c51463\"><h2 class=\"uagb-heading-text\">Crossovers and Mutations<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<p class=\"has-text-color\" style=\"color:#cbcbcb\">The crossover function generates a 3x3x3 matrix randomly filled with 0 an d 1 as a mask. It also generates an \u201cinverted\u201d mask by switching the state of each cells (0 to 1; 1 to 0). It then selects the two best players by their scores and applies the mask to them. Therefore, you will have 2 matrixes with blank cells that can merge into one complete gene.<br> The mutation function selects a random part of the gene and changes its value, it has 3 options to pick randomly from: no mutation, slight mutation or complete mutation. Click <span style=\"color:#5dace1\" class=\"has-inline-color\"><a href=\"https:\/\/oussamaameur.fr\/index.php\/2020\/12\/15\/code-from-my-doodle-jump-genetic-algorithm\/#Crossover_Mutations\" class=\"ek-link\">here<\/a> <\/span>to see a sample of the code.<\/p>\n\n\n\n<div class=\"wp-block-uagb-advanced-heading uagb-block-2c0bda41\"><h2 class=\"uagb-heading-text\">Conclusion<\/h2><div class=\"uagb-separator-wrap\"><div class=\"uagb-separator\"><\/div><\/div><p class=\"uagb-desc-text\"><\/p><\/div>\n\n\n\n<p class=\"has-text-color\" style=\"color:#cbcbcb\">Genetic Algorithms are powerful tools for the optimization of a function&#8217;s parameters. However, I think that backing it up with another type of Artificial Intelligence, such as a neural network or reinforcement learning, could help improve the performances even further.<\/p>\n\n\n<p><iframe loading=\"lazy\" width=\"1196\" height=\"673\" src=\"https:\/\/www.youtube.com\/embed\/1bQxCqyLbrw\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Coding a genetic algorithm to beat a minimalist Doodle Jump &hellip; <a href=\"https:\/\/oussamaameur.fr\/index.php\/2019\/11\/08\/genetic-algorithm-doodle-jump\/\" class=\"more-link\"><span class=\"readmore\">Continue reading<span class=\"screen-reader-text\">Genetic Algorithm : Doodle Jump<\/span><\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":2,"_editorskit_typography_data":[],"_editorskit_blocks_typography":"","_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}"},"categories":[2],"tags":[6],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false,"my-music-band-archive-top":false,"my-music-band-hero":false,"my-music-band-featured":false,"my-music-band-slider":false,"my-music-band-testimonial":false},"uagb_author_info":{"display_name":"Oussama AMEUR","author_link":"https:\/\/oussamaameur.fr\/index.php\/author\/oussama-ameur\/"},"uagb_comment_info":0,"uagb_excerpt":"Coding a genetic algorithm to beat a minimalist Doodle Jump &hellip; Continue readingGenetic Algorithm : Doodle Jump","_links":{"self":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts\/112"}],"collection":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":20,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":882,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/posts\/112\/revisions\/882"}],"wp:attachment":[{"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oussamaameur.fr\/index.php\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}