Package: tui-map-generator
TUI Map GeneratorHeight map 🗺 generator usingdiamond square💎🔷 with TUI 🖥️ interface.What for?This tool allows you to generate height maps usingdiamond squarealgorithm for your games or other projects. This is not a trivial task as it might seem at the beginning. Height map is not just random numbers - it needs to look 'organic', should be generated automatically and should be customizable, yet deterministic. See#Inspirationsfor more on that.With several parameters you can customize the size, roughness and color palette. Generated map can be saved as:pngplain imagejsonfile with formattingxpRexpaint image editorTUI interfaceTo make it easier to use, there is aTUIinterface. This gives you a 'graphical'-like user interface in the terminal (hence the nameTUI). This way you can use it in a console without any kind of graphical interface. And yes, the mouse works too! 🐭The GameI'm personally using this tool to generate maps for my game calledSSiS. It's part of an bigger tool calledConfig Editorwritten using amazing library calledTextual. However, the currently released version of my game is not yet using maps generated with this method. You can follow me onitch.ioto get notified when it's released.CompatibilityAll platforms should work, but I've tested it only onMacOS. If you have any problems, please create an issue.Linuxworks fine ✅ (tested on Ubuntu 22 with gnome-terminal)Windowsworks fine ✅ (tested on wt and cmd)MacOSworks fine ✅ (tested on iTerm2 and Terminal.app)InstallationPublic repositorypipinstalltui-map-generatororpipxinstalltui-map-generatorto have it in isolated environment.From sourceYou need to havePython >3.8installed and thepoetrylibrary. Check-out this repository, open the project folder in a terminal and run:poetryinstall
poetryrunpythonsrc/tui_map_generatorgenerate# orpoetryrunpythonsrc/tui_map_generatortuiOn MacOs I had to add folder with the source file to the PATH variable to make it work withtrogon(python script run with out python command need to be in PATH to skip the './' prefix):exportPATH=$PATH:~/<yourprojectsfolder>/tui-map-generator/src/tui_map_generatorUsageThere are two ways to use this tool:1. Plain command linewrite this command to see all available options:python3-mtui-map-generatorgenerate--helpto see something like this:Usage:python3-mtui-map-generatorgenerate[OPTIONS]Generateheightmapusingdiamondsquarealgorithm.Add'generate --help'toyourcommandtogetmorehelptheparametersoruse'tui'commandinstead'generate'.

Options:-s,--seedINTEGERSeedforrandomnumbergenerator.Skiptogetrandommapswitheachrun.Ifyouliketheresultsmakesuretonotecurrentlyusedseed.Useexplicitvaluetogeneratethesamemapmultipletimes,stillbeingabletofinetuneit(e.g.changeroughnesslevelorpalette).-u,--scale-upINTEGERRANGEMapsizescaleupfactorusedwhilesavingtoPNGfiles(see--export-png-filename).Withdefaultvalueof1youendupwithonepixelperheightmapvaluewhichmeansareallytinyimage.Withscaleup=5,eachheightmappointresultsin5x5pixelsrectangle.Linearscalingisusedinordertopreserveexactheightvalues(nointerpolation).[x>=1]-i,--export-png-filenameTEXTFilename(withoutextension)toexportmapPNGfileformat(.png).-j,--export-json-filenameTEXTFilename(withoutextension)toexportmapusingjsonformat(.json).-x,--export-xp-filenameTEXTFilename(withoutextension)toexportmapusingRexpaintfileformat(.xp).--printout/--no-printoutPrintheightmaptoconsole(defaultTrue).-h,--heightINTEGERRANGEMaximumheightvalue(minisalways1).Inordertoproperlydisplayinconsole,maxheightmustbelowerorequalthenumberofcolorsinselectedpalette(thebiggestpaletteis128).Whileexportingtofiles,maxheightisnotlimited.[x>=2]-r,--roughnessFLOATRANGERoughnesslevel-howrapidlyvalueschangenearby(thehighervaluethemore'ragged'map).Bestresultswheninrangeof~3.0toMAX_HEIGHT.[x>=1.0]-p,--palette[landscape_4|landscape_8|landscape_16|grey_16|red_16|green_16|blue_16|yellow_16|magenta_16|cyan_16|grey_32|grey_64|grey_128]Nameofoneofavailablecolorpalettes.Apaletteisasetofcolorstorepresentmapheightvalues.-m,--map-size[9|17|33|65|129]Mapsize(fordiamondsquaresizemustben^2+1).Ifyouneeddifferentsize,pickbiggervalueandcuttodesiredsize.--helpShowthismessageandexit.To quickly see how it works, skip all parameters (use default) and write this command:python3-mtui-map-generatorgenerate2. TUI interfacewrite this command to start TUI interface:python3-mtui-map-generatortuiExamplesmaps/example_01Map size: 65Algorithm: diamond squareMax height: 16Roughness: 16.0Random seed: 2994Palette: landscape_16maps/example_02Map size: 129Algorithm: diamond squareMax height: 64Roughness: 64.0Random seed: 4948Palette: grey_64maps/example_03Map size: 33Algorithm: diamond squareMax height: 8Roughness: 3.0Random seed: 6956Palette: landscape_8Under the hoodLibrariesHere are some some of the libraries used in this project:rich- to get beautiful colors and formatting in the terminal (but this is much more powerful tool - check it out! 🚀)rich_pixels- to render map in the terminal (but this tool is also capable of displaying images in console)click- to create command line interfacetrogon- to create TUI interface with wonderfulTextuallibrary - this one is beyond amazing! 🤯 My understanding of the full power of terminal apps has expanded a lot since I've found it. Just as a teaser -Textualapps can be even run inweb browserInspirationsThis implementation is based onexample-diamond-squareproject written inLuausingDefoldengine. See the author him self, explaining the wholediamond square💎🔷 algorithm:YouTube video. More on the process of building my implementation can be found on myblogpost.