Created extensive wiki documentation covering all aspects of the Fantasy Map Generator: - Home.md: Wiki homepage with overview and navigation - Getting-Started.md: Complete beginner's guide for users and developers - Architecture.md: System architecture, design patterns, and technology stack - Data-Model.md: Detailed data structures and relationships - Generation-Process.md: Step-by-step map generation pipeline - Modules-Reference.md: Documentation for all 20+ modules - Features-and-UI.md: Complete feature list and UI guide - README.md: Wiki directory overview The documentation includes: - High-level architecture and design patterns - Detailed data structures with typed arrays - 17-stage generation pipeline with algorithms - All core modules (generators, renderers, UI, I/O) - 41+ UI editors and features - Code examples and usage patterns - Developer setup and contribution guidelines - User tutorials and quick start guides This wiki provides comprehensive documentation for both users wanting to create maps and developers wanting to understand or contribute to the codebase.
17 KiB
Getting Started
Welcome! This guide will help you get started with the Fantasy Map Generator, whether you're a user wanting to create maps or a developer wanting to contribute.
Table of Contents
For Users
Using the Online Version
The easiest way to use the Fantasy Map Generator is through the web application:
Link: azgaar.github.io/Fantasy-Map-Generator
Requirements:
- Modern web browser (Chrome, Firefox, Safari, or Edge)
- JavaScript enabled
- Recommended: Desktop or laptop (mobile works but with limitations)
No installation needed! Just open the link and start generating maps.
Using the Desktop Version
For offline use or better performance, download the Electron desktop application:
Download: GitHub Releases
Installation:
- Go to the releases page
- Download the archive for your platform:
- Windows:
FMG-windows-x64.zip - macOS:
FMG-darwin-x64.zip - Linux:
FMG-linux-x64.zip
- Windows:
- Extract the archive
- Run the executable:
- Windows:
FMG.exe - macOS:
FMG.app - Linux:
FMG
- Windows:
Benefits:
- Works offline
- Better performance
- No browser limitations
- Easier file management
Creating Your First Map
Step 1: Open the Generator
Visit the website or open the desktop app.
Step 2: Generate
Click the "Generate New Map" button (or it generates automatically on first load).
Step 3: Explore
Your map is ready! You'll see:
- Terrain with mountains, plains, and water
- Rivers and lakes
- Political boundaries (states)
- Cities and towns
- Labels and names
Step 4: Customize
Use the toolbar to:
- Toggle layers on/off
- Zoom and pan
- Open editors to modify the map
- Change visual style
Step 5: Save
Click File → Save Map to download your map as a .map file.
Congratulations! You've created your first fantasy map.
Basic Controls
Mouse Controls:
- Left Click: Select elements
- Right Click: Context menu (in editors)
- Drag: Pan the map
- Scroll: Zoom in/out
- Hover: Show tooltips
Keyboard Shortcuts:
- Ctrl+Z: Undo
- Ctrl+Y: Redo
- Ctrl+S: Save
- Ctrl+O: Open
- F11: Fullscreen
- Space: Toggle pan mode
Common Tasks
Changing Terrain
- Click Layers → Heightmap
- Click Edit Heightmap
- Use brush tools to raise/lower terrain
- Click Apply
Adding a City
- Click Layers → Burgs
- Click Add Burg
- Click on map where you want the city
- Fill in name and details
- Click Add
Customizing Colors
- Click Style → Edit Style
- Select element to customize (states, terrain, etc.)
- Choose colors
- Click Apply
Exporting
- Click File → Export
- Choose format (SVG, PNG, etc.)
- Configure options
- Click Export
Learning Resources
Official Resources:
- Wiki - Comprehensive guides
- YouTube Channel - Video tutorials
- Blog - Articles and tips
Community:
Examples:
- Gallery - Community maps for inspiration
For Developers
Setting Up Development Environment
Prerequisites
- Git - Version control
- Modern Browser - Chrome/Firefox with DevTools
- Text Editor - VS Code, Sublime, Atom, etc.
- Optional: Node.js (for local server)
Clone the Repository
git clone https://github.com/Azgaar/Fantasy-Map-Generator.git
cd Fantasy-Map-Generator
Run Locally
Option 1: Python Server
# Python 3
python -m http.server 8080
# Python 2
python -m SimpleHTTPServer 8080
Option 2: Node.js Server
npx http-server -p 8080
Option 3: VS Code Live Server
- Install "Live Server" extension
- Right-click
index.html - Select "Open with Live Server"
Option 4: Direct File Access
Open index.html directly in browser (some features may not work due to CORS).
Access the Application
Open your browser and navigate to:
http://localhost:8080
Project Structure
Fantasy-Map-Generator/
├── index.html # Main HTML file
├── index.css # Main stylesheet
├── main.js # Core application logic
├── versioning.js # Map version migration
├── modules/ # Feature modules
│ ├── heightmap-generator.js
│ ├── river-generator.js
│ ├── cultures-generator.js
│ ├── burgs-and-states.js
│ ├── religions-generator.js
│ ├── routes-generator.js
│ ├── military-generator.js
│ ├── markers-generator.js
│ ├── names-generator.js
│ ├── coa-generator.js
│ ├── coa-renderer.js
│ ├── biomes.js
│ ├── lakes.js
│ ├── voronoi.js
│ ├── fonts.js
│ ├── relief-icons.js
│ ├── ocean-layers.js
│ ├── io/ # Save/load/export
│ ├── ui/ # 41+ editor dialogs
│ ├── renderers/ # Visualization
│ └── dynamic/ # On-demand utilities
├── libs/ # Third-party libraries
│ ├── d3.min.js
│ ├── delaunator.min.js
│ ├── jquery.min.js
│ └── jquery-ui.min.js
├── utils/ # Utility functions
├── config/ # Configuration files
├── styles/ # Additional stylesheets
├── images/ # Image assets
├── charges/ # Heraldic charges (200+)
└── heightmaps/ # Template heightmaps
Making Your First Change
Example: Changing Default Sea Level
File: modules/heightmap-generator.js
Find:
const seaLevel = 20; // Default sea level
Change to:
const seaLevel = 25; // Raised sea level
Save and reload - Sea level is now higher.
Development Workflow
1. Create a Branch
git checkout -b feature/my-feature
2. Make Changes
Edit files in your preferred editor.
3. Test Changes
- Reload the browser
- Test affected features
- Check browser console for errors
4. Commit Changes
git add .
git commit -m "Add description of changes"
5. Push Branch
git push origin feature/my-feature
6. Create Pull Request
- Go to GitHub repository
- Click "Pull Requests"
- Click "New Pull Request"
- Select your branch
- Describe changes
- Submit
Code Style Guidelines
JavaScript Style
Use strict mode:
"use strict";
Module pattern:
window.MyModule = (function() {
// Private
function privateFunction() {}
// Public
function publicFunction() {}
return { publicFunction };
})();
Naming conventions:
- Variables:
camelCase - Constants:
UPPER_SNAKE_CASE - Functions:
camelCase - Modules:
PascalCase
Comments:
// Single-line for brief explanations
/* Multi-line for
longer explanations */
Formatting
- Indentation: 2 spaces (no tabs)
- Semicolons: Use them
- Quotes: Prefer double quotes
- Line length: ~100 characters
Best Practices
- No global pollution - Use modules
- Use typed arrays for cell data
- Cache DOM selections - Don't query repeatedly
- Minimize D3 updates - Batch when possible
- Comment complex logic - Help future maintainers
Understanding the Codebase
Key Concepts
1. Global State
grid // Voronoi diagram + terrain
pack // Civilizations + derived data
seed // Random seed
All modules access these globals.
2. Generation Pipeline
generateGrid()
→ generateHeightmap()
→ markFeatures()
→ calculateClimate()
→ generateRivers()
→ defineBiomes()
→ generateCultures()
→ generateStates()
→ render()
Each step builds on the previous.
3. Data Structures
Heavily uses typed arrays:
pack.cells.h = new Uint8Array(n); // Heights
pack.cells.s = new Uint16Array(n); // State IDs
See Data Model for details.
4. Rendering
Uses D3.js for SVG manipulation:
d3.select('#states').selectAll('path')
.data(pack.states)
.enter().append('path')
.attr('d', drawStatePath)
.attr('fill', d => d.color);
Debugging Tips
Browser DevTools
Console:
- View errors and warnings
- Log values:
console.log(grid) - Inspect objects:
console.dir(pack.states[0])
Debugger:
- Set breakpoints in sources
- Step through code
- Inspect variables
Performance:
- Profile generation
- Identify slow functions
- Monitor memory usage
Common Issues
Problem: Changes not appearing
- Hard refresh (Ctrl+Shift+R)
- Clear browser cache
- Check console for errors
Problem: Map not generating
- Check console for errors
- Verify module loading order
- Test with lower cell count
Problem: Performance issues
- Reduce cell count
- Profile in DevTools
- Check for infinite loops
Testing
Currently, the project lacks automated tests. Manual testing is required:
Test Checklist
- Map generates successfully
- All layers render correctly
- Editors open without errors
- Changes persist after save/load
- Export formats work
- No console errors
Test Different Scenarios
- Different templates
- Different cell counts
- Edge cases (very high/low values)
- Browser compatibility
Quick Start Tutorial
Tutorial: Adding a Custom Biome
This tutorial shows how to add a new biome type called "Jungle".
Step 1: Define Biome Data
Edit modules/biomes.js:
// Add to biomesData.i array
14 // New ID for Jungle
// Add to biomesData.name array
"Jungle"
// Add to biomesData.color array
"#2d5016" // Dark green
// Add to biomesData.habitability array
50 // Medium habitability
// Add to other arrays...
Step 2: Update Biome Matrix
Add logic to assign "Jungle" biome:
// In high temp + high precipitation
if (temp > 80 && prec > 200) {
return 14; // Jungle
}
Step 3: Test
- Reload the application
- Generate a new map
- Look for jungle biomes in hot, wet regions
- Check if rendering works correctly
Step 4: Add Icons (Optional)
Add jungle-specific relief icons in modules/relief-icons.js.
Congratulations! You've added a custom biome.
Tutorial: Creating a Simple Editor
This tutorial shows how to create a basic editor dialog.
Step 1: Create Editor File
Create modules/ui/my-editor.js:
"use strict";
function editMyFeature() {
// Create dialog
$("#myEditor").dialog({
title: "My Feature Editor",
width: 400,
height: 300,
buttons: {
Apply: applyChanges,
Close: function() { $(this).dialog("close"); }
}
});
function applyChanges() {
// Implement your logic
const value = $("#myInput").val();
console.log("Applied:", value);
}
}
Step 2: Add HTML Dialog
In index.html, add:
<div id="myEditor" class="dialog">
<label>My Setting:</label>
<input id="myInput" type="text" />
</div>
Step 3: Include Script
In index.html, add:
<script src="modules/ui/my-editor.js"></script>
Step 4: Add Menu Item
Add button to toolbar or menu to call editMyFeature().
Step 5: Test
Click the button and verify dialog opens.
Contributing
Ways to Contribute
- Report Bugs - Use GitHub Issues
- Suggest Features - Use Discussions
- Improve Documentation - Submit PR with doc improvements
- Fix Bugs - Pick an issue and submit a fix
- Add Features - Implement new functionality
- Share Maps - Inspire others on Reddit
Contribution Guidelines
Before Contributing
-
Read the documentation
-
Check existing issues
- Avoid duplicates
- Discuss major changes first
-
Start small
- Begin with minor changes
- Get familiar with codebase
- Build up to larger features
Pull Request Process
- Fork the repository
- Create a branch (
feature/my-feature) - Make changes with clear commits
- Test thoroughly
- Update documentation if needed
- Submit pull request with clear description
- Respond to feedback
Code Review
Maintainers will review your PR and may:
- Request changes
- Suggest improvements
- Merge if approved
Be patient and receptive to feedback!
Community Guidelines
Be respectful:
- Kind and constructive communication
- Welcome newcomers
- Help others learn
Stay on topic:
- Keep discussions relevant
- Use appropriate channels
Share knowledge:
- Document your solutions
- Help others with issues
- Create tutorials
Follow the Code of Conduct: See CODE_OF_CONDUCT.md
Resources
Documentation
- Home - Wiki home
- Architecture - System design
- Data Model - Data structures
- Generation Process - How maps are created
- Modules Reference - Module documentation
- Features and UI - Feature guide
External Resources
Inspiration:
- Generating Fantasy Maps - Martin O'Leary
- Polygonal Map Generation - Amit Patel
- Here Dragons Abound - Scott Turner
Tools:
Getting Help
Questions?
- Ask on Discord
- Post on Reddit
- Search GitHub Issues
Bug Reports?
- Use GitHub Issues
- Include steps to reproduce
- Provide browser/version info
- Share console errors
Feature Requests?
- Use Discussions
- Describe use case
- Explain expected behavior
Private Inquiries?
- Email: azgaar.fmg@yandex.by
Next Steps
For Users
- Experiment - Try different templates and options
- Explore editors - Customize every aspect
- Share your maps - Post to community
- Learn advanced features - 3D view, submaps, etc.
For Developers
- Read the codebase - Explore key modules
- Make small changes - Build confidence
- Fix a bug - Pick from issues
- Add a feature - Implement something new
- Improve docs - Help others learn
Welcome to the Community!
Whether you're creating maps for your D&D campaign, writing a fantasy novel, or contributing code, we're glad you're here!
Happy mapping! 🗺️
FAQ
Q: Is it really free? A: Yes! Completely free and open source.
Q: Can I use maps commercially? A: Yes! The MIT license allows commercial use.
Q: Do I need to credit the generator? A: Not required, but appreciated!
Q: Can I run it offline? A: Yes, use the desktop version or host locally.
Q: How do I report bugs? A: Use GitHub Issues.
Q: Can I contribute if I'm new to coding? A: Absolutely! Start with documentation or small bug fixes.
Q: Where can I see examples? A: Check the Reddit community for amazing maps!
Q: Is there a mobile app? A: Not currently, but the web version works on mobile browsers.
Q: Can I import my own data? A: Yes, see export/import features for JSON data.
Q: How can I support the project? A: Patreon or contribute code!
For more questions, visit the community channels!