birdbot
Train your own flappy bird robot easily
½éÉÜ
´ËÏîÄ¿ÌṩÁËÒ»¸ö¼òÒ׵Ŀò¼ÜÀ´ÑµÁ·flappy bird»úÆ÷ÈË£¬¿ÉÒԺܷ½±ãÔÚ´Ë¿ò¼ÜÉÏѧϰ»ò²âÊÔagentµÄһЩ Ëã·¨¡£
Ìصã
¶ÔÓÎÏ·½øÐÐÁ˼òµ¥µÄ·â×°£¬¿ÉÒԺܷ½±ãµÃµ½ÓÎÏ·µÄ״̬À´¸¨ÖúË㷨ʵÏÖ¡£ ¿ÉÒÔÏÔʾÓÎÏ·½çÃæ·½±ãµ÷ÊÔ£¬Äܹ»¿´µ½Ë㷨ʵÏÖµÄЧ¹û¡£Ò²¿ÉÒÔÑ¡Ôñ¹Ø±ÕÓÎÏ·½çÃæÒÔ¼°ÉùÒô£¬ÕâÑù ÓÎÏ·ÈÔÈ»ÄÜÕý³£ÔËÐУ¬Ò»°ãÓÃÓÚѵÁ·½×¶Î£¬¿ÉÒÔ¼õÉÙCPUµÄÕ¼Óá£
¿ªÊ¼ÑµÁ·×Ô¼ºµÄ»úÆ÷ÈË ×¼±¸
È·ÈÏ°²×°ÁËpython2.7.xºÍpyglet¡£pygletµÄ°²×°Window¿É´ÓÕâÀïÖ±½ÓÏÂÔضþ½øÖÆexeÎļþ°²×°¡£Linux¿É ´Ó¸÷¸ö·¢ÐаæµÄÈí¼þÔ´°²×°£¬ÀýÈçubuntu:
sudo apt-get install python-pyglet
ÈôÈí¼þÔ´ÖÐÕÒ²»µ½£¬¿ÉÒÔ°´ÕâÀïÏÂÔØÔ´´úÂë±àÒë°²×° ʵÏÖÖÇÄÜËã·¨
Ëã·¨´úÂëдÔÚBot.plan()·½·¨ÀBot.plan()·½·¨Ã¿0.05Ãë»á±»µ÷ÓÃÒ»´Î£¬¿ÉÒÔ¸ù¾Ýÿ´Î´«ÈëµÄstateÐÅÏ¢ À´¸¨Öú´Ë´ÎµÄ¾ö²ß¡£ stateÊÇÒ»¸ödict£¬´æ·ÅµÄÊǵ±Ç°µÄÓÎϷ״̬(Ò²¾ÍÊÇÉÏÒ»´ÎÖ´Ðж¯×÷ºóµÄ״̬)¡£¾ßÌåÐÅÏ¢ÈçÏÂ:
state = { ‘bird’: (x, y, bird_state) ,
‘pipes’: [(x0, y0), (x1, y1), … ] }
ÆäÖÐbirdÊÇÄñÏà¹ØÐÅÏ¢£¬x, yÊÇÄñµÄºá×Ý×ø±ê£¬bird_stateΪstring£¬ÈôֵΪ’alive’±íʾÄñ»î×Å£¬’dead’±íʾ ÄñËÀÁË¡£ pipesÊǸ÷¸ö¹ÜµÀµÄλÖã¬ÉϹܵÀµÄλÖÃÓÃ×óϽǵĵã±íʾ£¬Ï¹ܵÀµÄλÖÃÓÃ×óÉϽǵĵã±íʾ£¬¹ÜµÀ´æ ·ÅµÄ˳Ðò°´¡°ÉÏÏÂÉÏÏÂÉÏÏ¡±£¬¼û×îºóÃæµÄͼ¡£ºìµã±íʾ¹ÜµÀλÖã¬Êý×Ö±íʾ˳Ðò¡£ÁíÍâ×¢Òâ×ø±êϵÊÇ´Ó ×óµ½ÓÒ£¬´Óϵ½ÉÏ£¬¼´ÔµãÔÚ×óÏÂ½Ç ÓÉÓÚÓÎÏ·±È½Ï¼òµ¥£¬¿ÉÒÔÖ´ÐеĶ¯×÷Ö»Óеã»÷ÆÁÄ»¡£¿ÉÒÔͨ¹ýµ÷ÓÃself.tap()Ö¸ÁîÀ´µã»÷ÆÁÄ»¡£
Êý¾ÝµÄ±£´æ¼°ÆäËû
ÐèÒªÔÚÕû¸ö³ÌÐòÖ´ÐÐÆÚ¼ä¸üеÄÊý¾Ý¿ÉÒÔ·ÅÔÚBot._init_()·½·¨ÀѵÁ·µÃµ½µÄÊý¾Ý¿ÉÒÔͨ¹ý_init_()·½·¨ ÀïµÄdo_at_exit()±£´æ£¬ÕâÑùѵÁ·Ê±¼ä¹ý³¤»ò³ÌÐò³ö´íʱ¿ÉÒÔ°ÑÊý¾Ý´æÏÂÀ´£¬±ÜÃâ´ÓÍ·¿ªÊ¼ÑµÁ·¡£
ÊÇ·ñÏÔʾ´°¿ÚºÍ²¥·ÅÉùÒô¿ÉÒÔÔÚmainµÄÁ½¸ö±êÖ¾show_windowºÍenable_soundÉèÖᣠÀý×Ó³ÌÐò
´úÂëÀïÓÐÒ»¸öÀý×Ósample_bot.py£¬ÊµÏÖÁËQ-learningËã·¨£¬²Î¿¼µÄÊÇÕâƪÎÄÕÂFlappy Bird hack using Reinforcement Learning¡£±£´æÊý¾ÝµÈÒ²¿ÉÒԲο¼Àý×Ó¡£¿ÉÒÔ¿¼ÂǽáºÏһЩ¹æÔò(ÀýÈçµÍÓÚϸù¹ÜµÀʱ ¾¡Á¿·É¸ß£¬¸ßÓÚʱÔòÄñ½µµÍ¸ß¶ÈµÈ)À´¼Ó¿ìѵÁ·¡£
²Î¿¼×ÊÁÏ
wikipediaµÄÇ¿»¯Ñ§Ï°½éÉÜ
¡¶AI: a modern approach¡·µÄµÚ21ÕÂ