Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.43 KB | None | 0 0
  1. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. // Type Defines +
  3. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4.  
  5.  
  6. #define Void 0
  7. #define Empty 1
  8. #define Res 2
  9. #define TYPE_COUNT 3
  10.  
  11.  
  12. //==============================================================================
  13. // |
  14. // = element Res |
  15. // |
  16. //==============================================================================
  17.  
  18. //------------------------------------------------------------------------------
  19. // == Rules |
  20. //------------------------------------------------------------------------------
  21. /* Rule 1:
  22. ................................................................................
  23.  
  24. _@ -> @_
  25.  
  26.  
  27.  
  28. ................................................................................
  29. */
  30.  
  31. bool Res_rs1_r1_given_keycode64(int _cursn) { /* @ */
  32. return true;
  33. }
  34. bool Res_rs1_r1_given_keycode95(int _cursn) { /* _ */
  35. return is(ew(_cursn), Empty);
  36. }
  37. void Res_rs1_r1_vote_keycode64(int _cursn, inout int _nvotes, inout int _winsn) { /* @ */
  38. int myvotes = 1;
  39. _nvotes += myvotes;
  40. if (random_create(int(_nvotes)) < myvotes) { _winsn = _cursn; }
  41. }
  42. void Res_rs1_r1_vote_keycode95(int _cursn, inout int _nvotes, inout int _winsn) { /* _ */
  43. int myvotes = 1;
  44. _nvotes += myvotes;
  45. if (random_create(int(_nvotes)) < myvotes) { _winsn = _cursn; }
  46. }
  47. bool Res_rs1_r1_check_keycode64(int _nvotes) { /* @ */
  48. return _nvotes > 0;
  49. }
  50. bool Res_rs1_r1_check_keycode95(int _nvotes) { /* _ */
  51. return _nvotes > 0;
  52. }
  53. void Res_rs1_r1_change_keycode64(int _cursn, int _winsn) { /* @ */
  54. ew(_cursn, ew(0));
  55. }
  56. void Res_rs1_r1_change_keycode95(int _cursn, int _winsn) { /* _ */
  57. ew(_cursn, new(Empty));
  58. }
  59. bool Res_rs1_r1_given() {
  60. if (!Res_rs1_r1_given_keycode64(0)) return false;
  61. if (!Res_rs1_r1_given_keycode95(1)) return false;
  62. return true;
  63. }
  64. void Res_rs1_r1_vote(inout int _nvotes_0, inout int _winsn_0, inout int _nvotes_1, inout int _winsn_1) {
  65. _nvotes_0 = 0; /* @ */
  66. _winsn_0 = 63;
  67. _nvotes_1 = 0; /* _ */
  68. _winsn_1 = 63;
  69. Res_rs1_r1_vote_keycode64(0, _nvotes_0, _winsn_0); /* @ */
  70. Res_rs1_r1_vote_keycode95(1, _nvotes_1, _winsn_1); /* _ */
  71. }
  72. bool Res_rs1_r1_check(int _nvotes_0, int _nvotes_1) {
  73. if (!Res_rs1_r1_check_keycode64(_nvotes_0)) return false; /* @ */
  74. if (!Res_rs1_r1_check_keycode95(_nvotes_1)) return false; /* _ */
  75. return true;
  76. }
  77. void Res_rs1_r1_change(int _winsn_0, int _winsn_1) {
  78. Res_rs1_r1_change_keycode95(0, _winsn_0); /* @ -> _ */
  79. Res_rs1_r1_change_keycode64(1, _winsn_1); /* _ -> @ */
  80. }
  81. bool Res_rs1_r1() {
  82. if (Res_rs1_r1_given()) {
  83. int _nvotes_0; /* @ */
  84. int _winsn_0;
  85. int _nvotes_1; /* _ */
  86. int _winsn_1;
  87. Res_rs1_r1_vote(_nvotes_0, _winsn_0, _nvotes_1, _winsn_1);
  88. if (Res_rs1_r1_check(_nvotes_0, _nvotes_1)) {
  89. Res_rs1_r1_change(_winsn_0, _winsn_1);
  90. return true;
  91. }
  92. }
  93. return false;
  94. }
  95. /* Rule 2:
  96. ................................................................................
  97.  
  98. @ -> @
  99.  
  100. ................................................................................
  101. */
  102.  
  103. bool Res_rs1_r2_given_keycode64(int _cursn) { /* @ */
  104. return true;
  105. }
  106. void Res_rs1_r2_vote_keycode64(int _cursn, inout int _nvotes, inout int _winsn) { /* @ */
  107. int myvotes = 1;
  108. _nvotes += myvotes;
  109. if (random_create(int(_nvotes)) < myvotes) { _winsn = _cursn; }
  110. }
  111. bool Res_rs1_r2_check_keycode64(int _nvotes) { /* @ */
  112. return _nvotes > 0;
  113. }
  114. void Res_rs1_r2_change_keycode64(int _cursn, int _winsn) { /* @ */
  115. ew(_cursn, ew(0));
  116. }
  117. bool Res_rs1_r2_given() {
  118. if (!Res_rs1_r2_given_keycode64(0)) return false;
  119. return true;
  120. }
  121. void Res_rs1_r2_vote(inout int _nvotes_0, inout int _winsn_0) {
  122. _nvotes_0 = 0; /* @ */
  123. _winsn_0 = 63;
  124. Res_rs1_r2_vote_keycode64(0, _nvotes_0, _winsn_0); /* @ */
  125. }
  126. bool Res_rs1_r2_check(int _nvotes_0) {
  127. if (!Res_rs1_r2_check_keycode64(_nvotes_0)) return false; /* @ */
  128. return true;
  129. }
  130. void Res_rs1_r2_change(int _winsn_0) {
  131. Res_rs1_r2_change_keycode64(0, _winsn_0); /* @ -> @ */
  132. }
  133. bool Res_rs1_r2() {
  134. if (Res_rs1_r2_given()) {
  135. int _nvotes_0; /* @ */
  136. int _winsn_0;
  137. Res_rs1_r2_vote(_nvotes_0, _winsn_0);
  138. if (Res_rs1_r2_check(_nvotes_0)) {
  139. Res_rs1_r2_change(_winsn_0);
  140. return true;
  141. }
  142. }
  143. return false;
  144. }
  145. bool Res_rs1() {
  146. if (Res_rs1_r1()) return true;
  147. if (Res_rs1_r2()) return true;
  148. return false;
  149. }
  150. void Res_behave() {
  151. if (Res_rs1()) return;
  152. }
  153. ARGB Res_getColor(Unsigned selector) {
  154. return cu_color(0,255,0);
  155. }
  156. void Res_EVENT_START() {
  157. _SYMMETRY = random_create(8);
  158. }
  159.  
  160. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  161. // Dispatches +
  162. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  163.  
  164.  
  165. void _BEHAVE_DISPATCH(uint type) {
  166. switch(type) {
  167. case Res: Res_EVENT_START(); Res_behave(); break;
  168. default: break;
  169. }
  170. }
  171. ARGB _COLOR_DISPATCH(uint type) {
  172. switch(type) {
  173. case Void: return uvec4(255,255,0,255);
  174. case Empty: return uvec4(255,0,0,0);
  175. case Res: return Res_getColor(0);
  176. default: return uvec4(255,0,255,255);
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement