{"id":13570237,"url":"https://github.com/LambdaHack/LambdaHack","last_synced_at":"2025-04-04T06:32:09.974Z","repository":{"id":1097312,"uuid":"956452","full_name":"LambdaHack/LambdaHack","owner":"LambdaHack","description":"Haskell game engine library for roguelike dungeon crawlers; please offer feedback, e.g., after trying out the sample game with the web frontend at","archived":false,"fork":false,"pushed_at":"2024-03-18T07:37:59.000Z","size":37339,"stargazers_count":625,"open_issues_count":108,"forks_count":55,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-12-06T21:53:42.140Z","etag":null,"topics":["ascii","browsergame","engine","freesoftware","game","gamedev","haskell","html5","indiedev","library","pcg","replayability","roguelike","sdl","squad","tactical","turnbased"],"latest_commit_sha":null,"homepage":"https://lambdahack.github.io","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LambdaHack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2010-10-02T12:59:47.000Z","updated_at":"2024-11-17T09:44:54.000Z","dependencies_parsed_at":"2024-11-05T02:32:48.161Z","dependency_job_id":"a0af332a-a0f0-4308-8a7b-648f798e3ca0","html_url":"https://github.com/LambdaHack/LambdaHack","commit_stats":{"total_commits":12523,"total_committers":21,"mean_commits":596.3333333333334,"dds":0.03026431366286031,"last_synced_commit":"4a6eca154360e6d2becb83704891170be4d3f8c3"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LambdaHack%2FLambdaHack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LambdaHack%2FLambdaHack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LambdaHack%2FLambdaHack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LambdaHack%2FLambdaHack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LambdaHack","download_url":"https://codeload.github.com/LambdaHack/LambdaHack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247134855,"owners_count":20889409,"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":["ascii","browsergame","engine","freesoftware","game","gamedev","haskell","html5","indiedev","library","pcg","replayability","roguelike","sdl","squad","tactical","turnbased"],"created_at":"2024-08-01T14:00:49.991Z","updated_at":"2025-04-04T06:32:04.956Z","avatar_url":"https://github.com/LambdaHack.png","language":"Haskell","readme":"LambdaHack\n==========\n\n[![Hackage](https://img.shields.io/hackage/v/LambdaHack.svg)](https://hackage.haskell.org/package/LambdaHack)\n[![Join the chat at Discord](https://img.shields.io/discord/688792755564052486.svg?label=chat%20on%20Discord\u0026logo=discord\u0026logoColor=ffffff\u0026color=7389D8\u0026labelColor=6A7EC2)](https://discord.gg/87Ghnws)\n[![Join the chat at Matrix](https://img.shields.io/matrix/lambdahack:mozilla.org.svg?label=chat%20on%20Matrix\u0026logo=matrix\u0026server_fqdn=mozilla.modular.im)](https://matrix.to/#/#lambdahack:mozilla.org)\n\nLambdaHack is a Haskell[1] game engine library for ASCII roguelike[2]\ngames of arbitrary theme, size and complexity, with optional\ntactical squad combat. It's packaged together with a sample\ndungeon crawler in a quirky fantasy setting. The sample game can be\ntried out in the browser at http://lambdahack.github.io.\n\nAs an example of the engine's capabilities, here is a showcase\nof shooting down explosive projectiles. A couple were shot down close\nenough to enemies to harm them. Others exploded closer to our party members\nand took out of the air the projectiles that would otherwise harm them.\nActual in-game footage.\n\n![gameplay screenshot](https://raw.githubusercontent.com/LambdaHack/media/master/screenshot/allureofthestars.com.shooting.down.explosives.gif)\n\nThis was a semi-automatic stealthy speedrun of the escape scenario\nof the sample game, native binary, SDL2 frontend, single tiny\nbitmap font. The enemy gang has a huge numerical and equipment\nsuperiority. Our team loots the area on auto-pilot until the first foe\nis spotted. Then they scout out enemy positions. Then hero 1 draws\nenemies and unfortunately enemy fire as well, which is when he valiantly\nshoots down explosives to avoid the worst damage. Then heroine 2 sneaks\nbehind enemy lines to reach the remaining treasure. That accomplished,\nthe captain signals retreat and leaves for the next area (the zoo).\n\n\nUsing the engine\n----------------\n\nTo use the engine, you need to specify the content to be\nprocedurally generated. You declare what the game world\nis made of (entities, their relations, physics and lore)\nand the engine builds the world and runs it.\nThe library lets you compile a ready-to-play game binary,\nusing either the supplied or a custom-made main loop.\nA couple of frontends are available (SDL2 is the default\nfor desktop and there is a JavaScript browser frontend)\nand many other generic engine components are easily overridden,\nbut the fundamental source of flexibility lies in the strict\nand enforced with types separation of engine code from the read-only\ncontent and of clients (human and AI-controlled) from the server.\n\nPlease see the changelog file for recent improvements\nand the issue tracker for short-term plans. Long term goals\ninclude multiplayer tactical squad combat, in-game content\ncreation, auto-balancing and persistent content modification\nbased on player behaviour. Contributions are welcome.\nPlease offer feedback to mikolaj.konarski@funktory.com or, preferably,\non any of the public forums.\n\nGames from different repos known to use the LambdaHack library:\n\n* Allure of the Stars[6], a near-future Sci-Fi game\n\nNote: the engine and the LambdaHack sample game are bundled together\nin a single Hackage[3] package released under the permissive `BSD3` license.\nYou are welcome to create your own games by forking and modifying\nthe single package, but please consider eventually splitting your changes\ninto a separate content-heavy package that depends on the upstream\nengine library. This will help us exchange ideas and share improvements\nto the common codebase. Alternatively, you can already start the development\nin separation by cloning and rewriting Allure of the Stars[10]\nand mix and merge with the sample LambdaHack game rules at will.\nNote that the LambdaHack sample game derives from the Hack/Nethack visual\nand narrative tradition[9], while Allure of the Stars uses the more free-form\nMoria/Angband style (it also uses the AGPL license, and BSD3 + AGPL = AGPL,\nso make sure you want to liberate your code and content to such an extent).\n\n\nInstallation of the sample game from binary archives\n----------------------------------------------------\n\nThe game runs rather slowly in the browser (fastest on Chrome) and you are\nlimited to the square font for all purposes, though it's scalable.\nAlso, savefiles are prone to corruption on the browser,\ne.g., when it's closed while the game is still saving progress\n(which takes a long time). Hence, after trying out the game,\nyou may prefer to use a native binary for your architecture, if it exists.\n\nPre-compiled game binaries are available through the release page[11]\n(and Linux dev versions from GitHub Actions[18] and Windows from AppVeyor[19]).\nTo use a pre-compiled binary archive, unpack it and run the executable\nin the unpacked directory or use program shortcuts from the installer,\nif available. On Linux, make sure you have the SDL2 libraries installed\non your system (e.g., libsdl2-2.0-0 and libsdl2-ttf-2.0-0 on Ubuntu).\nFor Windows (XP no longer supported), the SDL2 and all other needed libraries\nare included in the game's binary archive.\n\n\nScreen and keyboard configuration\n---------------------------------\n\nThe game UI can be configured via a config file.\nThe default config settings, the same that are built into the binary,\nare on github at [GameDefinition/config.ui.default](https://github.com/LambdaHack/LambdaHack/blob/master/GameDefinition/config.ui.default).\nWhen the game is run for the first time, or whenever the config file\nis deleted, the file is written to the default user data location,\nwhich is `~/.LambdaHack/` on Linux,\n`C:\\Users\\\u003cusername\u003e\\AppData\\Roaming\\LambdaHack\\`\n(or `C:\\Documents And Settings\\user\\Application Data\\LambdaHack\\`\nor something else altogether) on Windows\nand `Inspect/Application/Local Storage` under RMB menu\nwhen run inside the Chrome browser.\nIf the user config file is outdated or corrupted, it's automatically\nmoved away together with old savefiles. At the next game start,\nthe new default config file appears at its place.\n\nScreen fonts and, consequently, window size can be changed by editing\nthe config file in the user data folder. The default bitmap font\n`16x16xw.bdf` used for the game map covers most national characters\nin the Latin alphabet (e.g. to give custom names to player characters)\nand results in a game window of exactly 720p HD dimensions. The `8x8xb.fnt`\nbitmap font results in a tiny window and covers latin-1 characters only.\nThe config file parameter `allFontsScale` permits further window size\nadjustments, automatically switching to the scalable version of the large\ngame map font (`16x16xw.woff`). Config file option `chosenFontset` governs\nnot only the main game map font, but also the shape of the rectangular fonts,\nif any, in which longer texts are overlaid over the map.\n\nFor high resolution displays and/or if fullscreen mode is requested\nin the configuration file, `allFontsScale` needs to be set.\nE.g., scale 3 works for 4K displays. Otherwise, the letters may be\ntoo small or, in fullscreen or on retina displays in OS X,\nthe screen may be automatically scaled as a whole, not each letter\nseparately, softening letter edges of the square fonts that should\nrather be pixel-perfect and crisp.\n\nIf you don't have a numeric keypad, you can use the left-hand movement\nkey setup (axwdqezc) or Vi editor keys (aka roguelike keys) or mouse.\nIf numeric keypad doesn't work, toggling the Num Lock key sometimes helps.\nIf running with the Shift key and keypad keys doesn't work,\ntry the Control key instead. The game is fully playable with mouse only,\nas well as with keyboard only, but the most efficient combination\nmay be mouse for menus, go-to, inspecting the map, aiming at distant\npositions and keyboard for everything else.\n\nIf you run the ANSI terminal frontend (`--frontendANSI` on commandline),\nthen numeric keypad (especially keypad `*`, `/` and `5`) may not work\ncorrectly, depending on the terminal emulator you use. Toggling\nthe Num Lock key may help or make issues worse. As a work around\nthese issues, numbers are used for movement in the ANSI frontend,\nwhich sadly prevents the number keys from selecting heroes.\nThe commands that require pressing Control and Shift together won't work\neither, but fortunately they are not crucial to gameplay.\n\nSome effort went into making the ANSI frontend usable with screen readers,\nbut without feedback it's hard to say how accessible that setup is.\nThis doesn't work on Windows, due to extra code that would be required.\nAs a side effect of screen reader support, there is no aiming line\nnor path in ANSI frontend and some of map position highlighting\nis performed using the terminal cursor. Screen readers may also work\nbetter with animations turned off, using `--noAnim` or the corresponding\nconfig file or main game menu options.\n\n\nCompilation of the library and sample game from source\n------------------------------------------------------\n\nTo compile with the standard frontend based on SDL2, you need the SDL2\nlibraries for your OS. On Linux, remember to install the -dev versions\nas well, e.g., libsdl2-dev and libsdl2-ttf-dev on Ubuntu Linux 16.04.\nCompilation to JavaScript for the browser is more complicated\nand requires the ghcjs[15] compiler and optionally the Google Closure\nCompiler[16].\n\nThe latest official version of the LambdaHack library can be downloaded,\ncompiled for SDL2 and installed automatically using the 'cabal' tool,\nwhich may already be a part of your OS distribution, but if it's too old\n(version 3.4 or later is required) you can download the whole current\ncompilation suite as described at https://www.haskell.org/downloads/.\nYou can get and run the LambdaHack package from Hackage[3] as follows\n\n    cabal update\n    cabal install LambdaHack\n    ~/.cabal/bin/LambdaHack\n\nFor a newer snapshot, clone the source code from github[5]\nand run `cabal run LambdaHack` from the main directory.\nAlternatively, if you'd like to develop in this codebase,\nthe following speeds up the turn-around a lot\n\n    cp cabal.project.local.development cabal.project.local\n\nand then you can compile (and recompile) with\n\n    cabal build\n\nand run the game with\n\n    make play\n\nThe SDL2 frontend binary also contains the ANSI terminal frontend\n(`--frontendANSI` on commandline) intended for screen readers\nand a simplified black and white line terminal frontend (`--frontendTeletype`)\nsuitable for teletype terminals or a keyboard and a printer (but it's going\nto use a lot of paper, unless you disable animations with `--noAnim`).\nThe teletype frontend is used in CI and for some tests and benchmarks defined\nin Makefile. The terminal frontends leave you on your own regarding font\nchoice and color setup and you won't have the colorful squares outlining\nspecial positions that exist in the SDL2 frontend, but only crude\ncursor highlights. The terminal frontends should run on Windows,\nbut Windows disables console for GUI applications, so they don't.\n\n\nTesting and debugging\n---------------------\n\nUnit tests and integration tests can be run and displayed with\n\n    cabal test --test-show-details=direct\n\nand doctests with\n\n    cabal install doctest --overwrite-policy=always \u0026\u0026 cabal build\n    cabal repl --build-depends=QuickCheck --with-ghc=doctest definition\n    cabal repl --build-depends=QuickCheck --build-depends=template-haskell --with-ghc=doctest lib:LambdaHack\n\nThe [Makefile](https://github.com/LambdaHack/LambdaHack/blob/master/Makefile)\ncontains many sample automated playtest commands.\nNumerous tests that use the screensaver game modes (AI vs. AI)\nand the teletype frontend are gathered in `make test-locally`.\nSome of these are run by CI  on each push to github.\nTest commands with prefix `frontend` start AI vs. AI games with\nthe standard SDL2 frontend to view them on.\n\nRun `LambdaHack --help` to see a brief description of all debug options.\nOf these, the `--sniff` option is very useful (though verbose\nand initially cryptic), for displaying the traffic between clients\nand the server. Some options in the config file may prove useful\nfor debugging too, though they mostly overlap with commandline options\n(and will be totally merged at some point).\n\n\nCoding style\n------------\n\nStylish Haskell is used for slight auto-formatting at buffer save; see\n[.stylish-haskell.yaml](https://github.com/LambdaHack/LambdaHack/blob/master/.stylish-haskell.yaml).\nAs defined in the file, indentation is 2 spaces wide and screen is\n80-columns wide. Spaces are used, not tabs. Spurious whitespace avoided.\nSpaces around arithmetic operators encouraged.\nGenerally, relax and try to stick to the style apparent in a file\nyou are editing. Put big formatting changes in separate commits.\n\nCI checks the code with `hlint .` using the very liberal configuration file at\n[.hlint.yaml](https://github.com/LambdaHack/LambdaHack/blob/master/.hlint.yaml).\nIf hlint is still too naggy, feel free to add more exceptions.\n\nHaddocks are provided for all module headers and for all functions and types\nfrom major modules, in particular for the modules that are interfaces\nfor a whole directory of modules. Apart of that, only very important\nfunctions and types are distinguished by having a haddock.\nIf minor ones have comments, they should not be haddocks\nand they are permitted to describe implementation details and be out of date.\nPrefer assertions instead of comments, unless too verbose.\n\nThe 'pointman' from game manual and UI is called 'leader' in the source code\nand there are a few more mismatches, though the source code naming\nand the UI naming should each be consistent in separation.\nIf the UI names stick, perhaps source code will be renamed at some point.\n\nThis codebase is an experiment in extensive use of states without lens.\nSo far, it works, doesn't result in much larger files or lots\nof repetition and has the added benefits that newcomers don't need\nto learn any optics library. Record punning, etc., definitely help.\n\n\nFirst steps reading the codebase\n--------------------------------\n\nA good start may be\n\nhttps://github.com/LambdaHack/LambdaHack/blob/master/GameDefinition/game-src/Client/UI/Content/Input.hs\n\nThat's where keyboard keys are assigned commands, help texts and categories\n(including special categories indicating that a group of keys\nalso forms an in-game menu). This file is specific to a particular game\n(hence `GameDefinition` in the path) and the engine dynamically creates\nin-game help screens based on this file and on player config file\nthat can partially overwrite it.\n\nThe commands assigned to keys are interpreted by the UI client\n(each faction in the game uses a client and the player's client additionally\nhas UI capabilities) in the following module:\n\nhttps://github.com/LambdaHack/LambdaHack/blob/master/engine-src/Game/LambdaHack/Client/UI/HandleHumanM.hs\n\nBy this point you've seen one of the six major command sets (`HumanCmd`,\nthe others being `Effect`, `UpdAtomic`, `Request`, `Response`, `FrontReq`)\nand one of around ten distinct interpreters for the commands\n(mostly in `Handle*` modules). You've also seen a bit of the UI\nclient code, but not the AI client nor the server (game arbiter) code.\nThe wiki[17] contains not entirely outdated further reading about\nthe client-server architecture.\n\nAt this point, before trying to grasp anything more and drown in abstraction,\nyou are welcome to pick up a few `good first issue`-labeled tickets\nand get some hands-on experience with the codebase.\n\nFor further study, note that most of the commands are interpreted in monads.\nServer and clients share some of the customized monadic API, but their\nmonads are implemented differently (in `*Implementation` modules).\nAll these monads are state monads (managing different aspects of game state),\ntherefore the semantics of a command is a state transformer with extra\nside effects (e.g., frontend drawing).\n\nThe \"main loop\" is the following: the UI client receives keystrokes\nand interprets the commands they correspond to. As soon as one of the commands\nis not just local UI manipulation, but a request to change the main game state,\nsuch a request is packaged and sent to the server (e.g., a request\nto move a hero to the north). The server responds \"not possible,\nthere is a wall\" or reacts by sending to clients (to all UI and AI clients\nthat can see the event) a series of game state-changing responses.\nAI clients, likewise, send to the server requests, generated based\non the perceived game state changes and the AI goals of each AI faction.\n\n\nFurther information\n-------------------\n\nFor more information, visit the wiki[4]\nand see [PLAYING.md](https://github.com/LambdaHack/LambdaHack/blob/master/GameDefinition/PLAYING.md),\n[CREDITS](https://github.com/LambdaHack/LambdaHack/blob/master/CREDITS)\nand [COPYLEFT](https://github.com/LambdaHack/LambdaHack/blob/master/COPYLEFT).\n\nHave fun!\n\n\n\n[1]: https://www.haskell.org/\n[2]: http://roguebasin.roguelikedevelopment.org/index.php?title=Berlin_Interpretation\n[3]: https://hackage.haskell.org/package/LambdaHack\n[4]: https://github.com/LambdaHack/LambdaHack/wiki\n[5]: https://github.com/LambdaHack/LambdaHack\n[6]: http://allureofthestars.com\n[9]: https://github.com/LambdaHack/LambdaHack/wiki/Sample-dungeon-crawler\n[10]: https://github.com/AllureOfTheStars/Allure\n[11]: https://github.com/LambdaHack/LambdaHack/releases\n[15]: https://github.com/ghcjs/ghcjs\n[16]: https://www.npmjs.com/package/google-closure-compiler\n[17]: https://github.com/LambdaHack/LambdaHack/wiki/Client-server-architecture\n[18]: https://github.com/LambdaHack/LambdaHack/actions\n[19]: https://ci.appveyor.com/project/Mikolaj/lambdahack\n","funding_links":[],"categories":["Haskell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLambdaHack%2FLambdaHack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLambdaHack%2FLambdaHack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLambdaHack%2FLambdaHack/lists"}