gheb / tamagotchi
自学习宠物蛋
Requires
- php: >=7.1.0
- doctrine/doctrine-bundle: ^1.6
- doctrine/doctrine-cache-bundle: ^1.2
- doctrine/doctrine-fixtures-bundle: ^2.3
- doctrine/orm: ^2.5
- gheb/neat-bundle: ^1.0@dev
- incenteev/composer-parameter-handler: ^2.0
- mybuilder/phpunit-accelerator: ^1.1
- sensio/distribution-bundle: ^5.0
- sensio/framework-extra-bundle: ^3.0.2
- stof/doctrine-extensions-bundle: ^1.2
- symfony/assetic-bundle: ^2.8
- symfony/monolog-bundle: ^2.8
- symfony/swiftmailer-bundle: ^2.3
- symfony/symfony: 3.2.*
Requires (Dev)
- covex-nn/phpcb: 1.0.4.1
- pdepend/pdepend: ^2.2
- phpmd/phpmd: ^2.3
- phpunit/phpunit: ^5.1
- sebastian/phpcpd: ^2.0
- sensio/generator-bundle: ^3.0
- squizlabs/php_codesniffer: ^2.4
- symfony/phpunit-bridge: 2.7.x@beta
- symfony/var-dumper: ^4.0
This package is auto-updated.
Last update: 2024-09-28 01:47:10 UTC
README
我的一个同事曾经带着一条鱼来上班。一开始我想,哇,我也需要一个!然后我想到了每天我都不能喂他:( 这就是我开始决定作为副项目构建一个类似宠物蛋项目的时候,并使用AI来决定下一步要做什么。
这个宠物蛋有需要,比如饥饿、困倦,有时还想玩。每一个都会影响它的健康。如果你不照顾它的饮食,不把它放床上去或者和它玩耍,宠物蛋最终会更快地死去。
由于我在动画/绘画方面的技能为零,我使用了一些免费的精灵图。
我本来可以使用tensorflow或phpml,但我想用这个项目来学习它是如何工作的。这个项目是以后在其他项目中重用的结果。
有很多事情我会改变,或者不会像现在这样去做,但这是一个实验性项目。也许我以后会编写一个更好的:)
前端设计用于在800x480的树莓派屏幕上显示,但应适用于任何遵守比例的屏幕。
玩耍
克隆项目或使用composer安装
$ composer create-project gheb/tamagotchi
该项目附带一个数据库的docker文件,以及一个开发compose文件,其中包含adminer,以便在调试时导航数据库。
$ docker-compose up -d
使用adminer
$ docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
然后
$ docker/console doctrine:schema:create $ docker/start
完成时
$ docker/stop $ docker-compose stop
如果您不使用docker,克隆此项目。您需要yarn、composer、mysql、php7.1。然后执行以下命令:
$ composer install $ php bin/console doctrine:schema:create $ cd web && yarn install && yarn run build
然后您需要训练AI。我鼓励您阅读NEAT(增强拓扑结构的神经进化)遗传算法的工作原理。为了创建一批种群并让neat-bundle评估每个基因组以进行学习,运行:
$ docker/console gheb:neat:generate $ php bin/console gheb:neat:generate
这是一个无限循环,会尽力进化一个神经网络并打破分数!
为了获得最佳基因组并根据输入播放其网络,运行:
$ docker/console gheb:neat:evaluate $ php bin/console gheb:neat:evaluate
如果您不使用docker,您可以使用start脚本通过web服务器和websocket运行。
$ php bin/console server:start localhost -p 8000 $ php bin/console gos:web:ser --env=prod
现在您可以启动浏览器并打开 https://:8000
$ chromium-browser --start-fullscreen --start-maximized --no-default-browser-check --incognito https://:8000 &>/dev/null &
要在后台运行所有内容,您需要supervisor
$ sudo apt install supervisor
为程序创建一个配置文件
# /etc/supervisor/conf.d/tamagotchi.conf [program:tamagotchi] # change this with your username user=gregoire # change according to your path command=/home/gregoire/TRAVAUX/PERSO/tamagotchi/start # uncomment these lines to launch this at start #autostart=true #autorestart=true # change according to your path stdout_logfile=/home/gregoire/TRAVAUX/PERSO/tamagotchi/var/logs/supervisor_stdout.log stderr_logfile=/home/gregoire/TRAVAUX/PERSO/tamagotchi/var/logs/supervisor_stderr.log
然后您必须告诉supervisor获取并加载这个新配置。
$ supervisorctl reread $ supervisorctl update $ supervisorctl tamagotchi STOPPED Jan 14 02:33 PM supervisor> #Now, we can start, stop and restart the tamagotchi: supervisor> stop tamagotchi tamagotchi: stopped supervisor> start tamagotchi tamagotchi: started supervisor> restart tamagotchi tamagotchi: stopped tamagotchi: started # You may also view the most recent entries from stdout and stderr logs using tail command: supervisor> tail tamagotchi [OK] Web server listening on http://127.0.0.1:8000 supervisor> tail tamagotchi stderr [2018-01-14 15:34:43] websocket.INFO: Launching Ratchet on 127.0.0.1:1337 PID: 6305 [2018-01-14 15:35:16] websocket.WARNING: User firewall is not configured, we have set ws_firewall by default [2018-01-14 15:35:16] websocket.INFO: anon-9760925065a5b6aa49679d118520908 connected {"connection_id":482,"session_id":"9760925065a5b6aa49679d118520908","storage_id":482} [2018-01-14 15:35:16] websocket.INFO: anon-9760925065a5b6aa49679d118520908 subscribe to output/application [2018-01-14 15:35:18] websocket.INFO: anon-9760925065a5b6aa49679d118520908 disconnected {"connection_id":482,"session_id":"9760925065a5b6aa49679d118520908","storage_id":482,"username":"anon-9760925065a5b6aa49679d118520908"} # Checking program status after making changes is easy as well: supervisor> status tamagotchi RUNNING pid 26039, uptime 0:00:24
问题报告
错误:<class 'socket.error'>,[Errno 13] 权限被拒绝:文件:/usr/lib/python2.7/socket.py 行:228
如果您在启动supervisorctl
命令时收到此消息,请更新/etc/supervisor/supervisor.conf
并将unix_http_server
的chmod更改为766
待办事项
- 定义调用新评估的节奏,并提供一个使用crontab或其他方法的方式。
- 为了演示目的,显示网络的图形。