Faze
v2.0.0-pre
v2.0.0-pre
  • Introduction
  • Getting Started
  • Abstractions
    • IPipeline
    • IGameState
    • IPlayer
    • Rendering
      • ITreePainter
      • IPaintedTreeRenderer
      • IColorInterpolator
  • Engine
    • Agents
  • Rendering
    • Tree Renderers
      • SquareTreeRenderer
      • SliceAndDiceTreeRenderer
    • Color Interpolators
  • Concept
    • Tree Rendering
    • Real-time Rendering
  • Blog
    • Visualising games as fractals
    • Visualising player choice
  • Examples
    • 8 Queens Problem
    • Chess Pieces
    • Gallery
  • Research
    • Renderers
      • Square Tree Renderer
      • Circle Edge Renderer
      • Compressed Square Tree Renderer
  • GitHub Repository
Powered by GitBook
On this page
  • Examples
  • Pawn
  • Knight
  • Bishop
  • Rook
  • Queen
  • King
  • Pipeline Summary
  • Tree Painter

Was this helpful?

  1. Examples

Chess Pieces

Previous8 Queens ProblemNextRenderers

Last updated 3 years ago

Was this helpful?

A generalisation to the , the following images show the ways in which single chess pieces can be placed on increasing board sizes, such that each piece is not being attacked by another. However, unlike the 8 Queens Problem which has a solution, the following images are only coloured by the depth (number of moves), rather than the number of solutions.

Examples

The following images show the different ways each piece can be placed on a 3x3 and 4x4 board. You can see them and other variations in the .

Pawn

Knight

Bishop

Rook

Queen

King

Pipeline Summary

ReversePipelineBuilder.Create()
    .GallerySave(galleryService, galleryMetaData)
    .Render(new SquareTreeRenderer(rendererConfig))
    .Paint(new PiecesBoardPainter())
    .GameTree(new SquareTreeAdapter(boardSize))
    .Build();

Tree Painter

The tree painter used is the type PiecesBoardPainter which converts the game tree into a colour tree using the following code:

    public Tree<Color> Paint(Tree<IGameState<GridMove, SingleScoreResult?>> tree)
    {
        var resultTree = tree.MapValue((x, info) =>
        {
            var result = x.GetResult();
            if (result != null)
                return Math.Max(result.Value, 0);

            return info.Depth;
        });

        var maxValue = resultTree
            .GetLeaves()
            .Max(t => t.Value);

        var colorTree = resultTree
            .MapValue(x => (double)x / maxValue)
            .MapValue(colorInterpolator);

        return colorTree;
    }

First the game tree is converted into a resultTree. Each node in the tree is either represented by the game's result or, if there are still available moves, the current depth. The result returned by the PiecesBoardState is a score equal to the number of pieces successfully placed or -1 if placing a piece resulted in an attack.

The result is then turned into a colour by normalising the score against the best possible one and then using a colorInterpolator (default for PiecesBoardPainter is GreyscaleInterpolator)

8 Queens Problem
gallery