docs: regenerate site from f094acfdb5
This commit is contained in:
commit
63c5ed9baf
975 changed files with 55427 additions and 0 deletions
60
random-seed.html
Normal file
60
random-seed.html
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Random.seed — Ludic</title>
|
||||
<meta name="description" content="Seed the random generator so runs are reproducible.">
|
||||
<link rel="stylesheet" href="base.css">
|
||||
<link rel="stylesheet" href="docs.css">
|
||||
</head>
|
||||
<body>
|
||||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||
<main class="wrap item">
|
||||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-random.html">Random</a> <span>›</span> <span class="here">Random.seed</span></div>
|
||||
<div class="item-head">
|
||||
<span class="kind-badge kind-method">method</span>
|
||||
<h1 id="top">Random.seed</h1>
|
||||
</div>
|
||||
<code class="sig">Random.seed(value)</code>
|
||||
<div class="desc"><p>Sets the starting state of the random-number generator. Every subsequent call to <code>Random.range</code> and <code>Random.chance</code> then follows a fixed, repeatable sequence for that seed, so seeding with the same <code>value</code> makes two runs produce identical randomness — invaluable for tests, replays, and debugging. Seed once, typically in a <code>Start</code>-phase handler before you draw any random numbers. Use different seed values (for example a frame count or a level number) when you want variety between runs.</p></div>
|
||||
<div class="params"><h2>Parameters</h2><div class="param" id="param-value"><code class="pname">value</code><span class="pdesc">the seed; the same value reproduces the same sequence</span></div></div>
|
||||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ReproducibleField {
|
||||
property Position { column: int = 0, row: int = 0 }
|
||||
model Star { Position }
|
||||
|
||||
const GRID_WIDTH: int = 20
|
||||
const GRID_HEIGHT: int = 15
|
||||
const TILE_SIZE: int = 16
|
||||
|
||||
handler SeedField phase Start {
|
||||
Random.seed(value: 42)
|
||||
for spawn_index in 0 .. 8 {
|
||||
spawn Star {
|
||||
Position {
|
||||
column: Random.range(low: 0, high: GRID_WIDTH - 1),
|
||||
row: Random.range(low: 0, high: GRID_HEIGHT - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handler DrawWorld phase Render {
|
||||
Screen.clear(Color.MidnightBlue)
|
||||
for (Position) in query [Position, {Star}] {
|
||||
Screen.fill_rectangle(
|
||||
x: Position.column * TILE_SIZE,
|
||||
y: Position.row * TILE_SIZE,
|
||||
width: TILE_SIZE,
|
||||
height: TILE_SIZE,
|
||||
color: Color.White)
|
||||
}
|
||||
Screen.show()
|
||||
}
|
||||
}</pre></div>
|
||||
|
||||
<a class="back" href="api.html">← All symbols</a>
|
||||
</main>
|
||||
<script src="ludic-highlight.js"></script>
|
||||
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||
</body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue