package tiny_libs
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
From-scratch libraries for teaching: graphics, audio, compression, crypto, networking and more
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.3.6.tar.gz
md5=7c636383d146d30ac6f2fa234a6253c8
sha512=c79f3823c5f8f57e5038eb640d487c61168b84aa07c61999d6622ef9fd0c890e2b03b4c6a7cdbbe9352a49e25dda00ac7bb14693cee8e3d7beeed251351a2af0
doc/src/tiny_libs.ai_decision/Behavior.ml.html
Source file Behavior.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48(* Claude Code * * Copyright (C) 2026 Yoann Padioleau * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * (LGPL) as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. *) type ('context, 'action) t = | Action of string * 'action | Condition of string * ('context -> bool) | Sequence of ('context, 'action) t list | Selector of ('context, 'action) t list | Not of ('context, 'action) t (* one evaluation: success or not, the action decided (the last one on * the successful way), and the nodes visited, most recent first *) let rec eval (tree : ('context, 'action) t) (c : 'context) (seen : (string * bool) list) : bool * 'action option * (string * bool) list = match tree with | Action (label, a) -> (true, Some a, (label, true) :: seen) | Condition (label, q) -> let ok = q c in (ok, None, (label, ok) :: seen) | Sequence children -> let rec go decided seen = function | [] -> (true, decided, seen) | child :: rest -> let ok, a, seen = eval child c seen in if not ok then (false, None, seen) else go (if a = None then decided else a) seen rest in go None seen children | Selector children -> let rec go seen = function | [] -> (false, None, seen) | child :: rest -> let ok, a, seen = eval child c seen in if ok then (true, a, seen) else go seen rest in go seen children | Not child -> let ok, _, seen = eval child c seen in (not ok, None, seen) let decide tree c = match eval tree c [] with true, a, _ -> a | false, _, _ -> None let path tree c = let _, _, seen = eval tree c [] in List.rev seen
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>