Skip to content

Instantly share code, notes, and snippets.

@gamma235
Last active August 29, 2015 14:02
Show Gist options
  • Save gamma235/a6a1c9b1f4857d10a59d to your computer and use it in GitHub Desktop.
Save gamma235/a6a1c9b1f4857d10a59d to your computer and use it in GitHub Desktop.
(ns samsara.core
(:import java.util.Date))
(def sensual-objects (atom #{{:G__8279 [:neutral :thought]}}))
(def mindfulness (atom 44444))
(def karmic-history (atom []))
(def faculties (atom {:faith 0 :energy 0 :concentration 0 :wisdom 0}))
(def ignorance (atom 88888))
(defn map-span
"useful helper for mapping over the faculties when being is mindful"
[m f]
(into {} (for [[k v] m] [k (f v)])))
;; Strengths will be used later, after I implement the 7 enlightenment factors, but is idle right now
(defn strengths?
"This helper determines if the faculties are strengths yet. the outcome has implications for the rate of advancement to path-entry"
[]
(let [bools (for [[k v] @faculties] (if (> v 100) true false))]
(every? true? bools)))
(defn contact
"Simulates mental contact with an object. This is the most important function because it is the entry point for
an IO stream drawing in data from 6 unique channels, representing the 5 senses and the mental apparatus of a being.
In a non-prototypical implementation the function would process carefully selected inputs from this data-stream,
one by one, in an infinite loop. I use random numbers and gensyms here to simulate perception, but in reality
object recognition or prioritizing algorithms would be used to determine which particular events are chosen for
contact and how they are named. Additionally, that which is percieved/felt is a unique combination of one's past karma
and the nature of the current data-stream. It is in this sense that the phenomenology of a human can be modeled as
a finite state machine. The hard problem, of course, is writing an algorithm that can sensitively percieve abstract
qualities such as mine-ness and patience, as opposed to simple objects. That problem is not dealt with here, as simply
the bare quality of the object is dealt with, insofar as it relates to feeling, the result of karma. This corresponds
to the middle part of the description of dependent-origination: consciousness, sense-gate and object combine to give rise to contact, which immediately gives rise to perception and feeling."
[]
(let [random (rand-int 2)
feelings [:pleasant :unpleasant :neutral]
consciousness [:sight :sound :touch :taste :smell :thought]
perception (if (even? random) (apply key (rand-nth (vec @sensual-objects))) (keyword (gensym)))
mental-datum []]
{perception
(conj mental-datum
(rand-nth feelings)
(rand-nth consciousness))}))
(defn mindful?
"determines whether being is applying mindfulness to object, and alters mindfulness level accordingly. Returns karmic potency as a bool."
[]
(let [random (rand-int 88888)
karmically-potent? (if (> @mindfulness random) true false)]
(if karmically-potent?
(swap! mindfulness inc)
(swap! mindfulness dec))
karmically-potent?))
;; this returns the call to contact as "result". It is useful for testing, but can be removed.
(defn thought-moment
"updates being state according to whether being is mindful and karmic fruit is positive or negative"
[]
(let [mindful (mindful?)
result (contact)]
(if mindful
(reset! faculties (map-span @faculties inc))
(swap! sensual-objects conj result))
(swap! karmic-history conj [result (Date.)])
result))
;; testing it out
(strengths?)
(contact)
(thought-moment)
@mindfulness
@sensual-objects
@karmic-history
@faculties
(take 200 (lazy-seq @karmic-history))
(repeatedly 20000 thought-moment)
(strengths?)
@mindfulness
@sensual-objects
@karmic-history
@faculties
(take 200 (lazy-seq @karmic-history))
(comment (def dependent-origination [:suffering
:rebirth
:becoming
{:clinging [:self-doctrine :rites-rituals :views]}
{:craving [:sensuous :destructive :becoming]}
{:feeling [:pleasant :unpleasant :neutral]}
:contact
{:sense-gates [:eye :ear :skin :tongue :mind :nose]}
{:consciousness [:see :hear :touch :taste :think :smell]}
{:mind-body [:consiousness :feeling true :4-elements]}
{:fabrications [:mental :verbal :bodily]}
:ignorance]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment