Skip to content

Commit

Permalink
- Finished the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aPixelInSpace committed Mar 18, 2021
1 parent 0d35f29 commit ada7f30
Show file tree
Hide file tree
Showing 34 changed files with 692 additions and 122 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
An easy-to-use, composable and configurable maze generator and solver. Several types of grid tiles with multiple possible shapes.

## Usage
You may visit https://mazes.apixelinspace.com to randomly generate a few examples (website in preview version, work in progress)

The CLI and the documentation are coming soon : https://github.com/aPixelInSpace/F-a-maze-ing/wiki.
To use the CLI, check the [documentation](https://github.com/aPixelInSpace/F-a-maze-ing/wiki).

You may visit https://mazes.apixelinspace.com to randomly generate a few examples (website in preview version, work in progress)

## Examples

Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
theme: jekyll-theme-architect
theme: jekyll-theme-cayman
4 changes: 2 additions & 2 deletions src/Mazes.CLI/Canvas/ArrayOfA/Disk.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ let verb = "s-disk"
[<Verb(verb, isDefault = false, HelpText = "Disk shape")>]
type Options = {
[<Option('r', "rings", Required = true, HelpText = "The number of rings.")>] rings : int
[<Option('w', "ratio", Required = true, HelpText = "Width/height ratio." )>] ratio : float
[<Option('c', "center", Required = true, HelpText = "Number of cells for the central ring." )>] center : int
[<Option('w', "ratio", Required = false, Default = 1.0, HelpText = "Width/height ratio." )>] ratio : float
[<Option('c', "center", Required = false, Default = 3, HelpText = "Number of cells for the central ring." )>] center : int
}

let handleVerb (options : Parsed<Options>) =
Expand Down
2 changes: 1 addition & 1 deletion src/Mazes.CLI/Maze/GrowingTreeSpiral.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Options = {
[<Option(Default = 1.0, HelpText = "Probability between 0.0 and 1.0 to choose the neighbor that will make a spiral")>] spiralWeight : float
[<Option(Default = 1.0, HelpText = "Probability between 0.0 and 1.0 to make perfect spiral (as best as possible)")>] spiralUniformity : float
[<Option(Default = 4, HelpText = "Max length for the spiral")>] spiralMaxLength : int
[<Option(Default = 0.0, HelpText = "Probability between 0.0 (counter-clockwise) and 1.0 (clockwise) to choose revolution of the spiral")>] spiralRevolution : float
[<Option(Default = 0.0, HelpText = "Probability between 0.0 (counter-clockwise) and 1.0 (clockwise) to choose the revolution of the spiral")>] spiralRevolution : float
}

let handleVerb ndStruct (options : Parsed<Options>) =
Expand Down
14 changes: 7 additions & 7 deletions src/Mazes.CLI/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,26 @@ let canvasArray2DToNdStruct argv (canvas : CanvasChoice) =
match canvas with
| Array2DCanvas canvas ->
[|
handleVerb<Grid2D.Ortho.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Ortho.handleVerb canvas |> NDimensionalStructure.create2D)) Grid2D.Ortho.verb argv
handleVerb<Grid2D.Ortho.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Ortho.handleVerb canvas)) Grid2D.Ortho.verb argv
|> Option.map Array2DOrtho

handleVerb<Grid2D.Hex.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Hex.handleVerb canvas |> NDimensionalStructure.create2D)) Grid2D.Hex.verb argv
handleVerb<Grid2D.Hex.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Hex.handleVerb canvas)) Grid2D.Hex.verb argv
|> Option.map Array2DHex

handleVerb<Grid2D.Tri.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Tri.handleVerb canvas |> NDimensionalStructure.create2D)) Grid2D.Tri.verb argv
handleVerb<Grid2D.Tri.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Tri.handleVerb canvas)) Grid2D.Tri.verb argv
|> Option.map Array2DTri

handleVerb<Grid2D.OctaSquare.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.OctaSquare.handleVerb canvas |> NDimensionalStructure.create2D)) Grid2D.OctaSquare.verb argv
handleVerb<Grid2D.OctaSquare.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.OctaSquare.handleVerb canvas)) Grid2D.OctaSquare.verb argv
|> Option.map Array2DOctaSquare

handleVerb<Grid2D.PentaCairo.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.PentaCairo.handleVerb canvas |> NDimensionalStructure.create2D)) Grid2D.PentaCairo.verb argv
handleVerb<Grid2D.PentaCairo.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.PentaCairo.handleVerb canvas)) Grid2D.PentaCairo.verb argv
|> Option.map Array2DPentaCairo

handleVerb<Grid2D.Brick.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Brick.handleVerb canvas |> NDimensionalStructure.create2D)) Grid2D.Brick.verb argv
handleVerb<Grid2D.Brick.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Brick.handleVerb canvas)) Grid2D.Brick.verb argv
|> Option.map Array2DBrick
|] |> pick
| ArrayOfACanvas canvas ->
handleVerb<Grid2D.Polar.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Polar.handleVerb canvas |> NDimensionalStructure.create2D)) Grid2D.Polar.verb argv
handleVerb<Grid2D.Polar.Options, Mazes.Core.Structure.NDimensionalStructure<_,_>> (Some (fun parsed -> parsed |> Grid2D.Polar.handleVerb canvas)) Grid2D.Polar.verb argv
|> Option.map ArrayOfAPolar

type MazeChoice =
Expand Down
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Render/SVG/Brick.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ let verb = "rs-brick"
[<Verb(verb, isDefault = false, HelpText = "Brick SVG render")>]
type Options = {
[<Option('d', "distColor", Required = false, Default = false, HelpText = "Distance coloration")>] distColor : bool
[<Option('s', "solution", Required = false, Default = false, HelpText = "Show solution ?")>] solution : bool
[<Option('e', "entranceExit", Required = false, Default = true, HelpText = "Add an entrance and an exit ?")>] entranceExit : bool
}

let handleVerb (maze : Maze<_,_>) (options : Parsed<Options>) =
let map = maze.createMap maze.NDStruct.GetFirstCellPartOfMaze
let map = lazy (maze.createMap maze.NDStruct.GetFirstCellPartOfMaze)

let colorMap =
match options.Value.distColor with
| true -> Some map
| true -> Some map.Value
| false -> None

BrickGrid.render maze.NDStruct None colorMap None None

let path =
match options.Value.solution with
| true -> (Some (map.Value.ShortestPathGraph.PathFromRootTo maze.NDStruct.GetLastCellPartOfMaze))
| false -> None

let (entrance, exit) =
match options.Value.entranceExit with
| true ->
let (entrance, exit) = (maze.NDStruct.GetFirstCellPartOfMaze, maze.NDStruct.GetLastCellPartOfMaze)
maze.OpenMaze (entrance, exit)
(Some entrance, Some exit)
| false -> (None, None)

BrickGrid.render maze.NDStruct path colorMap entrance exit
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Render/SVG/Hex.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ let verb = "rs-hex"
[<Verb(verb, isDefault = false, HelpText = "Hexagonal SVG render")>]
type Options = {
[<Option('d', "distColor", Required = false, Default = false, HelpText = "Distance coloration")>] distColor : bool
[<Option('s', "solution", Required = false, Default = false, HelpText = "Show solution ?")>] solution : bool
[<Option('e', "entranceExit", Required = false, Default = true, HelpText = "Add an entrance and an exit ?")>] entranceExit : bool
}

let handleVerb (maze : Maze<_,_>) (options : Parsed<Options>) =
let map = maze.createMap maze.NDStruct.GetFirstCellPartOfMaze
let map = lazy (maze.createMap maze.NDStruct.GetFirstCellPartOfMaze)

let colorMap =
match options.Value.distColor with
| true -> Some map
| true -> Some map.Value
| false -> None

HexGrid.render maze.NDStruct None colorMap None None

let path =
match options.Value.solution with
| true -> (Some (map.Value.ShortestPathGraph.PathFromRootTo maze.NDStruct.GetLastCellPartOfMaze))
| false -> None

let (entrance, exit) =
match options.Value.entranceExit with
| true ->
let (entrance, exit) = (maze.NDStruct.GetFirstCellPartOfMaze, maze.NDStruct.GetLastCellPartOfMaze)
maze.OpenMaze (entrance, exit)
(Some entrance, Some exit)
| false -> (None, None)

HexGrid.render maze.NDStruct path colorMap entrance exit
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Render/SVG/OctaSquare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ let verb = "rs-octas"
[<Verb(verb, isDefault = false, HelpText = "Octagonal and square SVG render")>]
type Options = {
[<Option('d', "distColor", Required = false, Default = false, HelpText = "Distance coloration")>] distColor : bool
[<Option('s', "solution", Required = false, Default = false, HelpText = "Show solution ?")>] solution : bool
[<Option('e', "entranceExit", Required = false, Default = true, HelpText = "Add an entrance and an exit ?")>] entranceExit : bool
}

let handleVerb (maze : Maze<_,_>) (options : Parsed<Options>) =
let map = maze.createMap maze.NDStruct.GetFirstCellPartOfMaze
let map = lazy (maze.createMap maze.NDStruct.GetFirstCellPartOfMaze)

let colorMap =
match options.Value.distColor with
| true -> Some map
| true -> Some map.Value
| false -> None

OctaSquareGrid.render maze.NDStruct None colorMap None None

let path =
match options.Value.solution with
| true -> (Some (map.Value.ShortestPathGraph.PathFromRootTo maze.NDStruct.GetLastCellPartOfMaze))
| false -> None

let (entrance, exit) =
match options.Value.entranceExit with
| true ->
let (entrance, exit) = (maze.NDStruct.GetFirstCellPartOfMaze, maze.NDStruct.GetLastCellPartOfMaze)
maze.OpenMaze (entrance, exit)
(Some entrance, Some exit)
| false -> (None, None)

OctaSquareGrid.render maze.NDStruct path colorMap entrance exit
2 changes: 1 addition & 1 deletion src/Mazes.CLI/Render/SVG/Ortho.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Options = {
[<Option('d', "distColor", Required = false, Default = false, HelpText = "Apply distance coloration ?")>] distColor : bool
[<Option('s', "solution", Required = false, Default = false, HelpText = "Show solution ?")>] solution : bool
[<Option('e', "entranceExit", Required = false, Default = true, HelpText = "Add an entrance and an exit ?")>] entranceExit : bool
[<Option('l', "lines", Required = false, Default = Lines.Straight, HelpText = "Type of lines Straight, Circle or Curved). In circle mode only the Width value is considered; in curved mode you can change the curve option to obtain various effects")>] lines : Lines
[<Option('l', "lines", Required = false, Default = Lines.Straight, HelpText = "Type of lines Straight, Circle, Curved or Random). In circle mode only the Width value is considered; in curved mode you can change the curve option to obtain various effects")>] lines : Lines
[<Option(HelpText = "RNG seed, if none is provided a random one is chosen")>] seed : int option
[<Option(Default = 5.0, HelpText = "Curve multiplication factor")>] curveMultFact : float
[<Option(Default = 30, HelpText = "Width of a single cell")>] width : int
Expand Down
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Render/SVG/PentaCairo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ let verb = "rs-pentac"
[<Verb(verb, isDefault = false, HelpText = "Pentagonal 'Cairo' SVG render")>]
type Options = {
[<Option('d', "distColor", Required = false, Default = false, HelpText = "Distance coloration")>] distColor : bool
[<Option('s', "solution", Required = false, Default = false, HelpText = "Show solution ?")>] solution : bool
[<Option('e', "entranceExit", Required = false, Default = true, HelpText = "Add an entrance and an exit ?")>] entranceExit : bool
}

let handleVerb (maze : Maze<_,_>) (options : Parsed<Options>) =
let map = maze.createMap maze.NDStruct.GetFirstCellPartOfMaze
let map = lazy (maze.createMap maze.NDStruct.GetFirstCellPartOfMaze)

let colorMap =
match options.Value.distColor with
| true -> Some map
| true -> Some map.Value
| false -> None

PentaCairoGrid.render maze.NDStruct None colorMap None None

let path =
match options.Value.solution with
| true -> (Some (map.Value.ShortestPathGraph.PathFromRootTo maze.NDStruct.GetLastCellPartOfMaze))
| false -> None

let (entrance, exit) =
match options.Value.entranceExit with
| true ->
let (entrance, exit) = (maze.NDStruct.GetFirstCellPartOfMaze, maze.NDStruct.GetLastCellPartOfMaze)
maze.OpenMaze (entrance, exit)
(Some entrance, Some exit)
| false -> (None, None)

PentaCairoGrid.render maze.NDStruct path colorMap entrance exit
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Render/SVG/Polar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ let verb = "rs-polar"
[<Verb(verb, isDefault = false, HelpText = "Polar SVG render")>]
type Options = {
[<Option('d', "distColor", Required = false, Default = false, HelpText = "Distance coloration")>] distColor : bool
[<Option('s', "solution", Required = false, Default = false, HelpText = "Show solution ?")>] solution : bool
[<Option('e', "entranceExit", Required = false, Default = true, HelpText = "Add an entrance and an exit ?")>] entranceExit : bool
}

let handleVerb (maze : Maze<_,_>) (options : Parsed<Options>) =
let map = maze.createMap maze.NDStruct.GetFirstCellPartOfMaze
let map = lazy (maze.createMap maze.NDStruct.GetFirstCellPartOfMaze)

let colorMap =
match options.Value.distColor with
| true -> Some map
| true -> Some map.Value
| false -> None

PolarGrid.render maze.NDStruct None colorMap None None

let path =
match options.Value.solution with
| true -> (Some (map.Value.ShortestPathGraph.PathFromRootTo maze.NDStruct.GetLastCellPartOfMaze))
| false -> None

let (entrance, exit) =
match options.Value.entranceExit with
| true ->
let (entrance, exit) = (maze.NDStruct.GetFirstCellPartOfMaze, maze.NDStruct.GetLastCellPartOfMaze)
maze.OpenMaze (entrance, exit)
(Some entrance, Some exit)
| false -> (None, None)

PolarGrid.render maze.NDStruct path colorMap entrance exit
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Render/SVG/Tri.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ let verb = "rs-tri"
[<Verb(verb, isDefault = false, HelpText = "Triangular SVG render")>]
type Options = {
[<Option('d', "distColor", Required = false, Default = false, HelpText = "Distance coloration")>] distColor : bool
[<Option('s', "solution", Required = false, Default = false, HelpText = "Show solution ?")>] solution : bool
[<Option('e', "entranceExit", Required = false, Default = true, HelpText = "Add an entrance and an exit ?")>] entranceExit : bool
}

let handleVerb (maze : Maze<_,_>) (options : Parsed<Options>) =
let map = maze.createMap maze.NDStruct.GetFirstCellPartOfMaze
let map = lazy (maze.createMap maze.NDStruct.GetFirstCellPartOfMaze)

let colorMap =
match options.Value.distColor with
| true -> Some map
| true -> Some map.Value
| false -> None

TriGrid.render maze.NDStruct None colorMap None None

let path =
match options.Value.solution with
| true -> (Some (map.Value.ShortestPathGraph.PathFromRootTo maze.NDStruct.GetLastCellPartOfMaze))
| false -> None

let (entrance, exit) =
match options.Value.entranceExit with
| true ->
let (entrance, exit) = (maze.NDStruct.GetFirstCellPartOfMaze, maze.NDStruct.GetLastCellPartOfMaze)
maze.OpenMaze (entrance, exit)
(Some entrance, Some exit)
| false -> (None, None)

TriGrid.render maze.NDStruct path colorMap entrance exit
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Structure/Grid2D/Brick.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

module Mazes.CLI.Structure.Grid2D.Brick

open System
open CommandLine
open Mazes.Core.Structure
open Mazes.Core.Structure.Grid2D.Type

[<Literal>]
Expand All @@ -11,10 +13,23 @@ let verb = "g-brick"
[<Verb(verb, isDefault = false, HelpText = "Brick grid")>]
type Options = {
[<Option('e', "empty", Required = false, Default = false, HelpText = "If true, the grid will have no internal connections")>] empty : bool
[<Option('s', "seed", Required = false, HelpText = "RNG seed, if none is provided a random one is chosen")>] seed : int option
[<Option('w', "weave", Required = false, Default = 0.0, HelpText = "Value between 0.0 and 1.0 to generate 'bridges' / weave the maze")>] weave : float
}

let handleVerb canvas (options : Parsed<Options>) =
canvas
|> match options.Value.empty with
| true -> Brick.Grid.createEmptyBaseGrid
| false -> Brick.Grid.createBaseGrid
let nStruct =
canvas
|> match options.Value.empty with
| true -> Brick.Grid.createEmptyBaseGrid
| false -> Brick.Grid.createBaseGrid
|> NDimensionalStructure.create2D

let rng =
match options.Value.seed with
| Some seed -> Random(seed)
| None -> Random()

nStruct.Weave rng options.Value.weave

nStruct
23 changes: 19 additions & 4 deletions src/Mazes.CLI/Structure/Grid2D/Hex.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

module Mazes.CLI.Structure.Grid2D.Hex

open System
open CommandLine
open Mazes.Core.Structure
open Mazes.Core.Structure.Grid2D.Type

[<Literal>]
Expand All @@ -11,10 +13,23 @@ let verb = "g-hex"
[<Verb(verb, isDefault = false, HelpText = "Hexagonal grid")>]
type Options = {
[<Option('e', "empty", Required = false, Default = false, HelpText = "If true, the grid will have no internal connections")>] empty : bool
[<Option('s', "seed", Required = false, HelpText = "RNG seed, if none is provided a random one is chosen")>] seed : int option
[<Option('w', "weave", Required = false, Default = 0.0, HelpText = "Value between 0.0 and 1.0 to generate 'bridges' / weave the maze")>] weave : float
}

let handleVerb canvas (options : Parsed<Options>) =
canvas
|> match options.Value.empty with
| true -> Hex.Grid.createEmptyBaseGrid
| false -> Hex.Grid.createBaseGrid
let nStruct =
canvas
|> match options.Value.empty with
| true -> Hex.Grid.createEmptyBaseGrid
| false -> Hex.Grid.createBaseGrid
|> NDimensionalStructure.create2D

let rng =
match options.Value.seed with
| Some seed -> Random(seed)
| None -> Random()

nStruct.Weave rng options.Value.weave

nStruct
Loading

0 comments on commit ada7f30

Please sign in to comment.