Page 1 of 1

Dungeon Master in Python

Posted: Sun Jul 05, 2026 9:51 pm
by Cycl0ne
The last couple of month.. years(?).. i used the ReDMCSB Source for the Amiga V3.6 and ported all to python. The project is called PyDm.

As you can see from the Source Code, the comments will reference the apropiate C Code, for people to check why something is done like its done:

Code: Select all

def perform_action(champ: Champion, action: Action, has_target: bool, rng: random.Random,
                   difficulty: int = 1, xp_override: int | None = None) -> str | None:
    """Apply an action's cost to the champion (the F0407 tail, MENU.C:1233-1243) and
    grant its skill experience. Returns the base-skill name if the champion gained a
    level (for the caller to announce), else ``None``.

    With nothing in front to hit (``has_target`` False) it's the "miss" path: the
    cooldown and experience are halved (MENU.C:1045-1052) but still applied. Either way
    the action is consumed — cooldown set, stamina decremented, (partial) XP granted.
    ``difficulty`` is the current map's XP multiplier (F0304). ``xp_override`` supplies a
    dynamic experience amount (the HEAL action's ``2 + 2*cycles``) that replaces the table
    value and is never halved."""
i included a module : Automap. this checks the world in the space of 3x3 around the char and saves it. Teleporters "invisible" are not shown (So you dont get spoiled). Its a kind of: Convenient Method, instead of you maybe did 30 years ago with pen and paper ;-)
Bildschirmfoto_20260705_212531.png
I used also the hand icon from the Amiga Version and the Yellow Pointer, which are data fields in the source
Bildschirmfoto_20260705_212443.png
All creatures are living in the dungeon like the original.
Bildschirmfoto_20260705_212335.png
Bildschirmfoto_20260705_212308.png
Here a short demo video of the port with the appearance GODMOG my debug Character ;-)
https://youtu.be/XU9nbs-FwZk

I divided the code into 2 Parts:
Renderer -> PyDM
World -> Basilisk Engine

I will upload the whole source in the next couple of days to my codeberg repository. And also create a Webasm Version and upload it to a website.

Oh, i use my own DMCSB Python module to extract graphics.dat/dungeon.dat, you need to supply it at the assets dir later. Maybe i will write a small "own" format to not get any problems with copyright of a nearly 40 year old game graphics :-D
What else is needed:
pygame-ce
numpy

Will keep you updated.

Re: Dungeon Master in Python

Posted: Sun Jul 05, 2026 11:48 pm
by ChristopheF
Great, I'm happy to see ReDMCSB was useful for some new projects !

Re: Dungeon Master in Python

Posted: Mon Jul 06, 2026 12:47 pm
by Cycl0ne
Have fun, bugs and comments you can write here...

https://codeberg.org/CyCl0ne/pyDM

tested at the moment with the Amiga dungeon.dat/graphics.dat (3.x)

* MagicMap implemented, but not used since this item is not available in the dungeon, you can use "M" for this.
* Skill decrease shooter CSB code part -> not implemented

Re: Dungeon Master in Python

Posted: Mon Jul 06, 2026 1:25 pm
by Gambit37
This is very cool, great work! It's wonderful to see DM running in new contexts.

Will this version always need to decode a graphics.dat, or could it be extended to read external image files? And could those external images have a higher bit depth? You can see where I'm going with this....

I have a semi-complete project for DSB to replace all the graphics with improved 8-bit versions (256 colours). I work on it very slowly but it will be finished one day. If your PyDM had support for that, it could also use these improved graphics...

Re: Dungeon Master in Python

Posted: Mon Jul 06, 2026 1:41 pm
by Cycl0ne
Hey Gambit of course ;-) this is why i separated the engine from the renderer. I had one forum post what my initial goal was: a DMCK (DM Contruction Kit). ;-)

All my projects allways fail, because i first implemented all goodies and then the motivation was gone. This time i said to myself: do a complete port and then the goodies.

But what you have to keep in mind: im using the ZONE/LAYER from the original Game, so every blit to screen goes through this mechanism. This was the first port and cleanup i did 2 years ago, when i thought this project would be cool in Typescript ;-)
https://codeberg.org/CyCl0ne/pyDM/src/b ... ne/zone.py

Re: Dungeon Master in Python

Posted: Mon Jul 06, 2026 8:22 pm
by Cycl0ne
For people who dont want to install python:

https://cycl0ne.codeberg.page/pages/

pyDM running as Webassembly

Bugs:
* Sound opening
* you can save and load, but it is not persistant.. sorry :( for that i need to read more webdocu

Re: Dungeon Master in Python

Posted: Mon Jul 06, 2026 11:40 pm
by ChristopheF
I tried https://cycl0ne.codeberg.page/pages/ in Edge, Chrome, Brave and Firefox.
The only thing I get is the "Loading, please wait" message...

Re: Dungeon Master in Python

Posted: Mon Jul 06, 2026 11:56 pm
by Cycl0ne
Takes some time 10-15sec. Maybe refresh. Problem is a limitation in Codeberg. I will move to another Server.

Check the f12 Browser console If there is an exception throwing. I tried IT in Chrome Android and Chrome Linux. Works. Was a quick Hack. Will Check tomorrow.

Re: Dungeon Master in Python

Posted: Tue Jul 07, 2026 9:53 am
by Cycl0ne
Hi Christophe,

the problem can be an Ad Blocker, we need to cross-script to get the compiled python executor. normally you should see this on error in the browser console (F12):
pythons.js:2223 Loading python interpreter from https://pygame-web.github.io/cdn/0.9.3/ ... 12/main.js
onload @ pythons.js:2223
The FetchEvent for "https://pygame-web.github.io/cdn/0.9.3/ ... 12/main.js" resulted in a network error response: Cross-Origin-Resource-Policy prevented from serving the response to the client.
main.js:1 Failed to load resource: net::ERR_FAILED


when disabling some blocker (for me its ghostery). all runs. As i said, i hacked it into the codeberg. Maybe i find some other hoster. but its low prio for me. it was just an proof of concept if wasm works ;-)

Re: Dungeon Master in Python

Posted: Tue Jul 07, 2026 4:09 pm
by ChristopheF
I do get the error you mention in F12 dev tools.
In Edge, I had to select "Allow" for "Insecure content" under Privacy, search, and services / Site permissions / All sites / https://cycl0ne.codeberg.page/
Not something anyone should ever do... but now it works. This will definitely need a better fix.

Some feedback so far:
- It's great to see the (nearly) original game running in a browser, well done !
- I'd like an option to enabled/disable the refinements that you implemented, like color icons in the action area & fluid movement for thrown objects.
- When you click on a movement arrow, both the arrow and the rectangle around are briefly inverted. In the original game, only the arrow is inverted, not the rectangle. This looked weird the very first time I clicked an arrow.
- When attacking a creature, you can attack with one champion, the damage amount is displayed over the action area, but you can still click on this damage picture to cause another champion to perform an action, even before the damage disappears.

Re: Dungeon Master in Python

Posted: Tue Jul 07, 2026 7:49 pm
by Cycl0ne
ChristopheF wrote: Tue Jul 07, 2026 4:09 pm - It's great to see the (nearly) original game running in a browser, well done !
Thanks !
ChristopheF wrote: Tue Jul 07, 2026 4:09 pm - I'd like an option to enabled/disable the refinements that you implemented, like color icons in the action area & fluid movement for thrown objects.
i will think on it ;-)
ChristopheF wrote: Tue Jul 07, 2026 4:09 pm - When you click on a movement arrow, both the arrow and the rectangle around are briefly inverted. In the original game, only the arrow is inverted, not the rectangle. This looked weird the very first time I clicked an arrow.
- When attacking a creature, you can attack with one champion, the damage amount is displayed over the action area, but you can still click on this damage picture to cause another champion to perform an action, even before the damage disappears.
All fixed + some other bugs (throwing something at a door, the item stays behind the door not infront.

Im compiling a new webasm version and upload it. But as i mentioned, this is just a POC. The native python version is the main source ;-)

The problem with the webversion:
* i need to include the two .dat files, no possible "upload" files.
* No real save/load, for that i need to create a database on a webserver to save to it. at the moment -> out of scope.

--> Just finished compiling and uploading the new version. its now live. (i had to use now icognito Tab to start it). I also implemented a fix, but it could take some time for codeberg to sync their servers. I created now a complete bundle. no more external loading of the python engine.

Re: Dungeon Master in Python

Posted: Tue Jul 07, 2026 11:05 pm
by ChristopheF
Thanks!

About saving: you could just build the saved game file in memory, then provide a link for the player to download it.
For loading, you can provide a button to upload as saved game and manipulate it in memory.
No need for an actual web server nor database, this can be done directly in the browser with some javascript.
I don't know how you would interface that with webasm/python though.

Re: Dungeon Master in Python

Posted: Wed Jul 08, 2026 12:08 am
by Cycl0ne
yes i thought so too, but before this, i still have some todos to work off:

* Scroll click in Mainmenu: Some kind of Optionsmenu and also shows engine version number Options could be:
[] Hardmode (Amiga 3.5+ Balance Change Reincarnation [A35E in your code])
[] Original Mode (no smooth animation + action buttons stamped) (as wished by you)
[] Debug
[] Automap

* Multiple save files with requester for laoding/saving.
* Internal structure change, i got a really big world.py with 5000 lines.. i want to split it up into "modules"
-> Creature module
-> different behaviour modules
-> ...
-> Fighting Module
-> Action Module
-> Item Module
->...

so one could extend the engine for new creatures and give them new attack, new drops, new anything.. or a new item, etc.

And what is also not available, a graphical layer editor. This was the most time consuming part to get this correct in code.
And with it, a new .dat format, something more portable with Tags in it liḱe: TXT3, LAY1 etc and some kind of grouping, so the fixed number into the dat belongs to a group and it can be resized without disturbing the file positions..

so yes still some things todo ;-)

Re: Dungeon Master in Python

Posted: Sat Jul 11, 2026 10:50 am
by Cycl0ne
I was thinking of a layout editor, here a mockup i did ... do you think this would be nice and usable?
Bildschirmfoto_20260711_104924.png
with this, all graphics could be exchangeable on resolution.

Re: Dungeon Master in Python

Posted: Sat Jul 11, 2026 11:54 am
by ChristopheF
I guess that could be useful for custom dungeon creators who want to replace graphics and need to realign them. Certainly very few people.
That said, currently there is no tool to at least browse the layout data, view them graphically as on your screenshot, and provide a clear name/description for each zone.

Re: Dungeon Master in Python

Posted: Sat Jul 11, 2026 12:53 pm
by Cycl0ne
Forget the idea, wont work. I tried and failed badly. Since the LAY1 incorporates: CLICK Zones and Achorpoints. Anchorpoints have no W,H.. So i have to think about it again.
ADGE did a nice job at that time then.

Re: Dungeon Master in Python

Posted: Sat Jul 11, 2026 10:34 pm
by Cycl0ne
ok so still thinking on the LAY1 so i created my own editor today, but only for the dungeon data/action/item/combo.
Bildschirmfoto_20260711_223011.png
Bildschirmfoto_20260711_222957.png
Bildschirmfoto_20260711_222933.png
Bildschirmfoto_20260711_222918.png
Bildschirmfoto_20260711_223325.png
Light Mode also available

Available as prealpha https://codeberg.org/CyCl0ne/pyDM/src/b ... ls/dmforge

Re: Dungeon Master in Python

Posted: Sun Jul 12, 2026 4:51 pm
by ChristopheF
FYI I have added pages on the Encyclopaedia for your python projects

Re: Dungeon Master in Python

Posted: Mon Jul 13, 2026 5:42 pm
by Cycl0ne
Hey thanks ! .. I will add some small text for you later. also maybe a new URL for the webversion.

What i did the whole weekend: Fix bugs and also created an "Enhance" Function. Default: Disabled and all looks and behaves like the original. Especially for you :-)
Bildschirmfoto_20260713_173735.png
when enhanced mode is activated, not only are the action bars colored again and the animation of weapons/projectiles is smooth, but the scrolls have a hint now:
Bildschirmfoto_20260713_174008.png
For ppl unfamiliar with the runes of the game.

This version will be up in a couple of hours as Web Version. At the moment its only the python Version online.

Re: Dungeon Master in Python

Posted: Mon Jul 13, 2026 11:16 pm
by Cycl0ne
Found a way to save in web.

a) Normal save/load ingame -> packed with zlib then uuencoded in browser cache, stays in cache until user removes it. Around 40kb of packed data.
b) F9/F10 Export/Import (F10 works only on the Main Screen) This lets you download the save file to disk. This save file is 100% compatible with the desktop pygm version. Just drop it into assets/ and you can continue your game on the desktop.
Bildschirmfoto_20260713_231300.png

Re: Dungeon Master in Python

Posted: Tue Jul 14, 2026 1:54 am
by ChristopheF
Nice additions !
thanks

Re: Dungeon Master in Python

Posted: Tue Jul 14, 2026 7:08 pm
by Cycl0ne
ChristopheF: Was there really no Chaos Strikes Back for the PC? and do you know where i can get my hands on an extracted Amiga CSB disk? dont want to hassle with installing some emulator or so. Was hard enough for the Atari ST to extract the disk.

Re: Dungeon Master in Python

Posted: Tue Jul 14, 2026 7:54 pm
by ChristopheF
No, FTL never made CSB on PC DOS.

No need for an emulator, you can browse and extract files from Amiga ADF images with this online tools:
https://www.ezyzip.com/open-extract-adf-file.html
https://www.stef.be/adfviewer/

Re: Dungeon Master in Python

Posted: Tue Jul 14, 2026 8:43 pm
by Cycl0ne
Wow thanks.. extracted. And it works. Never played CSB. need to figure out what it means with the utility disk :D
Bildschirmfoto_20260714_203619.png
It works, had to extract the dungeon from mini.dat in the utilities disk. Cool, insert 2 Coins. worked flawlessly.

Now i need to think how i make this selectable for the player, what he wants to play.

Hmm need to create a custom format to release the .dat, if you have the dat, you can now do this:
./run.sh --graphics assets/DM/GRAPHICS.DAT --dungeon assets/DM/DUNGEON.DAT
./run.sh --graphics assets/CSB/GRAPHICS.DAT --dungeon assets/CSB/DUNGEON.DAT
./run.sh --graphics assets/CSB/GRAPHICS.DAT --dungeon assets/CSB/CSB_GAME_DUNGEON.DAT

1) Original DM
2) CSB Dungeon with Mirrors
3) CSB Main Dungeon

Re: Dungeon Master in Python

Posted: Thu Jul 16, 2026 10:51 am
by Cycl0ne
@gambit, i tried my old enhanced graphics from 2011 .. but they suck :-P at least in the case of the Walls. But back to your question: yes you can exchange the graphics.
wall1.jpg

Re: Dungeon Master in Python

Posted: Sun Jul 26, 2026 7:08 pm
by Cycl0ne
V0.1.89 released and compiled to web version.
-> lots of bugfixed
-> Now with SWOOSH and TITLE and also from the PC Version.. The Song.dat in the Entrance

Re: Dungeon Master in Python

Posted: Mon Jul 27, 2026 9:00 pm
by Cycl0ne
V0.2.00 Release:
Automap enhancement: You can now scroll through the levels you visited (Not visited -> no button to scroll to):
Bildschirmfoto_20260727_205357.png
automap_levels.png
While debug playing now for 9h and on Level 9 and giving this game to other fellowers. I havce some things in mind, maybe you can give me some suggerstions:

* I dont comprehend, which weapon you pick, which is better than the other. So i was thinking of maybe linking a new feature to the priest. "Inspect". When at a certain level of Priest, you can see details of Weapon/Armor putting the item over the eye. What do you think? To make the game more attractive to new users

* Some kind of spellbook.. Hitting all those keys is nostalgic, but a kind of hassle. So was thinking of something like RTC : you find a spell scroll -> you get the spell on a button or so.

* Need to substitute the right mouse button for the web version. Any ideas? Two finger click maybe?

Re: Dungeon Master in Python

Posted: Mon Jul 27, 2026 10:00 pm
by Cycl0ne
0.2.1 :
Added a "Recall" system for Spells. The last spell cast can be recalled, it is saved to the champion, so you have 4 recall mod space.

Champ 1 : light, Champ2: fireball, Champ3: Lightning Bolt, Champ4: poison cloud
image.png
image.png (2.22 KiB) Viewed 28 times
Grey = no spell in memory
image2.png
image2.png (2.17 KiB) Viewed 28 times
Normal = Spell in memory, which can be cast
image3.png
When running out of mana using the spell, halve of the spell is now printed
Bildschirmfoto_20260727_215918.png
All hidden behind the F4 - Enhancement Version to be "Christophe approved" (c) (tm) :D

Re: Dungeon Master in Python

Posted: Wed Jul 29, 2026 7:28 am
by Cycl0ne
Dungeon Master never tells you how good a thing is. Hold the eye over a sword and the
panel gives you its name, its state flags and its weight — nothing about the 34 Strength
and 10 Kinetic Energy that actually decide the fight. Every number the engine uses is
sitting in the ported `WEAPON_INFO` / `ARMOUR_INFO` / `ACTION_*` tables in
`src/basilisk/_objectdata.py`, unreachable from inside the game.

Discussing with Sphenx and the people on Discord, how we could "improve" DM1 so for new players

to make it DM Style, it would be locked to this:

The levels you need to get it shown

Code: Select all

  ┌───────┬────────────────────────┬──────────────────────────────┐
  │ level │         title          │            shows             │
  ├───────┼────────────────────────┼──────────────────────────────┤
  │ ≤ 1   │ (untitled)             │ nothing — the original panel │
  ├───────┼────────────────────────┼──────────────────────────────┤
  │ 2–3   │ NEOPHYTE, NOVICE       │ label + word                 │
  ├───────┼────────────────────────┼──────────────────────────────┤
  │ 4–5   │ APPRENTICE, JOURNEYMAN │ label + bar                  │
  ├───────┼────────────────────────┼──────────────────────────────┤
  │ ≥ 6   │ CRAFTSMAN +            │ label + bar + number         │
  └───────┴────────────────────────┴──────────────────────────────┘
Here the words:
QUALITY_WORDS = ("PUNY", "FEEBLE", "MODEST", "FAIR", "SOUND", "STRONG", "MIGHTY", "SUPREME")

So with this enhancement it would look like this:
item_stats_mockup.png
1. **SWORD**, viewer is a CRAFTSMAN Fighter — `DAMAGE 48`, `HIT 48`, `STRENGTH 34`,
`IMPACT 10` in gold, then the weight line.
2. **MITHRAL AKETON**, viewer is an APPRENTICE Priest — `DEFENSE` and `SHARP` bars in
blue, no numbers yet.
3. **EE POTION** (power 200), viewer is a NEOPHYTE Priest — `(CONSUMABLE)`, then
`POWER … MIGHTY` as a word, plus the existing power-symbol prefix on the name, which
this same band unlocks.
4. **THE CONDUIT**, viewer is a NOVICE Wizard — the ungated `CHARGES 15` bar and number
sitting above four word-band stat rows. Exactly six rows; the tightest real case.
5. **SWORD below the gate** (and with F4 off) — the exact panel the original draws.

Code: Select all

Armour, Potion            -> SKILL_PRIEST
Weapon                    -> ACTION_SETS[action_set][5], folded by F0303's (idx-4)>>2
anything else (Moonstone) -> SKILL_WIZARD

Folding the set's own skill index gives: sword/axe/mace/torch → Fighter;
dagger, throwing star, rock, bow, sling, crossbow → Ninja;
wand, Staff of Claws, Horn of Fear → Priest;
Flamitt, Fury, Yew Staff, Firestaff, Bolt Blade, Conduit, Stormring → Wizard.
Armour → Priest is table-derived too (`C15_SKILL_DEFEND` folds to Priest).

Here the list of Stats to show:

Code: Select all

| item | rows |
|---|---|
| *(any item with charges)* | `CHARGES` / `FUEL` — **ungated**, then: |
| melee weapon | `DAMAGE`, `HIT`, `STRENGTH`, `IMPACT`, `MANA` |
| thrown (class 1–12) | `IMPACT`, `STRENGTH`, `DAMAGE`, `HIT`, `MANA` |
| launcher (class 16–47) | `SHOOT`, `IMPACT`, `STRENGTH` |
| magic (class ≥ 112) | `MANA`, `DAMAGE`, `HIT`, `STRENGTH`, `IMPACT` |
| torch (icon 4–7) | `LIGHT`, then the melee rows |
| armour | `DEFENSE` (or `SHIELD` when `AI_ATTRIBUTES & 0x80`), `SHARP` |
| potion | `POWER` |
| other | `MANA` if the icon carries a max-mana bonus, else nothing |