Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v2 source pure

Package cantiere (v2, "Kasaba Dili") is a Sinopia engine: an isometric maquette of an imaginary town on a drafting sh...

Overview

Package cantiere (v2, "Kasaba Dili") is a Sinopia engine: an isometric maquette of an imaginary town on a drafting sheet, built from a vocabulary of architectural elements — gabled houses, crenellated towers, domes, a bell tower, arcades, gardens with cypresses, a square with a fountain and building sites in red scaffolding — on six plans (Hill Town, Terraces, Courtyard, Coast, Citadel, Ruin), in six materials and four lights. The title block of the sheet carries the token number ("TAV. 42").

It is the successor of Cantiere v1 (p/.../art/cantiere/v1, which stays untouched): the same FNV-1a + splitmix64 streams, a new town. Three streams: seed+"|traits" (the trait draws), seed+"|town" (the 6 x 6 parcel plan, which Traits reads too, so Landmark and Tallest come without rendering) and seed+"|art" (colours and details). frontend/src/engines/cantierev2.ts is a byte-identical TypeScript twin; cantiere_test.gno pins golden vectors that the twin asserts too.

The art reads Input.TokenID (the title block). It never reads heights or moves, so the engine is not living. Pure integer maths: every division is a floor division (fdiv), as in the twin.

Constants 3

const DefaultParams

1const DefaultParams = `{"plan":"Seeded","material":"Seeded","light":"Seeded"}`
source

DefaultParams is the canonical form of the defaults; it renders exactly like "".

const MaxSVGBytes

1const MaxSVGBytes = 28672
source

MaxSVGBytes: the largest output over 10,000 default seeds is about 22 KB (docs/engines/cantiere-v2.md); the 28 KB budget.

const ParamsSchema

1const ParamsSchema = `{"type":"object","properties":{` +
2	`"plan":{"type":"string","title":"Plan","enum":["Seeded","Hill Town","Terraces","Courtyard","Coast","Citadel","Ruin"],"default":"Seeded"},` +
3	`"material":{"type":"string","title":"Material","enum":["Seeded","Tufa","Brick","Travertine","Painted Plaster","Whitewash","Basalt"],"default":"Seeded"},` +
4	`"light":{"type":"string","title":"Light","enum":["Seeded","Morning","Noon","Evening","Night"],"default":"Seeded"}}}`
source

ParamsSchema is the Studio form. Studio sends JSON.stringify of the values in this property order; ValidateParams accepts exactly that or "".

Functions 10

func Manifest

1func Manifest() engine.Manifest
source

Manifest describes the engine. Author and FeeBps are set by the adapter.

func Render

1func Render(in engine.Input) string
source

Render returns the raw SVG for in.Seed, in.Params and in.TokenID.

func SVG

1func SVG(seed string, cfg Config, tokenID string) string
source

SVG renders the artwork for a seed, a config and a token id.

func TavNumber

1func TavNumber(tokenID string) int
source

TavNumber is the sheet number in the title block: TokenID read as a decimal, modulo 100,000 (core's supply cap is 10,000). Anything but ASCII digits is 0, which prints "PROVA" (a proof; Studio renders use "0").

func TraitString

1func TraitString(seed, params string) string
source

TraitString is "Type=Value;…" in TraitTypes order (the golden-vector form shared with the TypeScript twin).

func Traits

1func Traits(in engine.Input) []engine.Trait
source

Traits returns the eight traits of in.Seed in TraitTypes order. It never renders: six draws and the 36-parcel town plan.

func ValidateParams

1func ValidateParams(params string) error
source

ValidateParams accepts "" (the showcase defaults) and the canonical JSON.

func Defaults

1func Defaults() Config
source

Defaults is the showcase look (params "").

func ParseParams

1func ParseParams(params string) (Config, error)
source

ParseParams accepts "" or the canonical JSON Studio produces, nothing else.

func TraitsOf

1func TraitsOf(seed string, cfg Config) TraitSet
source

TraitsOf returns the decoded traits of a seed under cfg.

Types 2

type Config

struct
1type Config struct {
2	Plan, Material, Light int
3}
source

Config is a parsed params string; -1 means drawn from the seed.

type TraitSet

struct
1type TraitSet struct {
2	Plan, Material, Light, Scaffolding, Landmark, Event, Tallest, Rarity string
3	Score                                                                int
4}
source

TraitSet is the decoded traits of a seed; the SVG and the trait list both read it, so picture and metadata cannot disagree.

Dependencies

Source Files 2