{"id":13568164,"url":"https://github.com/FaronBracy/RogueSharp","last_synced_at":"2025-04-04T04:30:51.229Z","repository":{"id":40650506,"uuid":"142682282","full_name":"FaronBracy/RogueSharp","owner":"FaronBracy","description":"A .NET Standard class library providing map generation, path-finding, and field-of-view utilities frequently used in roguelikes or 2D tile based games. Inspired by libtcod","archived":false,"fork":false,"pushed_at":"2024-08-03T14:33:20.000Z","size":7598,"stargazers_count":591,"open_issues_count":10,"forks_count":60,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-03-12T20:03:41.500Z","etag":null,"topics":["dice","field-of-view","fog-of-war","game","generator","libtcod","map","pathfinding","random","roguelike"],"latest_commit_sha":null,"homepage":"https://roguesharp.wordpress.com/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FaronBracy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-07-28T14:09:14.000Z","updated_at":"2025-03-12T08:44:49.000Z","dependencies_parsed_at":"2024-06-18T20:12:14.604Z","dependency_job_id":"43a10652-1666-46de-a0ad-8e7007e2505e","html_url":"https://github.com/FaronBracy/RogueSharp","commit_stats":{"total_commits":267,"total_committers":10,"mean_commits":26.7,"dds":0.202247191011236,"last_synced_commit":"22181573e2fcfbd350fbb80ea91c921b325b9524"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaronBracy%2FRogueSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaronBracy%2FRogueSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaronBracy%2FRogueSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FaronBracy%2FRogueSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FaronBracy","download_url":"https://codeload.github.com/FaronBracy/RogueSharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123071,"owners_count":20887259,"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":["dice","field-of-view","fog-of-war","game","generator","libtcod","map","pathfinding","random","roguelike"],"created_at":"2024-08-01T14:00:20.990Z","updated_at":"2025-04-04T04:30:46.218Z","avatar_url":"https://github.com/FaronBracy.png","language":"C#","funding_links":[],"categories":["C# #","C#"],"sub_categories":[],"readme":"[![Tutorials: Github.io](https://img.shields.io/badge/tutorials-github.io-blue.svg)](https://faronbracy.github.io/RogueSharp/articles/01_introduction.html)\n[![Documentation: Github.io](https://img.shields.io/badge/docs-github.io-blue.svg)](https://faronbracy.github.io/RogueSharp/api/index.html)\n[![Posts: Blog](https://img.shields.io/badge/blog_posts-wordpress-blue.svg)](https://roguesharp.wordpress.com/)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/FaronBracy/RogueSharp/master/LICENSE.txt)\n\n[![Build status](https://dreamersdesign.visualstudio.com/RogueSharp/_apis/build/status/RogueSharp%20Continuous)](https://dreamersdesign.visualstudio.com/RogueSharp/_build/latest?definitionId=1) \n[![Build status](https://ci.appveyor.com/api/projects/status/mx09mla59wsgrkkj?svg=true)](https://ci.appveyor.com/project/FaronBracy/roguesharp-20n28) \n[![Nuget](https://buildstats.info/nuget/roguesharp)](https://www.nuget.org/packages/RogueSharp) \n\n[![Test status](https://img.shields.io/azure-devops/tests/dreamersdesign/RogueSharp/1.svg)](https://dreamersdesign.visualstudio.com/RogueSharp/_build/latest?definitionId=1)\n[![Code coverage](https://img.shields.io/azure-devops/coverage/dreamersdesign/RogueSharp/1.svg)](https://dreamersdesign.visualstudio.com/RogueSharp/_build/latest?definitionId=1)\n\n[![Build History](https://buildstats.info/appveyor/chart/FaronBracy/roguesharp-20n28)](https://ci.appveyor.com/project/FaronBracy/roguesharp-20n28/history)\n\n[![RogueSharp with SadConsole](Images/sadconsoleport.png)](https://github.com/FaronBracy/RogueSharpSadConsoleSamples)\n\n- [Sample Game using RogueSharp with SadConsole](https://github.com/FaronBracy/RogueSharpSadConsoleSamples)\n- [Sample Game using RogueSharp with RLNet](https://github.com/FaronBracy/RogueSharpRLNetSamples)\n\n# What is RogueSharp? #\nRogueSharp is a free library written in C# to help [roguelike](http://en.wikipedia.org/wiki/Roguelike \"roguelike\") developers get a head start on their game. RogueSharp provides many utility functions for dealing with map generation, field-of-view calculations, path finding, random number generation and more.\n\nIt is loosely based on the popular [libtcod](http://doryen.eptalys.net/libtcod/ \"libtcod\") or \"Doryen Library\" though not all features overlap.\n\n## Getting Started ##\n1. Visit the [RogueSharp Blog](https://roguesharp.wordpress.com/ \"RogueSharp Blog\") for tips and tutorials.\n2. The quickest way to add RogueSharp to your project is by using the [RogueSharp nuget package](https://www.nuget.org/packages/RogueSharp \"RogueSharp nuget package\"). \n2. If building the assembly yourself, the solution file \"RogueSharp.sln\" contains the main library and unit tests. This should be all you need.\n3. Class documentation is located on [Github Pages](https://faronbracy.github.io/RogueSharp/api/index.html \"RogueSharp class documentation\").\n\n## Features ##\n\n**Pathfinding**\n\nWith or without diagonals\n\n![Pathfinding with Diagonals](Images/diagonalpathfinder.gif)\n```\n/// Constructs a new PathFinder instance for the specified Map \n/// that will consider diagonal movement by using the specified diagonalCost\npublic PathFinder( IMap map, double diagonalCost )\n\n/// Returns a shortest Path containing a list of Cells \n/// from a specified source Cell to a destination Cell\npublic Path ShortestPath( ICell source, ICell destination )\n```\n\n**Cell Selection**\n\nSelect rows, columns, circles, squares and diamonds with and without borders.\n\n![Cell Selection](Images/selection.gif)\n```\n/// Get an IEnumerable of Cells in a circle around the center Cell up \n/// to the specified radius using Bresenham's midpoint circle algorithm\npublic IEnumerable\u003cICell\u003e GetCellsInCircle( int xCenter, int yCenter, int radius )\n  \n/// Get an IEnumerable of outermost border Cells in a circle around the center \n/// Cell up to the specified radius using Bresenham's midpoint circle algorithm\npublic IEnumerable\u003cICell\u003e GetBorderCellsInCircle( int xCenter, int yCenter, int radius )\n```\n\n**Weighted Goal Maps**\n\nSet multiple goals weights for desirability. Add obstacles to avoid.\n\n![Weighted Goal Maps](Images/diagonalgoalmap.gif)\n\n```\n/// Constructs a new instance of a GoalMap for the specified Map \n/// that will consider diagonal movements to be valid if allowDiagonalMovement is set to true.\npublic GoalMap( IMap map, bool allowDiagonalMovement )\n\n/// Add a Goal at the specified location with the specified weight\npublic void AddGoal( int x, int y, int weight )\n\n/// Add an Obstacle at the specified location. Any paths found must not go through Obstacles\npublic void AddObstacle( int x, int y )\n```\n\n**Field-of-View**\n\nEfficient field-of-view calulation for specified distance. Option to light walls or not.\n\n![Field of View](Images/circularfieldofview.gif)\n```\n/// Constructs a new FieldOfView objec for the specified Map\npublic FieldOfView( IMap map )\n\n/// Performs a field-of-view calculation with the specified parameters.\npublic ReadOnlyCollection\u003cICell\u003e ComputeFov( int xOrigin, int yOrigin, int radius, bool lightWalls )\n\n/// Performs a field-of-view calculation with the specified parameters\n/// and appends it any existing field-of-view calculations.\npublic ReadOnlyCollection\u003cICell\u003e AppendFov( int xOrigin, int yOrigin, int radius, bool lightWalls )\n```\n\n## Creating a Map ##\nMost interactions with RogueSharp is based around the concept of a `Map` which is a rectangular grid of `Cells`. \n\nEach `Cell` in a `Map` has the following properties:\n\n- `IsTransparent`: true if visibility extends through the `Cell`.\n- `IsWalkable`: true if a the `Cell` may be traversed by the player\n- `IsExplored`: true if the player has ever had line-of-sight to the `Cell`\n- `IsInFov`: true if the `Cell` is currently in the player's field-of-view\n\nTo instantiate a new `Map` you can use its constructor which takes a width and height and will create a new map of those dimensions with the properties of all `Cells` set to false.\n    \n### Usage ###\n\n\tIMap boringMapOfSolidStone = new Map( 5, 3 );\n\tConsole.WriteLine( boringMapOfSolidStone.ToString() );\n\n### Output ###\n\n\t#####\n\t#####\n\t#####\n\nNotice that the `ToString()` operator is overridden on the `Map` class to provide a simple visual representation of the map. An optional bool parameter can be provided to `ToString()` to indicate if you want to use the field-of-view or not. If the parameter is not given it defaults to false. \n\nThe symbols used are as follows:\n\n- `%`: `Cell` is not in field-of-view\n- `.`: `Cell` is transparent, walkable, and in field-of-view\n- `s`: `Cell` is walkable and in field-of-view (but not transparent)\n- `o`: `Cell` is transparent and in field-of-view (but not walkable)\n- `#`: `Cell` is in field-of-view (but not transparent or walkable)\n\nA more interesting way to create a map is to use the `Map` class's static method `Create` which takes an `IMapCreationStrategy`. Some simple classes implementing `IMapCreationStrategy` are provided with RogueSharp but this is easily extended by creating your own class that implements the strategy.\n\n### Usage ###\n\n\tIMapCreationStrategy\u003cMap\u003e mapCreationStrategy = new RandomRoomsMapCreationStrategy\u003cMap\u003e( 17, 10, 30, 5, 3 )\n\tIMap somewhatInterestingMap = Map.Create( mapCreationStrategy );\n\tConsole.WriteLine( somewhatInterestingMap.ToString() );\n\n### Output ###\n\n\t#################\n\t#################\n\t##...#######...##\n\t##.............##\n\t###.###....#...##\n\t###...##.#####.##\n\t###...##...###..#\n\t####............#\n\t##############..#\n\t#################\n\n## Credits ##\n\n- [Doryen Library (libtcod)](http://doryen.eptalys.net/libtcod/ \"libtcod\")\n\t- This was a big inspiration for RogueSharp\n\t- The main RogueSharp library does not use any source code from libtcod, nor does it reference or depend on the libtcod library\n\t- [libtcod source code](https://bitbucket.org/jice/libtcod/src \"libtcod source code\")\n\t- [libtcod license](https://bitbucket.org/jice/libtcod/src/969e7cfdf44c2a8734957306b456ae0eb29ac8c4/LIBTCOD-LICENSE.txt?at=default \"libtcod license\")\n- [MonoGame](http://www.monogame.net/ \"MonoGame\")\n\t- Similar Point and Rectangle classes are included in RogueSharp that are inspired by MonoGame\n\t- [MonoGame source code](https://github.com/mono/MonoGame \"MonoGame\")\n\t- [MonoGame license](https://github.com/mono/MonoGame/blob/develop/LICENSE.txt \"MonoGame license\")\n- [Princeton University Java Algorithms](http://algs4.cs.princeton.edu/code/ \"Java Algorithms - Princeton University\")\n\t- Several classes from RogueSharps Algorithms namespace are inspired by these Algorithms\n- [RogueBasin](http://www.roguebasin.com/ \"RogueBasin\")\n\t- [Articles of interest for Roguelike developers](http://www.roguebasin.com/index.php?title=Articles \"Roguelike developer articles\")\n- [DocFx](https://github.com/dotnet/docfx \"DocFx\")\n\t- DocFx is used to automatically generate documentation from the XML comments in source code\n\t- [DocFx license](https://github.com/dotnet/docfx/blob/dev/LICENSE \"DocFx license\")\n- [Certes DocFx Template](https://github.com/fszlin/certes \"Certes DocFx Template\")\n\t- The DocFx template I'm using is based on the template created by fszlin for the Certes client.\n\t- Note: RogueSharp itself doesn't actually use Certes\n\t- [Certes license](https://github.com/fszlin/certes/blob/master/LICENSE)\n- [Dice Notation .NET](https://dicenotation.codeplex.com \"Dice Notation .NET\")\n\t- Significant portions of the code in RougeSharp DiceNotation namespace are taken directly from this great library\n\t- [Dice Notation .NET source code](https://dicenotation.codeplex.com/SourceControl/latest \"Dice Notation .NET source code\")\n\t- [Dice Notation .NET license](https://dicenotation.codeplex.com/license \"Dice Notation .NET license\")\n\n## License ##\n\n#### RogueSharp ####\n\nMIT License\n\nCopyright (c) 2014 - 2023 Faron Bracy\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n#### Other Licenses ####\n\nSee links to licenses in the credits for respective libraries","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFaronBracy%2FRogueSharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFaronBracy%2FRogueSharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFaronBracy%2FRogueSharp/lists"}