Skip to content

Instantly share code, notes, and snippets.

@patham9
patham9 / gist:589fd717bf9ee0ae4e0ff6ec73bb1da6
Created August 17, 2025 12:34
MM2/MORK: getting started
Needed:
pip3 install requests-sse
client.py:
Replace /target/debug/mork_server with /target/release/mork_server
@patham9
patham9 / gist:56ccaf963266406c33d27826ee6a6f4b
Created July 31, 2025 22:07
PLN deriver efficiency: use derivations only for inference in each recursion.
;; Exhaustive-until-depth deriver
(= (Derive $derivationsLast $beliefs $depth $maxdepth)
(if (> $depth $maxdepth)
$beliefs
(let $derivations
(collapse (superpose ((let* (((Sentence $x $Ev1) (superpose $derivationsLast))
((Sentence $y $Ev2) (superpose $beliefs))
($stamp (TupleConcat $Ev1 $Ev2)))
(if (StampDisjoint $Ev1 $Ev2)
(case (|- $x $y) ((($T $TV) (Sentence ($T $TV) $stamp)))) (empty)))
;PLN for MeTTa-Morph, based on PLN 0f2e0008f82cefdf53585d0bc103489e00b77de7 of June 12, 2025.
;What made it work:
;1. mettamorph extension for (empty)
;2. removal of functions that are already in the stdlib of mettamorph
;3. Replaced if occurrences with If of Mettamorph
;4. Represented implication sentences with functions to avoid floating vars
;mettamorph extension:
(= (empty) ()) ;todo make it call amb-failure-continuation
@patham9
patham9 / gist:b89ef4b8d7d40782766889b833ac5495
Created May 20, 2025 09:06
MeTTa Motto (rel extraction test)
!(import! &self motto)
!(let $x ((chat-gpt-agent "gpt-4o-mini")
(system "You are an assistant. Answer as a tuple (R a b) (no commas) where R in {near} and a,b in {human, robot, chair}")
(user "the robot is close to the chair!"))
(let $L ((py-dot ((py-dot ((py-dot $x replace) "(" "" ) replace) ")" "") split) " ")
(let ($R $a $b)
(((py-dot $L __getitem__) 0)
((py-dot $L __getitem__) 1)
((py-dot $L __getitem__) 2))
(EXTRACTED: (R = $R) (a = $a) (b = $b)))))
@patham9
patham9 / gist:276120eaf098bb2eeec274cff01a056f
Last active December 11, 2024 20:30
ROS2 Nav2 goal abortion
[component_container_isolated-10] [INFO] [1733948499.855052061] [controller_server]: Received a goal, begin computing control effort.
[component_container_isolated-10] [INFO] [1733948502.957650038] [controller_server]: Passing new path to controller.
[component_container_isolated-10] [ERROR] [1733948503.930128544] [planner_server]: Failed to create a plan from potential when a legal potential was found. This shouldn't happen.
[component_container_isolated-10] [WARN] [1733948503.930219308] [planner_server]: GridBased plugin failed to plan from (1.36, 1.68) to (2.80, 1.17): "Failed to create plan with tolerance of: 0.500000"
[component_container_isolated-10] [WARN] [1733948503.930227143] [planner_server]: [compute_path_to_pose] [ActionServer] Aborting handle.
[component_container_isolated-10] [INFO] [1733948503.956205964] [controller_server]: Passing new path to controller.
[component_container_isolated-10] [ERROR] [1733948503.956302770] [controller_server]: Path is empty.
[component_container_isolated-10] [INF
@patham9
patham9 / airis.py
Last active December 27, 2023 17:28
Berick Cook's AIRIS replicated by Patrick Hammer from his video and discussions with him.
from collections import deque
from copy import deepcopy
import sys
import time
import random
# THE WORLD
world = """
oooooooooooo
o o f o
@patham9
patham9 / parallel-amb.scm
Last active November 30, 2023 18:51
Parallel amb (Chicken Scheme)
(define-syntax amb-parallel
(syntax-rules ()
((_ arg1 arg2)
(receive (pipefd0 pipefd1) (create-pipe)
(let ((pid (process-fork)))
(if (eq? pid 0)
(let ((pipefd1_port (open-output-file* pipefd1)))
(write (amb-collect arg2) pipefd1_port) ;we can't backtrack into parent so we collect all of this level's results
(close-output-port pipefd1_port)
(exit 0)) ;child is done
@patham9
patham9 / parallel-list.scm
Last active November 30, 2023 18:17
Parallel list (Chicken Scheme)
(import (chicken process) (chicken file posix))
(define-syntax parallel-list
(syntax-rules ()
((_ arg1 arg2)
(receive (pipefd0 pipefd1) (create-pipe)
(let ((pid (process-fork)))
(if (eq? pid 0)
(begin (write arg1 (open-output-file* pipefd1))
(exit 0)) ;child is done
@patham9
patham9 / parallel-amb.scm
Last active November 30, 2023 18:05
Parallel amb
(import (chicken process) (chicken string) (chicken file posix) amb)
(define-syntax amb-parallel
(syntax-rules ()
((_ arg1 arg2)
(let-values (((pipefd0 pipefd1) (create-pipe)))
(let ((pid (process-fork)))
(begin (if (eq? pid 0)
(begin (file-write pipefd1 (string-append (->string arg1) "\n"))
(exit 0)) ;child is done
@patham9
patham9 / gist:9af1fb750ed37dd3b0c31c3740e7ccd9
Last active November 7, 2023 18:52
Mettamorph speedup (Processor: 1,6 GHz Dual-Core Intel Core i5, OS: macOS Monterey)
python3 timing.py
Starting 4 tests with 10 runs each, grab a coffee!
==
Compilation started.
Compilation complete.
TEST: !(factorial 30)
[265252859812191058636308480000000]
[265252859812191058636308480000000]
........
Time MeTTa: avg=3.9196492433547974 seconds, var=0.019423207564014434