{"id":20574644,"url":"https://github.com/llefranc/42_lem-ipc","last_synced_at":"2026-04-21T14:04:49.988Z","repository":{"id":151135537,"uuid":"595047692","full_name":"llefranc/42_lem-ipc","owner":"llefranc","description":"School projet: create a multiprocessus game using UNIX System V IPC mechanics (shared memory segment, semaphores sets and message queues).","archived":false,"fork":false,"pushed_at":"2023-05-31T15:56:24.000Z","size":1428,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T21:40:22.019Z","etag":null,"topics":["42","42born2code","42paris","42school","interprocess-communication","ipc","lemipc","message-queue","semaphore","shared-memory","shm","system-v"],"latest_commit_sha":null,"homepage":"","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/llefranc.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T09:34:14.000Z","updated_at":"2023-05-31T15:59:08.000Z","dependencies_parsed_at":"2024-05-03T11:52:56.716Z","dependency_job_id":null,"html_url":"https://github.com/llefranc/42_lem-ipc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llefranc%2F42_lem-ipc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llefranc%2F42_lem-ipc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llefranc%2F42_lem-ipc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llefranc%2F42_lem-ipc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llefranc","download_url":"https://codeload.github.com/llefranc/42_lem-ipc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242196023,"owners_count":20087761,"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":["42","42born2code","42paris","42school","interprocess-communication","ipc","lemipc","message-queue","semaphore","shared-memory","shm","system-v"],"created_at":"2024-11-16T05:36:19.504Z","updated_at":"2026-04-21T14:04:48.501Z","avatar_url":"https://github.com/llefranc.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lem-ipc (@42Paris)\n\n\u003e This project was coded for Linux. Here is the [subject][1].\n\u003e\n\n![Alt text](https://github.com/llefranc/42_lem-ipc/blob/main/img/lem-ipc_example.png)\n\n## About\n\nlem-ipc is a little game to understand how mutliple processes can communicate between themselves **using the UNIX System V IPC**.\n\n\u003e System V IPC is the name given to three interprocess communication mechanisms that are widely available on UNIX systems: message queues, semaphore, and shared memory.\n\nThe game consist of a grid filled with players from different teams (maximum 7 different teams), with each team fighting each other and trying to be the last team standing.\n\n## Building and running the project\n\n1. Download/Clone this repo\n\n        git clone https://github.com/llefranc/42_lem-ipc\n\n2. `cd` into the root directory and run `make` or `make debug` for additional logs\n\n        cd 42_lem-ipc\n        make\n\n3. Run several time `lemipc` in different terminals with a team number between 0 and 7\n\n\t\t# Two players in team 1 vs one player in team 2, and the graphic mode\n\t\t./lemipc 1\n\t\t./lemipc 1\n\t\t./lemipc 2\n\t\t./lemipc 0   # graphic mode\n\n\n\n## Modes\n\n\t\t./lemipc [team-number]\n\n`lemipc` can be launch in two different modes : **graphic mode or player mode**.   \n\nThe mode is determinated based on the team number provided as argument.\n\nDuring the game, you will have:\n- one `lemipc` instance for the graphic mode.\n- and x `lemipc` instances for x players alive. \n\n### Graphic mode\n\n\t\t./lemipc 0\n\t\t\nTo launch the graphic mode, you need to run `lemipc` with **0 as team number**.   \n\nThe graphic mode display the grid with the position of each player, and refreshed the grid each time a player mooves.  \n\n- :warning: Only one instance of the graphic mode can run at any time :warning:\n- :warning: The graphic mode must run during the game, otherwise the game ends immediately :warning:  \n\n_graphic mode example_\n\n![Alt text](https://github.com/llefranc/42_lem-ipc/blob/main/img/lem-ipc_graphic_mode_example.png)\n\n### Player mode\n\n\t\t./lemipc [1-7]\n\nTo launch the player mode, you need to run `lemipc` with **a team number between 1 and 7**.  \n\nThe player is automatically mooved on the grid when it's it turn based on a very simple IA.\n\n_player mode example_\n\n![Alt text](https://github.com/llefranc/42_lem-ipc/blob/main/img/lem-ipc_player_mode_example.png)\n\n## Lobby\n\nWhen launching the first instance of `lemipc`, this one will init the shared ressources and init a starting time.  \n\nA timer will then be displayed, and other `lemipc` instances **can joined the game during this time**.  \n\nThe game is **launched when the timer reaches 0**. At this point, no other instances will be able to join the game.\n\n\u003e The waiting time is defined with the macroconstant `SEC_START_TIME` in `game_utils.h`. You can change this value to increase or decrease the lobby waiting time.\n\n## Game rules\n\nThe game is designed based on the following rules:\n\n- ➡️ Each player is represented by its team number on the grid.\n- ➡️ Each second a player mooves.\n- ➡️ A player can move only on an empty tile.\n- ➡️ A player can move only in 4 directions (up, down, left and right).\n- ➡️ A player can move several times in a row.\n- ➡️ You cannot differentiate players from the same team on the grid.\n- ➡️ All the players of a same team target all together the same ennemy player.\n- ➡️ When two players from the same team surround an ennemy player, this one dies (diagonals works).\n- ➡️ It's mandatory for a player to move when it's its turn, even if it's just next to its target.\n- ➡️ The game stop when only one team is remaining.\n\n## System V mechanics\n\nThe three interprocess communication mechanisms of System V are used the following way:\n\n- `shared memory segment`: contain the map and game datas.\n- `semaphore sets` : secure the access of the shared memory segment.\n- `message queue` : allow the players of a same team to exchange the ennemy player ID to focus.\n\n\u003e **The first instance of `lempic` to be launch will init all the System V ressources; the last instance to exit will destroy all the System V ressources.**\n\n[1]: https://github.com/llefranc/42_lem-ipc/blob/main/lem-ipc.en.subject.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllefranc%2F42_lem-ipc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllefranc%2F42_lem-ipc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllefranc%2F42_lem-ipc/lists"}