Roguelike
This game is a rogue-like game that uses the libtcod library and is loosely based on the python rogue-like tutorial.
Install / Use
/learn @kwoolter/RoguelikeREADME
Python Rogue-like Game using TCOD lib
kwoolter :monkey: :copyright: 2020
Overview
This game is a rogue-like game that uses the libtcod library and is loosely based on the python rogue-like tutorial.
Screenshots
<table> <tr> <td> <img height=325 width=250 src="https://raw.githubusercontent.com/kwoolter/roguelike/master/roguelike/view/screenshots/new_character2.JPG" alt="new character"> </td> <td> <img height=325 width=250 src="https://raw.githubusercontent.com/kwoolter/roguelike/master/roguelike/view/screenshots/floor1.JPG" alt="exploring"> </td> </tr> <tr> <td> <img height=325 width=250 src="https://raw.githubusercontent.com/kwoolter/roguelike/master/roguelike/view/screenshots/inventory2.JPG" alt="inventory"> </td> <td> <img height=325 width=250 src="https://raw.githubusercontent.com/kwoolter/roguelike/master/roguelike/view/screenshots/shop2.JPG" alt="character"> </td> </tr> </table>Controls
F1help on controls available from current screenPage UpandPage Down- change font size
Game Ready Screen
Ncreate a new characterENTERorSPACEto start the gameEscquit the game
Create New Character Screen
Nchange player's nameCchange player's classRchange player's raceENTERorSPACEconfirm race/class selectionEscexit screen
Game Playing Screen
- Arrow keys - move and attack enemy
1-4- use spell in spell book slotCtrlattack current target with equipped weaponGorSPACEget an itemQorUuse item currently equipped in Item slotXexamine item on floorZskip turnCcharacter screenRinventory screenJjournal screenKspell bookENTERorVtravel on stairsEscpause game
Game Paused Screen
Qquit the gameEsccontinue playing game
Inventory Screen
- Arrow keys or
WASDchange selected item Eequip an itemQorUuse an itemXexamine an itemFdrop an itemEscorRexit screen
Spellbook Screen
- UP/DOWN Arrow keys or
WSchange selected spell - LEFT/RIGHT Arrow keys or
ADchange selected spell level filter Mmemorise/forget spellLlearn/unlearn spellEscorKexit screen
Character Screen
- Arrow keys or
WSchange selected ability L,EorSPACElevel-upUupgrade selected ability using Ability PointsEscexit screen
Shop Screen
EorBswitch to Buy tabQorVswitch to Sell tab- Up and down arrow keys or
WandS- change selected item ENTERorSPACEbuy/sell the selected item- Left and Right arrow keys or
AandD- change item category in Buy tab Escexit screen
Game Over Screen
ENTER- continue to Game Ready Screen
Background
What is a rogue-like game?
- https://en.wikipedia.org/wiki/Roguelike
What is the libtcod library?
- https://github.com/libtcod/libtcod
- https://libtcod.github.io/docs/
What is the Python rogue-like tutorial?
- http://rogueliketutorials.com/about/
- http://rogueliketutorials.com
- http://rogueliketutorials.com/tutorials/tcod/v2/
What is this game again?????
Features:
- DnD-like classes, abilities, monsters and combat rules
- DnD-like armour, melee weapons, ranged weapons and other items
- Dnd-like spells and spellbook
- DnD-like ability checks
- XP and Leveling-up
- Random dungeon floor generation with more rooms per floor as you get deeper
- Field of View (FoV) lighting
- "Fog of War" unexplored map
- Random enemies in each room that scale as you go deeper
- Random items scattered across the floor with probability governed by game rules
- Potions and Scrolls have randomised effects
- Random colour palettes and random room and dungeon level names
- Random Lore generation
- Inventory and Shop features
- Perma-death
The Game Design
Package Structure
Overview:
roguelikemodel- modules containing the classes for the game, floors, entities, etc.view- modules containing the classes for all of the viewscontroller- main control loop
tutorialdirectory - how I started out following the python tutorial
model package
model.py- main module that containsModel,Floor,Room,Tunnelclassesentity_factory.py- containsEntity,EntityFactory,Player,Fighter,Inventoryclassescombat.py- containsCombatEquipment,CombatEquipmentFactory,CombatClass,CombatClassFactoryclassesspells.py- spells and spellbook related classesevents.py- all of the event names used in the gamethemes.py- module for managing colour themes and random name generationdatadirectory - data files for the gameentities.csv- all of the game objects and their propertiescombat_equipment.csv- more properties for entities that are armour or weaponscombat_classes.csv- the different types of fighter classes and their abilitiesgame_parameters.csv- the rules of how the game scales in difficultyability_checks.csv- which items can you perform an ability check on and what are the outcomes for success and failurethemesdirectory - data files for colour themes and random name generationfloor_palettes.csv- colour palettes for different themesroom_palettes.csv- room colours for different themesrogue_history.cfg- config file for name generation usinglibtcod.namegen_generate()functionalityroom_names.csv- not used anymore as switch to random name generation usinglibtcodlibrary
view package
view.py- main module that containsMainFrame,FloorViewand other UI View related classesview_utils.py- utility classes for drawing stuff on a consolefontsdirectory - different font files that can be used withlibtcodscreenshotsdirectory - screenshots of the game in action
controller package
controller.py- main game loop, keyboard event handling, orchestration of game states and UI states
Dependencies
- Python 3
tcod- creating and writing to consoles, keyboard events, colours, field of view (FOV) calculations, random name generation, etc.numpy- floor maps and properties. Also used bytcodlibrary for FOV calculationspandas- used for loading incsvfiles that hold the game data e.g. entities, combat items, etc.pygame- only used for theRectclass
How Does The Game's Difficulty Scale?
Basic Concept
The Entity objects that appear in the game have a count and probability metric defined either for the current Floor or for each individual Room on the Floor.
For example, what is the maximum number of rats that you want to add to a room and what is the probability of each rat successfully being added? You may want at most 3 rats per room each with a 50% probability.
So in the game, for a given metric y you can specify how it is calculated using this formula:
y = a*x + b + (x//d) * ad
Where x is the dungeon level that you are currently on and a, b, d and ad are parameters defined for each metric.
So breaking this up, y = a*x + b is the simple formula for any straight line plotted on an xy axis. a represents
the slope of the line and b is the y intercept. However, you may want an increasing number of rats at lower dungeon
levels but no rats beyond level 10. To support this you can add (or subtract) x DIV d multiplied by a different slope.
So if you want no rats to appear after level 10 you can specific (x DIV 10) * -100.
Furthermore, you can constrain y by specifying minimum and maximum values.
This means you can cap the number of rats per room at say 4 but at a minimum always attempt to add 1.
Pulling all of this together you end up with the following lines of code to calculate y:
# Calculate y = a*x + b + (x div d)*ad applying min and max constraints
result = a*xvalue + b
result += (ad * (xvalue//d))
result = min(max(result, min_), max_)
An example visualisation of this is shown in the graph below where the orange line is y = ax + b,
the blue line is (x div d) * ad and the grey line is y which is the sum of these two lines with a maximum and minimum applied (4 and 0 respectively).
Using this basic concept you can create interesting curves for count and probability for each Entity in the game.
game_parameters.csv file
This file defines the count and probability for each entity that you want to appear in the game's rooms or floors.
Columns:
Entity- the name of the entity you want to define a metric for e.g.RatMetric- which metric are you defining e.g.CountorProbability?Scope- what scope is the metric for e.g.RoomorFloor?x- what is the name of the variable that you want to substitute asxinto the model - typicallyLevela- slopeb- y interceptd- x DIV valuead- x DIV value slopemin- the minimum value ofymax- the maximum value ofyTemplate- use a template instead of a,b,d,ad values
Use templates for when you want to share Count or Probability curves across multiple types of Entity
entities.csv file
Each Entity in the game needs to be defined as a row in this file.
Columns:
Name- the short name of theEntityused in other property files e.g.combat_equipment.csvDescription- a description of theEntityused when it is displayed in text messagesChar- the character used to represent theEntityon the gameFloorViewCategory- group entities together by categoryFG- foreground colourBG- background colourZorder- order of display in descending order i.e. 0 is draw lastIsTransparent- does light shine through it?IsWalkable- can you walk onto the same tile as it?IsInteractable- can you interact with it?- `IsColle
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
90.0kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
343.1kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
