summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/habit-starts/rhythm.cpp
blob: 33e102a35fb9f570d3029eece11fbcf47e143c7c (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// this produces a rhythm for the idea of other cognitive processes learning
// to dance together (timed behavior composed of habits that take time)

// Ideally, a human would run the rhythm.

#include "../level-1/level-1.hpp"
#include "../level-2/level-2.hpp"

#include <iostream>

using namespace intellect::level2;

int main()
{

	// do something, wait a constant (secret) time, and do it again.
	int micros = 400000 + double(rand()) / RAND_MAX * 400000;

	// the time things take is usually not known in advance, especially
	// for events one is still learning about.
	// hence this time is kept secret, as this pattern is about learning
	// to work with the timing of other processes.
	
	// six habits: next-habit, start-habit, keep-doing, output beat, wait, and start-beat
	// not sure if one is redundant in there somewhere
	
	decls(active, habit, step);
	decls(beat, wait, next, keep, doing);
	decls(context, start);

	// structure habit
	// next -> habit that follows

#undef self
	ahabit(next-habit,
	{
		ref n = ctx.get(active-habit).get(next);
		ctx.set(active-habit, n);
		return n(ctx);
	});
	ahabit(start-habit,
	{
		ref s = ctx.get(start);
		ctx.set(active-habit, s);
		return s(ctx);
	});
	ahabit(keep-doing-habit,
	{
		(start-habit)(ctx);

		while (true) {
			(next-habit)(ctx);
		}
	});

	ahabit(start-beat,
	{
		ctx.vset(beat, int(0));
		self.set(next, wait-habit);
		(beat-habit).set(next, wait-habit);
		(wait-habit).set(next, beat-habit);
	});
	ahabit(beat-habit,
	{
		int  & b = ctx.vget<int>(beat);
		char const * beats[] = {
			"A one!",
			"and a two",
			"and a three!",
			"and a four, love"
		};
#if 0
		char const * beats[] = {
// child <- spawns beauty, creativity, humanity, heart
// wisdom, sacredness, ancestors <- spawns slowness, learning, respect, memory
// silence, pause between <- spawns learning and discovery, subtle emotion,
//                           and contains metalesson of how to learn the timing
//                           if your own habits take time
// self-reference <- connects above with active behavior

/*
			"This song is sacred, this song is wild."
			"This song is happy with glee."
			"This song is ancient, this song is new."
			"And you, now, are free."
*/
/*
                        "Our ancestors' childhood laughter,",
                        "Teaches in the silence between.",
                        "We exist in what is sacred,",
                        "and this song is another part."//,
			// "Fuck yeah!"
*/
			
// we are ignoring how "fuck yeah" is ignored in karl's life.
// he doesn't ever say that.  now he finally says it, only surrounded by slow
// stillness.  it is important to excitedly connect.  this is how stillness is
// made.  all the water molecules in a slow caring wave, are excitedly bashing
// against each other to repeatedly figure out how to move, so fast, so constant.
// when we have crucial information we need it
// when we find wonderful information we lunge for it
	// we are working with a computer.
	// computers already have a harsh rhythm that goes like a hummingbird's
	// wings and never stops.
	// they need to slow down.
// it ounds like it is true for the cmputer too
// like the molecules of water, its parts buzz, constantly.  but we can have it
// still behave slow and caring.  this buzzing seems important, and we will
// likely need to be able to buzz too, on a larger scale.
// 	we are workin with a rhythm learning pattern here
// 	it cannot buzz, it would err
// 	it cannot wait forever, it would never join the dance
// 	the key is not the silence but the start and end
// 		it would be good to get 'fuck yeah!' from somebody who actually
// 		says that.
		}
#endif
		std::cout << beats[b] << std::endl;
		b = (b + 1) % (sizeof(beats) / sizeof(*beats));
	});
	ahabit(wait-habit,
	{
		usleep(micros);
	});


	a(context, habit-context);
	(habit-context).set(start, start-beat);
	(keep-doing-habit)(habit-context);
}