{"id":18441683,"url":"https://github.com/globidev/nibbler","last_synced_at":"2025-09-09T08:44:38.042Z","repository":{"id":28342175,"uuid":"31855627","full_name":"Globidev/Nibbler","owner":"Globidev","description":"Yet another snake","archived":false,"fork":false,"pushed_at":"2015-12-31T16:09:14.000Z","size":5585,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T19:47:25.406Z","etag":null,"topics":["extensible","game","libdl","snake"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Globidev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-08T15:57:04.000Z","updated_at":"2023-12-19T17:03:30.000Z","dependencies_parsed_at":"2022-08-22T20:50:46.366Z","dependency_job_id":null,"html_url":"https://github.com/Globidev/Nibbler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Globidev/Nibbler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Globidev%2FNibbler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Globidev%2FNibbler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Globidev%2FNibbler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Globidev%2FNibbler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Globidev","download_url":"https://codeload.github.com/Globidev/Nibbler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Globidev%2FNibbler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264713108,"owners_count":23652723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extensible","game","libdl","snake"],"created_at":"2024-11-06T06:39:07.089Z","updated_at":"2025-07-11T02:34:42.392Z","avatar_url":"https://github.com/Globidev.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nibbler\nYet another snake\n\n![demo](https://cloud.githubusercontent.com/assets/2079561/12066016/1d37cd74-afe1-11e5-9d15-8e7d8e27ac81.gif)\n\n## Principle\nThis project aims to familiarize with Unix's dynamic library API: `libdl`  \nIn this rework of the famous game [`Snake`](http://www.wikiwand.com/en/Snake_(video_game)), we give to the player the ability to change, in real time, the graphics library used to display the game. This is done by implementing different dynamic libraries which export an interface specialization.  \nThe core of the program will handle the dynamic switching between those implementations:\n\n![Core concept](https://cloud.githubusercontent.com/assets/2079561/12064829/155ed08e-afcd-11e5-836c-265cbf48b672.png)\n\nIt makes this project easily extendable with custom [graphics](https://github.com/Globidev/Nibbler/blob/master/gui/spec.hpp#L46-L59) / [audio](https://github.com/Globidev/Nibbler/blob/master/audio%2Fspec.hpp#L10-L20) implementations (there is also a [network specification](https://github.com/Globidev/Nibbler/blob/master/network%2Fspec.hpp#L36-L65) but it not currently possible to dynamically switch between network libraries).\n\n## Building\nWith docker:\n```sh\ndocker build -t nibbler-builder .\ndocker run --rm -it -v $PWD:/app -w /app nibbler-builder make -j$(nproc)\n```\n\nThen run it with X-Forwarding:\n```sh\nxhost +\ndocker run --rm -it \\\n    -v $PWD:/app \\\n    -w /app \\\n    -e DISPLAY \\\n    -v /tmp/.X11-unix:/tmp/.X11-unix \\\n    --net host \\\n    nibbler-builder ./nibbler\n```\nNote that the use of `--net host` is just to ease the usage for network games\n\n## Usage\nThe following options are available:\n```\n--help                Show this help message\n-w [ --width ] arg    The width of the game arena\n-h [ --height ] arg   The height of the game arena\n-t [ --torus ]        Torus mode\n-o [ --obstacles ]    Add obstacles on the map\n-s [ --snakes ] arg   Number of snakes\n-p [ --players ] arg  Number of players\n--script arg          Python script file for AIs\n--client              Join a multiplayer game\n--server              Host a multiplayer game\n--host arg            The host address of the multiplayer game to join\n--port arg            The port of the multiplayer game to host/join\n```\n\n### AIs\nThe number of snakes (`--snakes`) minus the number of players (`--players`) determines the number of AIs that will be used.  \nAIs are run by python scripts (thanks to [boost python](http://www.boost.org/doc/libs/1_60_0/libs/python/doc/html/index.html)).  \nThere are [four available scripts](https://github.com/Globidev/Nibbler/tree/master/ai) which are currently not very advanced but you can of course roll your own. See the [exposed module](https://github.com/Globidev/Nibbler/blob/master/game%2Fpython%2Fsnake_module.cpp#L16-L51) for more details on how to write AI scripts.\n\n### Network games\nRunning the program with the `--server` flag will only start a TCP server.  \nThe server is responsible for managing the game options and will wait until the number of players specified by `--players` are connected before starting a game.  \nWhen a player leaves prematurely, his snake will be replaced by an AI.  \nAdditional people can also connect to the server in order to *observe* a game.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobidev%2Fnibbler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglobidev%2Fnibbler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglobidev%2Fnibbler/lists"}