From d6f335ed8b8cc4d79135b5243a8146137ba054a5 Mon Sep 17 00:00:00 2001 From: Mark Evenson Date: Sat, 13 Aug 2022 09:09:08 +0200 Subject: [PATCH] mevenson: start adding Glacier and Inkingut implementations --- mevenson/glacier/glacier.lisp | 13 +++++++++++++ mevenson/inkingut/inkingut.lisp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 mevenson/glacier/glacier.lisp create mode 100644 mevenson/inkingut/inkingut.lisp diff --git a/mevenson/glacier/glacier.lisp b/mevenson/glacier/glacier.lisp new file mode 100644 index 0000000..6be0e9d --- /dev/null +++ b/mevenson/glacier/glacier.lisp @@ -0,0 +1,13 @@ +(in-package :cl-user) + +(defparameter k 20 + "Number of nodes to query") + +;;; query +(defun query (nodes) + (let ((query + (query-set nodes )))) + +(defun query-set (nodes k)) + + diff --git a/mevenson/inkingut/inkingut.lisp b/mevenson/inkingut/inkingut.lisp new file mode 100644 index 0000000..efce1a8 --- /dev/null +++ b/mevenson/inkingut/inkingut.lisp @@ -0,0 +1,33 @@ +;;;; Constraint: you can't peek at the total without voting. +;;;; N.b. this constraint is currently violated as anyone who has voted, +;;;; may retain a reference to the current vote tallies + + ;;; Simple multi-agents simulation with closures: after evaluation, + ;;; the environment contains a closure over an array specialized on + ;;; bits for accumulation of the storage +(let* ((vote-types ;; a poor-man's typing system, but we only have two elements + ;; first value is an affirmative vote; the second a negative + #(t nil)) + (length ;; total number of voters + #+(or) + (expt 2 8) ;; a safe value for testing + (expt 2 33)) ;; challenging: on the order of 10^10 + (votes + (make-array length :element-type 'cl:bit))) + (defun consensus-agent-p (vote) + (equalp vote (first vote-types))) + (defun get-vote (id) + (aref id votes)) + (defun record-vote (id vote) + (incf + (get-vote id) + ;; this is weird: there is an obvious logical shortcut, but does + ;; it express less is the question… + (cond + ((if (consensus-agent-p vote) + 1 + -1) + (t + 1)))) + (values votes ;; vote record is the primary value + length))) ;; length is currently redundant, but in the future we may be able to adjust the underlying vector