docs(0.S): the doc fences migrated by ludic migrate state; LANGUAGE.md's state section says what the tool and the checker do now; no module-level var left in the docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
19fcf60599
commit
a476ec7976
79 changed files with 481 additions and 355 deletions
|
|
@ -18,10 +18,12 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program FrameHits {
|
||||
var hits: []int = new []int
|
||||
state FrameHitsState {
|
||||
hits: []int = new []int
|
||||
}
|
||||
|
||||
handler BeginFrame phase Update {
|
||||
List.clear(hits) # start the frame with an empty list
|
||||
handler BeginFrame(frame_hits_st: FrameHitsState) phase Update {
|
||||
List.clear(frame_hits_st.hits) # start the frame with an empty list
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -19,12 +19,14 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Visited {
|
||||
var seen: []int = new []int
|
||||
state VisitedState {
|
||||
seen: []int = new []int
|
||||
}
|
||||
|
||||
handler Step phase Update {
|
||||
handler Step(visited_st: VisitedState) phase Update {
|
||||
let tile = 42
|
||||
if not List.contains(seen, tile) {
|
||||
List.push(seen, tile)
|
||||
if not List.contains(visited_st.seen, tile) {
|
||||
List.push(visited_st.seen, tile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Queue {
|
||||
var waiting: []int = new []int
|
||||
state QueueState {
|
||||
waiting: []int = new []int
|
||||
}
|
||||
|
||||
handler Serve phase Update {
|
||||
if List.len(waiting) > 0 {
|
||||
let next = List.first(waiting)
|
||||
handler Serve(queue_st: QueueState) phase Update {
|
||||
if List.len(queue_st.waiting) > 0 {
|
||||
let next = List.first(queue_st.waiting)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,14 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program FindSlot {
|
||||
var ids: []int = new []int
|
||||
state FindSlotState {
|
||||
ids: []int = new []int
|
||||
}
|
||||
|
||||
handler Locate phase Update {
|
||||
let slot = List.index_of(ids, 99)
|
||||
handler Locate(find_slot_st: FindSlotState) phase Update {
|
||||
let slot = List.index_of(find_slot_st.ids, 99)
|
||||
if slot >= 0 {
|
||||
List.swap(ids, slot, List.len(ids) - 1)
|
||||
List.swap(find_slot_st.ids, slot, List.len(find_slot_st.ids) - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Trail {
|
||||
var points: []int = new []int
|
||||
state TrailState {
|
||||
points: []int = new []int
|
||||
}
|
||||
|
||||
handler Head phase Update {
|
||||
if List.len(points) > 0 {
|
||||
let newest = List.last(points)
|
||||
handler Head(trail_st: TrailState) phase Update {
|
||||
if List.len(trail_st.points) > 0 {
|
||||
let newest = List.last(trail_st.points)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program CountEnemies {
|
||||
var enemies: []int = new []int
|
||||
state CountEnemiesState {
|
||||
enemies: []int = new []int
|
||||
}
|
||||
|
||||
handler Report phase Update {
|
||||
let n = List.len(enemies)
|
||||
handler Report(count_enemies_st: CountEnemiesState) phase Update {
|
||||
let n = List.len(count_enemies_st.enemies)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program UndoStack {
|
||||
var history: []int = new []int
|
||||
state UndoStackState {
|
||||
history: []int = new []int
|
||||
}
|
||||
|
||||
handler Undo phase Update {
|
||||
if List.len(history) > 0 {
|
||||
let last_action = List.pop(history)
|
||||
handler Undo(undo_stack_st: UndoStackState) phase Update {
|
||||
if List.len(undo_stack_st.history) > 0 {
|
||||
let last_action = List.pop(undo_stack_st.history)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,12 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program Collect {
|
||||
var picked: []int = new []int
|
||||
state CollectState {
|
||||
picked: []int = new []int
|
||||
}
|
||||
|
||||
handler Grab phase Update {
|
||||
List.push(picked, 7)
|
||||
handler Grab(collect_st: CollectState) phase Update {
|
||||
List.push(collect_st.picked, 7)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program PathOrder {
|
||||
var path: []int = new []int
|
||||
state PathOrderState {
|
||||
path: []int = new []int
|
||||
}
|
||||
|
||||
handler Finalize phase Update {
|
||||
handler Finalize(path_order_st: PathOrderState) phase Update {
|
||||
# path was built from the goal back to the start
|
||||
List.reverse(path) # now start -> goal
|
||||
List.reverse(path_order_st.path) # now start -> goal
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -20,13 +20,15 @@ Parameters:
|
|||
|
||||
```ludic
|
||||
program RemoveFast {
|
||||
var actors: []int = new []int
|
||||
state RemoveFastState {
|
||||
actors: []int = new []int
|
||||
}
|
||||
|
||||
handler Kill phase Update {
|
||||
handler Kill(remove_fast_st: RemoveFastState) phase Update {
|
||||
let dead = 2
|
||||
let last = List.len(actors) - 1
|
||||
List.swap(actors, dead, last) # move it to the end...
|
||||
let removed = List.pop(actors) # ...then drop it
|
||||
let last = List.len(remove_fast_st.actors) - 1
|
||||
List.swap(remove_fast_st.actors, dead, last) # move it to the end...
|
||||
let removed = List.pop(remove_fast_st.actors) # ...then drop it
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue