Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

4788
LINES
[SHOW ALL]

< > BotCompany Repo | #1031138 // Smarty AI Include

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (7897L) is out of date.

1  
// AI begins here
2  
3  
do not include class Letter.
4  
5  
!include once #1002637 // substring
6  
!include once #1000810 // join
7  
!include once #1007089 // lastIndexOf
8  
!include once #1003421 // padLeft
9  
!include once #1002071 // trim
10  
11  
// copied from main.java in preliminary IDEA project
12  
// from "static class Smarty" to
13  
// "JavaX standard functions & classes"
14  
15  
concept Smarty {
16  
    int IntensityRange;
17  
    String[] Sense = new[10+1];
18  
    boolean Processing50;
19  
    int MaxBodies;
20  
21  
    transient TheWorld World;
22  
    new Bodies bodies;
23  
24  
    static class TheWorld {
25  
        public String LookUnder() {
26  
            return "";
27  
        }
28  
29  
        public void MoveWest() {
30  
        }
31  
32  
        public void MoveSouth() {
33  
        }
34  
35  
        public void MoveEast() {
36  
        }
37  
38  
        public void MoveNorth() {
39  
        }
40  
41  
        public void PointUnder() {
42  
        }
43  
44  
        public void PointNorth() {
45  
        }
46  
47  
        public void PointSouth() {
48  
        }
49  
50  
        public void PointWest() {
51  
        }
52  
53  
        public void PointEast() {
54  
        }
55  
56  
        public void DisplayStimuliAndResponse(int[][][] sensorValues, char resp) {
57  
        }
58  
59  
        public int RangeSouth() {
60  
            return 0;
61  
        }
62  
63  
        public int RangeNorth() {
64  
            return 0;
65  
        }
66  
67  
        public int RangeEast() {
68  
            return 0;
69  
        }
70  
71  
        public int RangeWest() {
72  
            return 0;
73  
        }
74  
75  
        public S LookSouth() {
76  
            return "";
77  
        }
78  
79  
        public S LookNorth() {
80  
            return "";
81  
        }
82  
83  
        public S LookEast() {
84  
            return "";
85  
        }
86  
87  
        public S LookWest() {
88  
            return "";
89  
        }
90  
91  
        public void Update_View() {}
92  
93  
        public void setBinonDisplayObjList(S text) {}
94  
95  
        public void setBinonDisplayChngResults(S text) {}
96  
        
97  
        public void appendBinonDisplayChngResults(S text) {}
98  
99  
        public void showSensorValues(S text) {}
100  
        
101  
        public void showDeviceValues(S text) {}
102  
    } // end of TheWorld
103  
104  
    String VB_Name = "Adaptron";
105  
    // Originally was a TEST VERSION WHICH PRODUCES RANDOM INPUT AND
106  
    //CHECKS MEMORY TO SEE IF IT CONTAINS THE SAME STUFF
107  
    //Obviously must have spun it off of Think 5
108  
109  
    // Adaptron/Cognitron Algorithm - Program  - Feb. 2003 test
110  
    // (C) Copyright 2007, Adaptron Inc.
111  
    //
112  
    //THINK3 IS NOT HANDLING CONSCIOUS HABITS PROPERLY
113  
    //THINK4 IS EXPERIMENT IN EXPECTATIONS BEING SAVED
114  
    //THINK5 DOES A PROPER JOB OF HANDLING R-HABITS
115  
    //11 July 2002 - attempting to get the 2 bugs out of pattern matching
116  
    //13th July 2002 - put back the stimulus matching mem location use for
117  
    // habit continuation checking in the right order - resulting stimulus
118  
    // first then is it an expected trigger.
119  
    //pattern4 - July 28, format display better
120  
    //pattern5 - July 29 week - trace display improvements -got out bug in
121  
    //           habit collapsing
122  
    //pattern6 - Aug 3 - test some more
123  
    //pattern7 - Aug 9 - more tests with manual input, THEN AUTOMATED AGAIN
124  
    //pattern8 - Aug 13 - I did top and bottom expected stimuli in habit in
125  
    //           previous version - now I need to introduce expected stimuli
126  
    //           in the habit stack fixed up Context saving too - but I think
127  
    //           some context could be put in LTM for pattern matching on
128  
    //           context so it doesn't get too long or do pattern matching on
129  
    //           context while in STM.
130  
    //Pattern9 - incorporate thinking changes from Think8 and turn on responses
131  
    //Went back to the THINK versions and incorporated results from Pattern9
132  
    //THINK7 DOES A PROPER JOB OF HANDLING R-HABITS
133  
    //THINK8 Well documented version
134  
    // Fixed up some stuff and comments and made it into ACTIONS8.BAS Aug 16th 2002
135  
    //ACTIONS8 - Work on comments and then responses -Then went back to Pattern
136  
    //versions and worked on Pattern0 -Active Habits that fail attract attention
137  
    //and then incorporated these results into Actions8.
138  
    //Actions9   - Started to investigate response habits - fixed up
139  
    //             NOADDSHABITS and removed NOADDHABITS.
140  
    //ACTION10   - Make no distinction between doing nothing and doing something
141  
    //             until the last minute when go to do it.
142  
    //           - Refine priority of what attracts attention especially for
143  
    //             familiar input.
144  
    //EXPLORE1   - Test it out
145  
    //EXPLORE2   - Improve context saving. Use 16 bit memory locations.
146  
    //           - HAVING PROBLEM WITH HABIT MATCHING - CREATE NEW VERSION
147  
    //EXPLORE3   - Change habit stack so current one is on top and any ADDSHABITS
148  
    //             are below it. Stopped it using context in habits being done.
149  
    //EXPLORE4   - Removed code for context saving.
150  
    //Explore5   - Visual Basic 6 Version with different windows for LTM, STM etc.
151  
    //             Boredom turned on for current stimulus and result
152  
    //             habitualized and this habit has a familiar or novel result
153  
    //             based on InterestLevel. Old Boredom code commented out.
154  
    //Explore6   13th July 2003 Try to make feelings of novel, familiar etc.
155  
    //             into a new stimulus type which result in information about
156  
    //             success or failure.
157  
    //           12th Aug 2003 Decided not to do this. Instead am
158  
    //             going to add R-Habits. Decided R-Habits already taken care
159  
    //             of. Added continuous stimuli from both senses. Investigate
160  
    //             looping behaviour and subconscious habit execution. Haven't
161  
    //             done looping but it seems pretty stable.
162  
    //Explore7   11th Sept 2003 Now work on subconscious habit execution.
163  
    //             Add loop execution in subconscious habits
164  
    //           24th Sept Allow multiple stimuli on S-List - 1 external &
165  
    //             1 internal stimulus. Then fix bugs / features
166  
    //Explore8   1st Oct 2003 Now work on R-habits and their execution.
167  
    //Explore9   6th Nov 2003 Major change required in how memory stored and
168  
    //           used - less emphasis on efficiency and episodic accuracy.
169  
    //           Added multiple S-habit recognition and context of S-habit
170  
    //           Added conscious looping of permanent S-habits
171  
    //Happy1     25th Nov 2003 Add in pain and pleasure. 11th Dec Added
172  
    //           expectation of Novel as Interesting - exploration is better.
173  
    //Happy2     17th Dec 2003 First attempt at adding thinking
174  
    //           7th Jan 2004 small changes
175  
    //Happy3     10th Jan 2004 turn off separate Trigger and Result stimuli,
176  
    //           add control flags for it and DoingReflex.
177  
    //Happy4     13th Jan,Seperate permanence property from feeling for stimuli
178  
    //           Add Response Habits containing Response-Stimulus-Response
179  
    //           Get looping (repeating same stimulus) working properly
180  
    //Happy5     20th Jan, getting permanent working, remove stimulus roles
181  
    //Happy6     21st Jan, handle dynamic environments
182  
    //Happy7     23rd Jan, Try handling S-Habits as R-Habits-no go.
183  
    //Happy8     27th Jan, Try to get R-habits as R-S-R working. Feb 12th. Add
184  
    //           subconscious processes.
185  
    //Happy9     23rd Feb, Novel stimulus becomes interesting, then familiar
186  
    //           Enhance thinking, strategies for handling Interesting
187  
    //Works1     6th Mar, 2004, Attend to stimuli
188  
    //Works2     30th March, Expectation processing
189  
    //Works3     31st March, Stimulus context in LTM for S-Habits too.
190  
    //Works4     8th Apr, Recognize loops in R-Habits, Good/Bad testing
191  
    //Works5     15th Apr, turn on Kinesthetics, do subconscious habits
192  
    //Works6     work on repetition / loops
193  
    //Works7     18th July 2004, new learning strategy, Test Cases
194  
    //Works8     29th July, Good and Bad processing
195  
    //Works9     7th Sept, Generalization & Discrimination - 2 or more senses
196  
    //           and subconscious habit processing
197  
    //Learn1     18th Sept, Conscious versus subconscious behaviour, added
198  
    //           levels and context at end of LTM
199  
    //Learn2     3rd Nov, Kinesthetic stimuli, loops, action habits
200  
    //Learn3     23rd Nov, Rename things, subconscious A-Habits, A-sequences
201  
    //Learn4     6th Dec, Chained A-Habits, Concentration, A-Sequences
202  
    //Learn5     6th Jan, 2005, A&B sequence, thinking refined, kinesthtics,
203  
    //           order of For's, Separate world
204  
    //Learn6     World front-end, ABC repeating pattern & permanent S-Habits
205  
    //Learn7     Body info, still working on S-Habits, R-Habits, separate body
206  
    //Learn8     11 May 05, separate body & Test Cases, R-Habits, P-Stimuli,
207  
    //           Difference in R-Habits
208  
    //Learn9     21 June 05, 31st Dec 05, removed linked habits, novelty/familarity
209  
    //           stored as feeling, work on 2nd sense and R-Habits
210  
211  
    //Habit1     3rd March 06, New attention algorithm, only collapse permanent
212  
    //           triggers of S-Habits, practice non-permanent S-Habits
213  
    //Habit2     March - Interestlevel based on A & S-Habit feelings
214  
    //Habit3     March - Good & Bad, Reward & Punishment, Feelings
215  
    //Habit4     Jan 2007 reworking interest levels
216  
    //Habit5     29th Jan 07, S-habits collapse when both stimuli are permanent
217  
    //           A-habits interest propagate back to trigger, S-Habits interest
218  
    //           propagates up the heirarchy.
219  
    //Habit6     16th Feb 07, Rearrange attention algorithm
220  
    //Habit7     14th March 07, Add graduated stimuli
221  
    //Habit8     25th March 07, New attention algorithm
222  
    //Habit9     3rd April 07, Sort out permanent stimuli, attention algorithm
223  
    //Cogni1     18th April 07, Work on thinking part, replace feature with sensor
224  
    //           Recog1, Recog2 Recognition of objects from graduated senses.
225  
    //           Add discrete Sensor Array, discrete and graduated sensors
226  
    //Cogni2     New interest derivation for experiences, new expected interest
227  
    //Cogni3     27th July 07, Each Habit has its own expected interest
228  
    //In here I worked on lines
229  
    //Cogni5     Sept 07, Reworking multiple sensors with graduated values
230  
    //Cogni6     Oct 12, 07,  New S-Habit matching and find difference, multi-sensors
231  
    //Cogni7     Oct 28, 07, Multi-sensors
232  
    //Cogni8     Nov 16, 07, Use recency to solve which S-Habit to attend to. Change
233  
    //           action selection strategy, use FindInstead, not FindDifference
234  
    //Cogni9     Nov 25, 07, Bucket stimuli readings, Change as a stimulus
235  
    //Grad1      Dec 14, 07, Graduated sensors, S-Habits use LTM pointers
236  
    //Grad2      Feb 4, 2008,  sequences of graduated stimuli - C-Habits, generalization
237  
    //Grad3      Feb 14, 2008, Change as stimulus, new S-Habit structure
238  
    //Grad4      Feb 26, 2008, new S-Habit structure
239  
    //Grad5      Mar 9, 2008,  new S-Habit structure
240  
    //Grad6      April 2008, Remove Change as a stimulus - objects represent the changes experienced
241  
    //In here I worked on lines and developed course 447
242  
    //Grad7      Jan 2009, Subconscious action habits, Interest levels
243  
    //Grad8      Feb 2009, new S-Habit structure changes
244  
    //Grad9      Mar 20, 2009, Overlapping parts of S-habits, add line recognition from Sense1
245  
    //Ideas1     April 18, 2009, Add change objects, get thinking working and upto testcase #25
246  
    //Ideas2     May 19, 2009, Use tree of sense stimuli and P-habits - not on S-List
247  
    //Ideas3     June 17, 2009, Finish conversion of S-List, Conscious Habit rework, attention alg.
248  
    //Ideas4     July 8, P-Habits
249  
    //Ideas5     July 10, Remove context processing, ignore repeating S-Habits,
250  
    //Ideas6     Aug 2, Incorporate new line recognition, Where and Order processing
251  
    //Ideas7     Sept 1st, Partial trigger matching - generalization
252  
    //Ideas8     Sept 15th, Graduated readings, 8th Dec new recognition routines, Change Reading Object
253  
    //Ideas9     Dec 15th, Separation object
254  
    //Change1    Dec 31st, Save Change objects in LTM, Add STM for sequences
255  
    //Change2    Jan 10th, 2010 create SepRdgObj, remove LTM Separs(), move STM process
256  
    //Change3    Feb 2nd, STM processing, new line recognition, sequence recognition
257  
    //Change4    May 2nd, New LTM episodic memory representation, new STM
258  
    //Change5    May 26th, Sequence and Action LTM separated
259  
    //Change6    Jun 13th, new Where obj, STM per Sense & Sensor if independent
260  
    //Change7    Jun 23rd, Interest on sequences in STM, T-List
261  
    //Change8    Jul 4th, P-Habits in STM, Body and World changes
262  
    //Change9    Jul 20th, A_Sequences implemented, Fix STM S-habit recognition / distraction
263  
    //Active1    Jul 31st, Boredom and sub-conscious A-Habits
264  
    //Active2    Aug 12th, Conscious STM and/or A-Habits
265  
    //Active3    Sept 21st, New Sequence recognition, Conscious STM
266  
    //Active4    Oct 7th, Action Habits(practicing & doing), remove partial sequential match,
267  
    //                    Convert interest into a property of all binons
268  
    //Active5    Nov 4th, New binon structure, thinking
269  
    //Active6    Dec 7th, Another new binon structure, fix partial match, remove reset interest
270  
    //Active7    Dec 17th, Separate Change and Interest, reduce interest upon repetition, no concentration
271  
    //Active8    Jan 22nd, 2011 remove permanent, remove current habit, separate S-habit and A-Habits
272  
    //Active9    Feb 12th, New binon structure, P-habits before Sequences, better attention
273  
    //Expect1    Mar 6th,  Expect Interesting, new A-Habit structure, remove dependence concept
274  
    //Expect2    Mar 23rd, Changed DoIt structure, Experiences in STM, Conscious Seq's in STM
275  
    //Expect3    Apr 9th,  New Acton structure, sequential trigger and goal recognition, removed
276  
    //                     Novel and Fresh concepts
277  
    //Expect4    May 3rd,  Add device stimuli, Unexpected, New Acton structure
278  
    //Expect5    Aug 2nd,  Action habits, STM changes
279  
    //Expect6    Sept 4th, STM just recognizes (no expectations), remove orient actons, directed
280  
    //                     attention on expected goal
281  
    //Expect7    Sept 20th,Added UnInteresting
282  
    //Expect8    Oct 4th, New acton structure
283  
    //Expect9    Oct 16th, P-Habits, kinesthetic sense fixed, formation of combo by A-Habit?
284  
    //Practic1   Nov 7th, Sequences and Action Habits
285  
    //Practic2   Nov 15th, STM processing and Permanent
286  
    //Practic3   Dec 12th, Before and after conscious STMs, S-Level 1 stimuli familiar
287  
    //Practic4   Jan 10th, STMs do not create A-Habits, Practice mode - redo-interest
288  
    //Practic5   Jan 31st, Practice and Goal Actons, STM processing conscious sequences
289  
    //Practic6   Feb 15th, P-Habit processing, Directed Attention, sequences of permanent stimuli
290  
    //Practic7   Mar 14th, brought in new pattern recognition
291  
    //Practic8   Apr 7th, new novel/familiar combinations and STM processing, P-Habits working
292  
    //Practic9   Apr 24th, generalization for 2 senses
293  
    //General1   May 23rd, Incorporate new Object Recognition (twice)
294  
    //General2   July 1st, Practice and Thinking, Redo versus goal interest, Random next responses
295  
    //General3   July 11th, A-habits at lowest level first, Unexpected sequential interest
296  
    //General4   July 23rd, Expectation inhibits familiar from attention, should binons come with
297  
    //                       habituation of a repeat sequence built in?
298  
    //General5   12th Jan 2017 - started to document it - going to insert PerceptionAction from Act2
299  
    //15th Jan 2017  'Inserted PerceptionAction() and got Inpu_KeyPress(0 and TestCases working with no babbling output.
300  
    //22nd Jan   'adding motor babbling when known action habits are familiar
301  
    //23rd Jan   'thinking and bodies starting to work
302  
    //24th Jan   'adding body #6 with two senses - vision and motion
303  
    //28th Jan   'Got Thinking Approach #1 working
304  
    //29th Jan   'Make Binon type one of the Binon properties
305  
    //30th Jan   'Create P-Habit combinations for any number of senses = properties
306  
    //2018 Aug 29th  'Clean up code before sending to Jianyong
307  
    //31st Aug   'Renamed it Smarty. Continue to clean up the code
308  
    //25th August 2019
309  
    //           'renaming percpts, actions etc. to conform with the perception-action hierarchy paper
310  
311  
    //DefInt A - Z; //16 bits / 2 bytes
312  
313  
    int JND; //set to 20%
314  
315  
    final static String Smarty = "J"; // J = wingdings happy face
316  
317  
    final static String LeftArrow = chr(239); // "<"
318  
    final static String RightArrow = chr(240); // ">"
319  
    final static String UpArrow = chr(241); // "^"
320  
    final static String DownArrow = chr(242); // "v"
321  
    String FourWay; // "+" - unused
322  
323  
    String Smarty0; // "Smarty0" The initial / default Body name
324  
325  
    String[] BodySetting = new[22]; //Contains the current body being used
326  
    //Bodysetting$(0) contains the number of settings in use
327  
328  
    String BodyConfig; //The values in the configure forms when go to Design or Select
329  
    //For determining if a change has been made.
330  
331  
    String[] BodyValue; //Contain the values read and written to the .BDY file
332  
    //The values on the body configuration forms
333  
334  
    int BodyPointing; //direction body is pointing, 0=East, 1=South, 2=West, 3=North
335  
    //direction body is pointing, 0=East, 1=South, 2=West, 3=North
336  
    transient final int North = 3;
337  
    transient final int East = 0;
338  
    transient final int South = 1;
339  
    transient final int West = 2; //direction body is pointing, 0=East, 1=South, 2=West, 3=North
340  
341  
// --------------------------  Senses and Sensors --------------------------
342  
343  
    int NumSenses; //The number of physical senses, Max of 10, dynamically set in SetUpSense()
344  
    //Currently equals the NumProperties since each sense currently = 1 property type
345  
    int MaxSenses; //Maximum number of senses = max 10 physical senses
346  
    int IsSense; //1, Flag for Senses versus Devices
347  
    //unused String StringSense; //Names of senses, up to 10 physical senses - assigned in SetupSense()
348  
349  
    int[][] Senses = new int[10 + 1][8 + 1]; //Properties of the different senses
350  
    //1st index = Sense number
351  
    //2nd index = Sense property
352  
    String[] SensorStimuli = new String[10 + 1]; //A string of the possible symbolic stimuli for the sensor
353  
354  
    //---- Senses() - 2nd index values - Sense Properties - same used for Devices below
355  
    int PropertyBinonType; //1, Stimulus property binon type e.g. 1 = TextBin or 2 = ContBin
356  
    int SymbolicOrMagnitude; //2, Symbolic or Magnitude indicator
357  
    int LowerRangeLimit; //3, Lower limit of range of values, zero is minimum (65 = "A")
358  
    int UpperRangeLimit; //4, Upper limit of range of values, 255 is maximum (90 ="Z")
359  
    int LinearOrCircular; //5, Linear list or Ring/Circular of values for Magnitude sense, Distance is Linear, Compass degrees are Circular (0 to 360)
360  
    int IntegersOrLogs; //6, Integer Values or Log Values, Temperatures are Integers while Decibels are Logs
361  
    int NumberOfSensors; //7 Number of sensors in sensor array
362  
    int SensorsDependentOrIndependent; //8 are sensors adjacent (dependent) or independent
363  
364  
    int Symbolic; //1, Indicates that the values from this sense are symbolic, range A -> Z
365  
    int Magnitude; //2, Indicates that the values from this sense are numeric, integers, range 0 -> Limit
366  
367  
    int Linear; //1, Indicates that the values go from the lower limit to upper limit
368  
    int Circular; //2, Indicates that the values rap around from the upper limit to 0
369  
370  
    int IntegerValues; //1, Indicates that the values are integer readings
371  
    int LogValues; //2, Indicates that the values are already logs - orders of magnitude
372  
373  
    int Dependent; //1, Sensors in array are beside each other (adjacent)
374  
    int Independent; //2, Sensors are not associated with each other
375  
376  
    //--------------------  Values of stimuli from senses / sensors ------------------------------
377  
378  
    int[][][] SensorValues = new int[10 + 1][2 + 1][1+1]; //Stimulus values from senses/sensors
379  
    //1st index is sense number, currently = property /sense binon type
380  
    //2nd index is what type of information is in the SensorValues(), XQCnt or Valu
381  
    //3rd index is Fired for the most recent stimulus value and Current for the previous
382  
383  
    //---- SensorValues 2nd index values - type of information in SensorValues()
384  
    int Valu; //=1, the value for the stimulus, if symbolic then value = Asc(Symbol$)
385  
    int XQCnt; //=2, the count of times the value has repeated, also used below
386  
    String NoName; //"_", The character used when no letter provided for the IDL value of a TextBin binon
387  
    String Motion; //World.MoveDown() etc set this to indicate the direction the robot moved
388  
    String NoMove; //"-" to indicate there was no motion in the Motion$ stimulus value
389  
    String WheelMovement; //"-flrb..." 'will contains the possible wheel motions
390  
    //WheelMovement$ = "-flrb" & TurnRght$ & TurnLft$ & TurnArnd$ ' rotate right, left and around 180 degrees
391  
    String ABlock;
392  
    static final String Wall = chr(219); //a block, Chr$(219) is a black square in Terminal font
393  
    static final String EmptySquare = chr(177); //Chr$(177) is a fuzzy square in Terminal font
394  
395  
    //---- SensorValues 3rd index values - which past stimulus it is - also used below
396  
    int Fired; //=0 'stimulus put in this level upon firing before being processed
397  
    int Current; //=1 'The Fired one becomes the Current one after processing
398  
399  
    //--------------------  Devices ------------------------------------------------
400  
401  
    int NumDevices; //Number of output devices - max 4 - dynamically set in SetupDevice()
402  
    int MaxDevices; //Maximum number of devices = max 4 devices
403  
    String[] Device = new String[4 + 1]; //Names of device, up to 4 devices - assigned in SetupDevice()
404  
    int IsDevice; //2, Flag for Devices versus Senses
405  
406  
    int[][] Devices = new int[4 + 1][6 + 1]; //Properties of the output / response devices
407  
    //1st index = Device number
408  
    //2nd index = Device property
409  
    String[] DeviceResponses = new String[4 + 1]; //A string of the possible symbolic responses for the device
410  
411  
    //---- Devices() - 2nd index values - Device Properties - DEFINED ABOVE
412  
//  Public PropertyBinonType      '1, Response property binon type e.g. 1 = LetrBin
413  
//  Public SymbolicOrMagnitude    '2, Symbolic or Magnitude indicator
414  
//  Public LowerRangeLimit        '3, Lower limit of range of response values, zero is minimum (97 = "a")
415  
//  Public UpperRangeLimit        '4, Upper limit of range of response values, 255 is maximum (122 = "z")
416  
//  Public LinearOrCircular       '5, Linear list or Ring/Circular of values for Magnitude sense, Distance is Linear, Motor rotations are Circular (0 to 360)
417  
//  Public IntegersOrLogs         '6, Integer Values or Log Values, Temperatures are Integers while Decibels are Logs
418  
419  
//  Public Symbolic               '1, Indicates that the values for this device are symbolic, Range a -> z
420  
//  Public Magnitude              '2, Indicates that the values for this device are numeric, integers, range 0 -> limit
421  
422  
//  Public Linear                 '1, Indicates that the values go from the lower limit to upper limit
423  
//  Public Circular               '2, Indicates that the values rap around from the upper limit to 0
424  
425  
//  Public IntegerValues          '1, Indicates that the values are integer readings
426  
//  Public LogValues              '2, Indicates that the values are already logs - orders of magnitude
427  
428  
    //--------------------  Values of responses to devices ------------------------------
429  
430  
    int[][] DeviceValues = new int[4 + 1][2 + 1]; //Response values for devices
431  
    //1st index is device number, currently = response property binon type
432  
    //2nd index is what type of information is in the DeviceValues(), XQCnt or Valu
433  
434  
    //---- DeviceValues 2nd index values - type of information in DeviceValues() - DEFINED ABOVE
435  
//  Public Valu                   '=1, the value for the response, if symbolic then Symbol$ = Chr$(value)
436  
//  Public XQCnt                  '=2, the count of times the value needs repeating, also used below
437  
    transient final char NoResp = '-'; //"-", The character representing no response for a LetrBin binon
438  
    //c  Public Relax$                 '"-", used for a Relaxing response - currently the same as NoResp$
439  
    //and it is used as the stimulus input of the Motion sense
440  
    boolean WheelsTurn; //If it is false then Smarty displays as an O else it displays as ^><v
441  
442  
    //  Relax$ = NoResp$         '"-", used for Relaxing response - currently the same as NoResp$
443  
444  
    transient final char MoveForward = 'f';
445  
    transient final char MoveToLeft = 'l';
446  
    transient final char MoveToRight = 'r';
447  
    transient final char MoveBackward = 'b'; // f, l, r, b
448  
    static final char TurnRght = 187; //right angle in Terminal font
449  
    static final char TurnLft = 188; //left angle
450  
    static final char TurnArnd = 18; //double arrow
451  
452  
    String NoMoveOrTurn; //"z" indicates Smarty does not have this move ability
453  
454  
// ---------------------------Primitive responses  --------------------------------------
455  
456  
    //unused String[][] Acts = new String[100 + 1][2]; //Primitive responses per device per device type
457  
    int NumActs; //The number of Acts entries in use
458  
    //unused Public MaxActs; //Max is 100
459  
    //Acts properties
460  
    //unused Public DvcType; //0 = The device type number for this device
461  
    //unused Public DvcID; //1 = The device number for this device of the device type
462  
    //unused Public Respns; //2 = The response for this device
463  
464  
    //static Public NullAct; //-1 Used only for Act2 - Indicates that Act1 points to a primitive Acts()
465  
    //unused Public RelaxAct; //1, The 1st act = 1st response in 1st device of 1st device type = a relax
466  
467  
    boolean RotateActs; //Set true if GetNxtResponse rotates through all acts
468  
469  
    //--------------------  The Stimulus Objects (Binons)  -------------------------
470  
471  
    //This is a tree of all stimulus and response representations - Parallel ones from multiple sensors and devices.
472  
    //A binon is made up of 2 source binons (left and right) at the next level down.
473  
    //A binon has many right target and left target binons.
474  
    //For parallel recognition it stimulates both targets when it fires (recognizes its source combination)
475  
    //For sequential performance it is activated by its left target, waits to be triggered by its left source,
476  
    //then activates/does its right source and fires its right target.
477  
478  
    int NumBinons; //Number of objects so far in Binons(), incremented before its use
479  
    //to determine the place where the next new binon will be placed in Binons()
480  
    int MaxBinons; //5000, Max number of binons per type
481  
    boolean OverLimit; //Global flag set when over Binon or Path limit
482  
483  
    int[][] Binons = new int[5000 + 1][14 + 1]; //Objects, parts, percepts, stimuli, responses
484  
    //1st index = binon number
485  
    //2nd index = binon property
486  
487  
    //---- Binon Properties - 2nd index values
488  
    int BType; //1, The type of binon
489  
    int O1; //2, Left source binon pointer
490  
    int TQ; //3, the count of times the trigger has fired
491  
    int O2; //4, Right source binon pointer
492  
    int GQ; //5, the number of times the goal has fired
493  
    int IDL; //6, The ratio value of the binon
494  
    int IntVl; //7, Interest Value (NOVEL, INTERESTING, or Familiar)
495  
    int OLv; //8, Level of object = number of lowest level parts involved
496  
    int SP; //9, Sequential or Parallel property
497  
    int TriggerList; //10, points to the linked list of target binons [Targets()]
498  
    //   for which this binon is the left source binon (not the right source binon).
499  
    int TriggerCount; //11, Count of its sequential right targets, >1 means it has more than one goal
500  
    //    Used for prediction reliability, may be set >1 if needs to be combined with previous
501  
    int GoalList; //12, points to the linked list of target binons [Targets()]
502  
    //   for which this binon is the right source binon (not the left source binon)
503  
    int GoalCount; //13, Count of its sequential left targets, >1 means can not predict its trigger
504  
    //    Used for reliability of determining the cause, may be set >1 if needs to be combined with next
505  
    int AE; //14, Action (Percept - Act) or Attention (Act - Percept) level 1 Sequential binon
506  
507  
    int NullObject; //-1, Indicates the O1 or O2 pointer is not pointing to another binon
508  
509  
    //---- Interest values for Binons(x, IntVl) - must be numeric for comparison purposes
510  
// New - 1st time experienced - attention paid to it
511  
    //---- Interest values for Binons(x, IntVl) - must be numeric for comparison purposes
512  
    final int NOVEL = 3; //3 New - 1st time experienced - attention paid to it
513  
    // To indicate it has been experienced for the second time
514  
    final int INTERESTING = 2; //2 To indicate it has been experienced for the second time
515  
    // Neutral, experienced 2 or 3 or more times
516  
    final int FAMILIAR = 1; //1 Neutral, experienced 2 or 3 or more times
517  
    int NoInterest; //-1 Interest not known yet
518  
519  
    int InterestLevels; //2 or 3 - number of interest levels, 2= Novel and Familiar, 3= Novel, Interesting, and Familiar
520  
521  
    //---- Sequential or Parallel property values for Binons(x, SP)
522  
    int Sequential; //-1
523  
    int Parallel; //+1
524  
525  
    //---- Action or Attention property values for Binons(x, AE) - value = 0 for Parallel Percepts
526  
    int Action; //1
527  
    int Attention; //2
528  
529  
    //---- BinonType property values for Binons(x, BType)
530  
    int MaxBinonTypes; //with 2 senses and 1 device this is =6, 4 senses & 4 devices = 33
531  
    int NumBinonTypes; //= 2^N+1, number of property binons, Percept combination binon types, Action type and
532  
    //the D-Habit response types - set dynamically based on SetupSense() and SetupDevice()
533  
    String[][] BinonTypeName = new String[68 + 1][2 + 1]; //The names and abbreviations for the various binon types
534  
    //---- BinonTypeName$() 2nd index values
535  
    int BinName; //1
536  
    int BinAbbreviation; //2
537  
    //The source types of property binons are 1=TextBin, 2=ContBin. There are N of these
538  
    //and all other Percept combinations such as Name&Cont.
539  
    //There are 2^N-1 Property plus Percept types
540  
    //There is just the one Action type - a sequential combination of the
541  
    //Property binons, Percept binons, response D-Habit binons and/or Action binons.
542  
543  
    int[][] BinonTypes = new int[68 + 1][1 + 2]; //The binon types for stimuli (Percepts 15), ActBin (1) and responses (D-Habits 15)
544  
    //1st index = the type of binon (dimension = NumBinonTypes)
545  
    //2nd index = binon type property
546  
547  
    //---- BinonTypes() - 1st Index values - stimulus and response binon types
548  
    int ActBin; //Binon type for Actions, Expectations, percepts, and action binons = NumPercepts + 1. Dynamically set
549  
550  
    int NumProperties; //N=4, The number of stimulus property binon types - currently one property per sense
551  
552  
    final int NullType = 0; //0, Indicates the type not set, binon will be NullObject
553  
554  
    //---- BinonTypes() 2nd index values
555  
    int SensOrDevNum; //1, Pointer points back to sense or device
556  
//  Public SymbolicOrMagnitude    '2, Symbolic or Magnitude indicator - defined above
557  
558  
    //--------------------  Percept Stimuli Perceived ---------------------------------------
559  
560  
    int[] SensedBinons = new int[1 + 10]; //the source binons for the Percepts() tree (only uses = Numsenses=NumProperties)
561  
562  
    int NumPercepts; //N=63, The number of property binons and Percept combinations of them 2^NumProperties-1
563  
    int MaxPercepts; //=63 currently = (2^6)-1 would need to be (2^10) if 10 sensors
564  
    int[][][] Percepts = new int[1 + 63][1 + 2][2]; //Current and Fired Property binon and Percept IDs and XQ count
565  
    //1st index is the property / Percept binon type (dimension = NumPercepts)
566  
    //2nd index is what type of information is in the Percepts()
567  
    //3rd index is Fired=0 or Current=1
568  
569  
    //---- Percepts 2nd index values - type of information in Percepts()
570  
    int BinId; //=1, the 2nd index value for the binon ID - defined / used below
571  
    //Public XQCnt                  '=2, the count of times the fired binon has been recognized / fired - DEFINED ABOVE
572  
573  
    int[][] PerceptSources = new int[1 + 63][1 + 3]; //pointers to the lower level Percepts that are used in forming this Percept
574  
575  
    //---- PerceptSources() 2nd index values
576  
    int FirstSource; //=1, the first / left source Percept binon
577  
    int SecondSource; //=2, the second / right source Percept binon
578  
    int PerceptLevel; //=3, The level in the Percept tree
579  
580  
    //--------------------  Left and Right Targets ---------------------------------------
581  
582  
    //---  Linked List of Target Binons - for all binons -------------
583  
    int NumTargets; //The number of Target binon entries created so far
584  
    int MaxTargets; //10000 = the max number of Target binon entries possible
585  
586  
    int[][] Targets = new int[1 + 10000][1 + 2]; //pointed to by Binons(ID, TriggerList) or by Binons(ID, GoalList)
587  
    //---- Targets' 2nd index property values
588  
    int NLnk; //1 = The pointer to the next Targets() entry in this linked list,
589  
    //    may be a NullTarget at end of linked list
590  
    int TargetBinon; //2 = a left or right Target binon
591  
592  
    int NullTarget; //=0, an NLnk pointer at end of linked list
593  
594  
    //--------------------  D-Habit Response Produced ---------------------------------------
595  
596  
    //unused int[] RespondedBinons = new int[1 + 2]; //the response binons for the DHabits() tree (only uses = NumDevices=NumResponses)
597  
598  
    int NumDHabits; //N=15, The number of response binons and D-Habit combinations of them 2^NumDevices-1
599  
    //unused int MaxDHabits; //=15 currently = (2^4)-1
600  
    //unused int[][][] DHabits = new int[1 + 15][1 + 2][1 + 1]; //Current and Fired Property binon and Percept IDs and XQ count
601  
    //1st index is the property / Percept binon type (dimension = NumPercepts)
602  
    //2nd index is what type of information is in the Percepts()
603  
    //3rd index is Fired=0 or Current=1
604  
605  
    //---- Percepts 2nd index values - type of information in Percepts()
606  
    //Public BinId                  '=1, the 2nd index value for the binon ID - defined above
607  
    //Public XQCnt                  '=2, the count of times the fired binon has been recognized / fired - DEFINED ABOVE
608  
609  
    //--------------------  Action Stimuli Perceived ---------------------------------------
610  
611  
    int TopLevel; //The highest level with any binons in it in STM
612  
    int HighestPerceptLvl; //The highest STM() entry produced / fired per cycle
613  
    int MaxLevels; //=25, The highest level of complexity to which the tree can grow
614  
615  
    int[][][] STM = new int[25+1][3+1][25+1]; //STM current history of Patterns - a tree with parts at level 1
616  
    //1st index is the stimulus object level
617  
    //2nd index  =1 for binon type, =2 for binon ID, =3 for XQCnt, =4 for TQCnt
618  
    //3rd index  = Fired = 0 for the just fired stimulus
619  
    // = Current = 1 for the Current perceived stimuli
620  
    //They can all be expecting a repeat or a changed / different value
621  
    // = Last one whose position is the last STM entry that has something in it
622  
623  
    //---- STM 2nd index values - type of information in STM()
624  
    //Public BinId                '=1, the binon ID      - DEFINED ABOVE
625  
    //Public XQCnt                '=2, the count of times the fired binon has been recognized / fired / repeated - Defined above
626  
    int TQCnt; //=3, the count of times its trigger fired for repeat size comparison
627  
628  
    //---- STM 3rd index values - which past stimulus is it   - DEFINED ABOVE
629  
//  Public Fired                  '=0   'stimulus put in this level upon firing before being processed
630  
//  Public Current                '=1   'The fired one becomes the current one after processing
631  
632  
    int MoveAmount; //Move right amount to eliminate previous pattern - set in ProcessSTMLevel()
633  
634  
    //--------------------- Conscious Binons -----------------------------------------
635  
636  
    int PerceivedBinon; //predicting/expecting the next binon as the goal. May have 0, 1 or more associating binons.
637  
638  
//--------------------  Long Term Memory (LTM) - Monitoring Info. -------------------------
639  
    //For Display purposes only by Adapt.DUMPLTM in Adapt.LTMem
640  
    //Long term memory contains a list of the stimuli that have been paid attention to.
641  
    //It stores Perceptual sequences as a pair of sequential memory locations.
642  
643  
    int[][] LTMEMORY = new int[2000+1][8+1];
644  
    //1st index is StoreAt cycle number
645  
    //2nd index is what type of information is in the LTM
646  
647  
    //---- LTMEMORY() 2nd index values - type of information in LTMEMORY()
648  
    int LtmPerceptTyp; //1 Percept binon type
649  
    int LtmPerceptBin; //2 Percept binon
650  
    int LtmESType; //3 Type of ES Binon - may be an S
651  
    int LtmESActBin; //4 ES Actbin
652  
    int LtmARType; //5 Type of AR Binon - may be an R
653  
    int LtmARActBin; //6 AR ActBin
654  
    int LtmActionTyp; //7 Action binon type
655  
    int LtmActionBin; //8 Action binon
656  
657  
    int StoreAt; //LTM POSITION OF LAST STIMULUS - location in LTMEMORY() - incremented by PerceptionAction()
658  
    int MaxMemory; //2000
659  
660  
    //----------------------Input/Output History  ----------------------------------------
661  
    //For display by Adapt.HISTORYDISPLAY in Adapt.IO
662  
    String[][] INPUTS = new String[2000][10+1]; //INPUT history - List of sense stimuli for each sense (1 to 10)
663  
    String[][] OUTPUTS = new String[2000][4+1]; //OUTPUT history - List of Responses for each device (1 to 4)
664  
665  
    //--------------------  Other Variables ------------------------------------------
666  
667  
    double SizeBase; //1.2 for a 20% just noticeable difference
668  
    double IntensityBase; //If it is 2.0 then that is a 100% just noticeable difference
669  
670  
    //--------------------  Operational Values - Adaptron --------------------
671  
672  
    String ASpace;
673  
674  
    //char SequentialSign = first(unicode_rightPointingTriangle()); //Chr$(16) ">"
675  
    transient char SequentialSign = '>';
676  
    String ParallelSign; // "+" was Chr$(186) two vertical lines was "/"
677  
678  
    boolean CreateAll; //True if create all combinations
679  
    //False if use only familiar parts
680  
681  
    // *********  Counters, Temporary values, Flags and Pointers  ******
682  
683  
    //---------------------- Operational Values -------------------------------
684  
685  
    int Normal;
686  
    int Happy;
687  
    int Unhappy;
688  
    int PartMatch; //Used as ActTypes for body display
689  
690  
    //unused boolean PracticeMode; //Practicing the PracticeActon. Still performing it.
691  
    //When finished in PracticeMode then we switch to GoalMode.
692  
    //unused Public PracticeActon; //The acton that is being practiced
693  
    //static Public ActiveActon; //The highest level active acton being done subconsciously
694  
    //If set then this is being done subconsciously (not being practiced)
695  
    //static Public DoingAct1; //The Act is being done even though it is not being practiced
696  
    //This does not include the do Relax act
697  
    //unused Public GoalExpected; //Goal expected by Action started - to measure success or failure
698  
    //= 0 if no expectation because doing reflexive response
699  
    //unused Public GoalSoFar; //Keeps track of the part of the expected goal obtained so far
700  
    //unused boolean GoalMode; //Concentrating on the goal of the action being practiced.
701  
    //We have finished the acton execution.
702  
    //If set it will cause directed attention to the GoalExpected
703  
704  
    //unused Public ExpectedGoal; //Goal expected for thinking about
705  
    //unused Public TraceGoal; //Used for Trace - The goal we are either trying to achieve or avoid
706  
707  
    //unused Public MATCHUSE; //Trigger match Action in Actons() that is interesting to do
708  
    //unused Public ActionDesire; //Interest in the MATCHUSE entry for AttendTo
709  
    //unused Public PartialMATCHUSE; //same as MATCHUSE but for partial matches
710  
    //unused Public PartialActionDesire;
711  
    //unused Public PartialTrigger; //set to the partial trigger object if partial trigger true
712  
    //unused boolean ThoughtUsed;
713  
714  
    boolean DoingReaction; //set true if last response was reactive / reflex
715  
    boolean DoingRepeat; //set true if repeating a known response as a reflexive reaction
716  
717  
    int LastAct; //Last reflexive response used from Acts list
718  
    //unused Public NextAct; //The next output act for reflexive response from Acts()
719  
720  
    //unused Public ResponseOutput; //The one output in this cycle for storing in LTM trace
721  
722  
    //unused Public Recency;
723  
724  
    //unused boolean PracticeIt; //Global because used in Trace()
725  
    //unused boolean DoIt; //Global because used in Trace()
726  
    //unused boolean React; //Global because used in Trace()
727  
728  
    int LIN; //Count of how many stimuli have been input/output in INPUTS$() and OUTPUTS$()
729  
730  
    //unused boolean FreezeSList; //When true don't do the DUMPSTIMS any more
731  
    int COUNTIN; //Count of inputs for display of history
732  
733  
    String[] RecentWorld = new String[4]; //The list of recent .WLD files created - kept in RecentWldList.TXT
734  
    String[] RecentBody = new String[4]; //The list of recent .BDY files created - kept in RecentBdyList.TXT
735  
736  
    int OperatingMode; //Either, Running World or just Started
737  
    int Running;
738  
    int Started;
739  
740  
    // *********  Counters, Temporary values, Flags and Pointers  ******
741  
742  
    //unused Public I, J, T, M, H, N, K, P, F, S, Hab;
743  
    //unused Public ThoughtDesire;
744  
    char vbDblQuote;
745  
746  
    //  --------------- Colours --------------
747  
    int Black;
748  
    int White;
749  
    int LightBlue;
750  
    int DarkBlue;
751  
    //                                           End of  (Declarations)
752  
753  
    public void Initialize_Adaptron() {
754  
755  
        //Called only once from World form when it loads, World.Form_Load()
756  
        //Initialize all values that don't change
757  
758  
        FourWay = chr(170);
759  
760  
        Smarty0 = "Smarty0"; //The initial / default Body name
761  
        InitBodySettingsToSmarty0(); //sets the inital values in BodySetting$()
762  
763  
        // --------------------------  Senses and Sensors --------------------------
764  
        MaxSenses = 10; //max no. of physical senses possible in Values$ arrays
765  
        IsSense = 1; // Flag for Senses versus Devices
766  
767  
        //---- Senses() and Devices() - 2nd index values - Sense and device Properties
768  
        PropertyBinonType = 1; // Stimulus property binon type e.g. 1 = TextBin or 2 = ContBin
769  
        SymbolicOrMagnitude = 2; // Symbolic or Magnitude indicator
770  
        LowerRangeLimit = 3; // Lower limit of range of values, zero is minimum (65 = "A")
771  
        UpperRangeLimit = 4; // Upper limit of range of values, 255 is maximum (90 ="Z")
772  
        LinearOrCircular = 5; // Linear list or Ring/Circular of values for Magnitude sense, Distance is Linear, Compass degrees are Circular (0 to 360)
773  
        IntegersOrLogs = 6; // Integer Values or Log Values, Temperatures are Integers while Decibels are Logs
774  
        NumberOfSensors = 7; // Number of sensors in sensor array
775  
        SensorsDependentOrIndependent = 8; // Are sensors adjacent (dependent) or independent
776  
777  
        Symbolic = 1; // Indicates that the values from this sense are symbolic, range A -> Z
778  
        Magnitude = 2; // Indicates that the values from this sense are numeric, integers, range 0 -> Limit
779  
780  
        Linear = 1; // Indicates that the values go from the lower limit to upper limit
781  
        Circular = 2; // Indicates that the values rap around from the upper limit to 0
782  
783  
        IntegerValues = 1; // Indicates that the values are integer readings
784  
        LogValues = 2; // Indicates that the values are already logs - orders of magnitude
785  
786  
        Dependent = 1; // Sensors in array are beside each other (adjacent)
787  
        Independent = 2; // Sensors are not associated with each other
788  
789  
        //--------------------  Values of stimuli from senses / sensors ------------------------------
790  
791  
        //---- SensorValues 2nd index values - type of information in SensorValues()
792  
        Valu = 1; // the value for the stimulus, if symbolic then value = Asc(Symbol$)
793  
        XQCnt = 2; // the count of times the value has repeated, also used below
794  
        NoName = "_"; // The character used when no letter provided for the IDL value of a TextBin binon
795  
        ABlock = "#"; //a # for internal use to indicate a block at the location
796  
797  
        //---- SensorValues 3rd index values - which past stimulus it is - also used below
798  
        Fired = 0; //stimulus put in this level upon firing before being processed
799  
        Current = 1; //The Fired one becomes the Current one after processing
800  
801  
        //--------------------  Devices ------------------------------------------------
802  
803  
        MaxDevices = 4; //Maximum number of devices = max 4 devices
804  
        IsDevice = 2; // Flag for Devices versus Senses
805  
806  
        NoMoveOrTurn = "z"; //"z" indicates Smarty does not have this move ability
807  
        WheelMovement = "-flrb" + TurnRght + TurnLft + TurnArnd; // rotate right, left and around 180 degrees
808  
        NoMove = WheelMovement.substring(0, 1); //"-" to indicate there was no motion in the Motion$ stimulus value
809  
810  
        //--------------------  The Stimulus Objects (Binons)  -------------------------
811  
812  
        MaxBinons = 5000; // Max number of binons per type
813  
814  
        MaxBinonTypes = 68; //with 2 senses and 1 device this is =5
815  
        //---- BinonTypeName$() 2nd index values
816  
        BinName = 1;
817  
        BinAbbreviation = 2;
818  
        //---- BinonTypes() 2nd index values
819  
        SensOrDevNum = 1; // Pointer points back to sense or device
820  
//  SymbolicOrMagnitude = 2  ' Symbolic or Magnitude indicator - initialized above
821  
822  
        //--------------------  Percept Stimuli Perceived ---------------------------------------
823  
824  
        MaxPercepts = 63; // currently based on maxsenses=5 senses=number of property types
825  
        //---- Percepts() 2nd index values - type of information in Percepts()
826  
        BinId = 1; // the 2nd index value for the binon ID - defined / used below
827  
        //XQCnt = 2                ' the count of times the fired binon has been recognized / fired - DEFINED ABOVE
828  
        //---- PerceptSources() 2nd index values
829  
        FirstSource = 1; // the first / left source Percept binon
830  
        SecondSource = 2; // the second / right source Percept binon
831  
        PerceptLevel = 3; // The level in the Percept tree
832  
833  
        //---- Binons() Properties - 2nd index values
834  
        BType = 1; // The type of binon
835  
        O1 = 2; // Left source binon pointer
836  
        TQ = 3; // the count of times the trigger has fired
837  
        O2 = 4; // Right source binon pointer
838  
        GQ = 5; // the number of times the goal has fired
839  
        IDL = 6; // The ratio value of the binon
840  
        IntVl = 7; // Interest Value (NOVEL, INTERESTING, or Familiar)
841  
        OLv = 8; // Level of object = number of lowest level parts involved
842  
        SP = 9; // Sequential or Parallel property
843  
        TriggerList = 10; // points to the linked list of right target binons [Targets()]
844  
        TriggerCount = 11; // Count of its sequential right targets, >1 means it has more than one goal
845  
        GoalList = 12; // points to the linked list of left target binons [Targets()]
846  
        GoalCount = 13; // Count of its sequential left targets, >1 means can not predict its trigger
847  
        AE = 14; // Action (Stimulus - Response) or Attention (Response - Stimulus) level 1 Sequential binon
848  
849  
        NullObject = -1; // Indicates the O1 or O2 pointer is not pointing to another binon
850  
851  
        NoInterest = -1; // Interest not known yet
852  
853  
        InterestLevels = 2; //2 or 3 - number of interest levels, 2= Novel and Familiar, 3= Novel, Interesting, and Familiar
854  
855  
        //---- Sequential or Parallel property values for Binons(x, SP)
856  
        Sequential = -1;
857  
        Parallel = 1;
858  
859  
        //---- Action or Attention property values for Binons(x, AE)
860  
        Action = 1;
861  
        Attention = 2;
862  
863  
        //---  Linked List of Target Binons - for Percepts and Actions -------------
864  
        MaxTargets = 10000; // = the max number of Target binon entries possible
865  
        //---- Targets' 2nd index property values
866  
        NLnk = 1; // = The pointer to the next Targets() entry in this linked list,
867  
        TargetBinon = 2; // = a left or right Target binon
868  
869  
        NullTarget = 0; // an NLnk pointer at end of linked list
870  
871  
        //--------------------  Stimuli Perceived STM() ---------------------------------------
872  
873  
        MaxLevels = 25; // The highest level of complexity to which the tree can grow
874  
875  
        //---- STM 2nd index values - type of information in STM()
876  
        //BinId = 1          ' the binon ID - initialized above
877  
        //XQCnt = 2          ' the count of times the fired binon has been recognized / fired / repeated - initialized above
878  
        TQCnt = 3; // the count of times its trigger fired for repeat size comparison
879  
880  
        //--------------------  Long Term Memory (LTM) - Monitoring Info. -------------------------
881  
882  
        LtmPerceptTyp = 1;
883  
        LtmPerceptBin = 2;
884  
        LtmESType = 3;
885  
        LtmESActBin = 4;
886  
        LtmARType = 5;
887  
        LtmARActBin = 6;
888  
        LtmActionTyp = 7;
889  
        LtmActionBin = 8;
890  
891  
        MaxMemory = 2000;
892  
893  
        //---------------------- Operational Values -------------------------------
894  
895  
        ASpace = " ";
896  
897  
        ParallelSign = "+"; //Was Chr$(186), 'was "/"
898  
899  
        Normal = 0; //Used as ActTypes for body display
900  
        Happy = 1;
901  
        PartMatch = 2;
902  
        Unhappy = 3;
903  
904  
        vbDblQuote = (char) 34; // = "
905  
906  
        Running = 2;
907  
        Started = 1;
908  
        OperatingMode = Started; //Just started so WorldHelp is displayed
909  
910  
        Black = 0x0;
911  
        White = 0xFFFFFF;
912  
        LightBlue = 0xFF8080;
913  
        DarkBlue = 0xC00000;
914  
915  
        change(); // persist changes
916  
    }
917  
918  
    private static String chr(int c) {
919  
        return String.valueOf((char) c);
920  
    }
921  
922  
    public final void GetTypeInfo(int BinTyp, ISetter<String> BinonTyp, ISetter<String> Rdgs) {
923  
924  
        //Returns the names of the BinonTyp$ and Rdg$ for the given BinTyp
925  
926  
//  Public BinonTypeName$(1 To 5, 1 To 2) 'The names and abbreviations for the various binon types
927  
//                '---- BinonTypeName$() 2nd index values
928  
//  Public BinName                '1
929  
//  Public BinAbbreviation        '2
930  
931  
        Rdgs.set("");
932  
        BinonTyp.set("");
933  
        if (BinTyp == NullType) {
934  
            BinonTyp.set("Null");
935  
            Rdgs.set("~  = ");
936  
        } else {
937  
            BinonTyp.set(BinonTypeName[BinTyp][BinName]);
938  
            Rdgs.set(BinonTypeName[BinTyp][BinAbbreviation] + "= ");
939  
        }
940  
941  
    } //End of GetTypeInfo()
942  
943  
    public final int BinonTypeOf(int TheBinon) {
944  
        int tempBinonTypeOf;
945  
946  
        if (TheBinon == NullObject) {
947  
            tempBinonTypeOf = NullType;
948  
        } else {
949  
            tempBinonTypeOf = Binons[TheBinon][BType];
950  
        }
951  
952  
        return tempBinonTypeOf;
953  
    } //End of BinonTypeOf()
954  
955  
    public final void GetValue(int OOO, Var<String> v) {
956  
957  
        //Returns the value for the object based on its Type
958  
959  
        int Readng;
960  
        int TheBinon;
961  
        int LeftBinon;
962  
963  
        //Recursive routine to add values to V$ for any binon/object
964  
965  
        if (OOO == NullObject) {
966  
            return;
967  
        }
968  
969  
//VB TO JAVA CONVERTER NOTE: The following VB 'Select Case' included either a non-ordinal switch expression or non-ordinal, range-type, or non-constant 'Case' expressions and was converted to Java 'if-else' logic:
970  
//  Select Case BinonTypeOf(OOO)
971  
        var tempVar = BinonTypeOf(OOO);
972  
973  
//ORIGINAL LINE: Case ActBin //Public ActBin = sequential - action = NumPercepts+1
974  
        if (tempVar == ActBin) //Public ActBin = sequential - action = NumPercepts+1
975  
        {
976  
977  
            TheBinon = OOO;
978  
979  
            while ping (BinonTypeOf(TheBinon) == ActBin) //While we have an Action
980  
            {
981  
                LeftBinon = TheBinon;
982  
                //Go down the left side to the bottom Property or Percept binon
983  
                while ping (BinonTypeOf(LeftBinon) == ActBin) //While we have an Action
984  
                {
985  
                    LeftBinon = Binons[LeftBinon][O1]; //Get the left source part
986  
                }
987  
988  
                GetValue(LeftBinon, v); //get the property and/or Percept binon
989  
                v.set(v.get() + SequentialSign);
990  
991  
                //Go to the right side and repeat going down its left side
992  
                TheBinon = Binons[TheBinon][O2];
993  
            }
994  
            GetValue(TheBinon, v); //get the last Property or Percept binon on the right side
995  
996  
        }
997  
//ORIGINAL LINE: Case 1 To NumProperties //Senses / property binon
998  
        else if (tempVar >= 1 && tempVar <= NumProperties) //Senses / property binon
999  
        {
1000  
1001  
            Readng = Binons[OOO][IDL]; //The binons value
1002  
            if (BinonTypes[BinonTypeOf(OOO)][SymbolicOrMagnitude] == Symbolic) {
1003  
                if (Readng < 32) {
1004  
                    v.set(v.get() + "~");
1005  
                } else {
1006  
                    v.set(v.get() + chr(Readng)); //text
1007  
                }
1008  
            } else //Else the property is Magnitude
1009  
            {
1010  
                v.set(v.get() + vbToStr(Readng)); //a number
1011  
            }
1012  
1013  
        }
1014  
//ORIGINAL LINE: Case NumProperties + 1 To NumPercepts //Percept binons
1015  
        else if (tempVar >= NumProperties + 1 && tempVar <= NumPercepts) //Percept binons
1016  
        {
1017  
1018  
            TheBinon = OOO;
1019  
1020  
            while ping (BinonTypeOf(TheBinon) > NumProperties) //While we have a Percept
1021  
            {
1022  
                LeftBinon = TheBinon;
1023  
                //Go down the left side to the bottom property binon
1024  
                while ping (BinonTypeOf(LeftBinon) > NumProperties) //While we have a Percept
1025  
                {
1026  
                    LeftBinon = Binons[LeftBinon][O1]; //Get the left source part
1027  
                }
1028  
                GetValue(LeftBinon, v); //get the property binon
1029  
                v.set(v.get() + ParallelSign);
1030  
1031  
                //Go to the right side and repeat going down its left side
1032  
                TheBinon = Binons[TheBinon][O2];
1033  
1034  
            }
1035  
            GetValue(TheBinon, v); //get the last Property binon on the right side
1036  
1037  
        }
1038  
//ORIGINAL LINE: Case ActBin + 1 To NumBinonTypes //A response / device binon
1039  
        else if (tempVar >= ActBin + 1 && tempVar <= NumBinonTypes) //A response / device binon
1040  
        {
1041  
            Readng = Binons[OOO][IDL];
1042  
            if (Readng < 32) {
1043  
                v.set(v.get() + "~");
1044  
            } else {
1045  
                v.set(v.get() + chr(Readng)); //symbolic
1046  
            }
1047  
1048  
        }
1049  
1050  
    } //End of GetValue()
1051  
1052  
    public final void RememberResponse(int RespBin, int StoreAtPlace) {
1053  
1054  
        //Save the last response for LTM display
1055  
1056  
//  Public LTMEMORY&(1 To 2000, 1 To 6) -- comment stefan: not really - it's going to 8
1057  
//                                '1st index is StoreAt cycle number
1058  
//                                '2nd index is what type of information is in the LTM
1059  
//
1060  
//                '---- LTMEMORY() 2nd index values - type of information in LTMEMORY()
1061  
//  Public LtmPerceptTyp           '1 Percept binon type
1062  
//  Public LtmPerceptBin           '2 Percept binon
1063  
//  Public LtmESType              '3 Type of ES Binon - may be an S
1064  
//  Public LtmESActBin            '4 ES Actbin
1065  
//  Public LtmARType              '5 Type of AR Binon - may be an R
1066  
//  Public LtmARActBin            '6 AR ActBin
1067  
//  Public LtmActionTyp           '7 Action binon type
1068  
//  Public LtmActionBin           '8 Action binon
1069  
1070  
        LTMEMORY[StoreAtPlace][LtmActionTyp] = BinonTypeOf(RespBin);
1071  
        LTMEMORY[StoreAtPlace][LtmActionBin] = RespBin;
1072  
1073  
    } //End of RememberResponse()
1074  
1075  
    public final void RememberStimulus(int TrigObj, int StoreAtPlace) {
1076  
1077  
        //Save the given relationship / association in LTM for display
1078  
1079  
//  Public LTMEMORY&(1 To 2000, 1 To 6)
1080  
//                                '1st index is StoreAt cycle number
1081  
//                                '2nd index is what type of information is in the LTM
1082  
//
1083  
//                '---- LTMEMORY() 2nd index values - type of information in LTMEMORY()
1084  
//  Public LtmPerceptTyp           '1 Percept binon type
1085  
//  Public LtmPerceptBin           '2 Percept binon
1086  
//  Public LtmESType              '3 Type of ES Binon - may be an S
1087  
//  Public LtmESActBin            '4 ES Actbin
1088  
//  Public LtmARType              '5 Type of AR Binon - may be an R
1089  
//  Public LtmARActBin            '6 AR ActBin
1090  
//  Public LtmActionTyp           '7 Action binon type
1091  
//  Public LtmActionBin           '8 Action binon
1092  
1093  
        LTMEMORY[StoreAtPlace][LtmPerceptTyp] = BinonTypeOf(TrigObj);
1094  
        LTMEMORY[StoreAtPlace][LtmPerceptBin] = TrigObj;
1095  
1096  
    } //End of RememberStimulus()
1097  
1098  
    public final void SetupSense(int SenseNum, String Sense_Name, String BinonName, String BinonAbbrev, int MagnOrSymb, int LowerLimit, int UpperLimit, String Stimuli, int LinOrCirc, int IntOrLog, int NumSensrs, int SensorDependency) {
1099  
        printVars_str SetupSense(+SenseNum, +Sense_Name, +NumSensrs);
1100  
        //If the SenseNum passed in is zero this routine returns the Sense number (SenseNum)
1101  
        //for the given Sense, else it modifies the given SenseNum
1102  
        //The range or number of sensors is NumSensrs - max 256
1103  
        //IntensityRange:  is the range or number of intensity values for the sensors
1104  
        //Stimuli$:        is a string of possible stimuli for this sensor - saved in SensorStimuli$()
1105  
        //Sense_Name$:     is the name of the sense
1106  
        //MagnOrSymb:  = Magnitude if each sensor measures a Magnitude range of intensity
1107  
        //             = Symbolic if each sensor provides readings that are symbolic.
1108  
        //LinOrCirc:   = Linear
1109  
        //             = Circular
1110  
1111  
        //unused String Ssr = null;
1112  
        int UseSense;
1113  
        //unused String SG = null;
1114  
        int Sns;
1115  
        var BinTypNum = new Var<>(0);
1116  
        String DisplayStimuli;
1117  
1118  
//  Public NumSenses              'The number of physical senses, Max of 8
1119  
//                                'Currently equals the NumProperties since each sense currently = 1 property type
1120  
//  Public MaxSenses              'Maximum number of senses = max 8 physical senses
1121  
//  Public Sense$(1 To 8)         'Names of senses, up to 8 physical senses
1122  
//
1123  
//  Public Senses[1 To 8][1 To 6] 'Properties of the different senses
1124  
//                                '1st index = Sense number
1125  
//                                '2nd index = Sense property
1126  
//  Public SensorStimuli$(1 To 10)  'A string of the possible symbolic stimuli for the sensor
1127  
//
1128  
//                '---- Senses() - 2nd index values - Sense Properties
1129  
//  Public PropertyBinonType      '1, Stimulus property binon type e.g. 1 = TextBin or 2 = ContBin
1130  
//  Public SymbolicOrMagnitude    '2, Symbolic or Magnitude indicator
1131  
//  Public LowerRangeLimit        '3, Lower limit of range of values, zero is minimum (65 = "A")
1132  
//  Public UpperRangeLimit        '4, Upper limit of range of values, 255 is maximum (90 ="Z")
1133  
//  Public LinearOrCircular       '5, Linear list or Ring/Circular of values for Magnitude sense, Distance is Linear, Compass degrees are Circular (0 to 360)
1134  
//  Public IntegersOrLogs         '6, Integer Values or Log Values, Temperatures are Integers while Decibels are Logs
1135  
//  Public NumberOfSensors        '7  Number of sensors in sensor array
1136  
//  Public SensorsDependentOrIndependent '8 are sensors adjacent (dependent) or independent
1137  
//
1138  
//  Public Symbolic               '1, Indicates that the values from this sense are symbolic, range A -> Z
1139  
//  Public Magnitude              '2, Indicates that the values from this sense are numeric, integers, range 0 -> Limit
1140  
//
1141  
//  Public Linear                 '1, Indicates that the values go from the lower limit to upper limit
1142  
//  Public Circular               '2, Indicates that the values rap around from the upper limit to 0
1143  
//
1144  
//  Public IntegerValues          '1, Indicates that the values are integer readings
1145  
//  Public LogValues              '2, Indicates that the values are already logs - orders of magnitude
1146  
//
1147  
1148  
        if (NumSenses == MaxSenses) //Can't assign another new sense number
1149  
        {
1150  
            Stop();
1151  
        }
1152  
        //There are only so many senses in SensorValues array
1153  
        //currently set to 8 in Adaptron.Initialize_Adaptron()
1154  
        if (SenseNum == 0) //don't have a sense number yet so assign and return it
1155  
        {
1156  
            NumSenses = NumSenses + 1; //The new sense number for this sense
1157  
            SenseNum = NumSenses; //The returned sense number
1158  
        } else if (SenseNum > MaxSenses) //else it is more than allowed
1159  
        {
1160  
            Stop();
1161  
        } else if (SenseNum > NumSenses + 1) //else is it higher than the next one available
1162  
        {
1163  
            Stop();
1164  
        } else if (SenseNum <= NumSenses) //else use the one passed in - overriding an existing sense
1165  
        {
1166  
        } else if (SenseNum == NumSenses + 1) //else is it equal to the next one available
1167  
        {
1168  
            NumSenses = SenseNum; //which equals NumSenses + 1
1169  
        }
1170  
1171  
        UseSense = SenseNum;
1172  
1173  
        if (NumSensrs > 8) //only 8 sensors allowed per sense for now - maybe only
1174  
        {
1175  
            Stop();
1176  
        }
1177  
        //need this limit if independent sensors
1178  
        if (IntensityRange > 256) //only 256 values allowed for intensity
1179  
        {
1180  
            Stop();
1181  
        }
1182  
1183  
        Sense[UseSense] = Sense_Name;
1184  
        Senses[UseSense][SymbolicOrMagnitude] = MagnOrSymb;
1185  
        Senses[UseSense][LowerRangeLimit] = LowerLimit;
1186  
        Senses[UseSense][UpperRangeLimit] = UpperLimit;
1187  
        SensorStimuli[UseSense] = Stimuli; //If not "" these take preference over the upper and lower limit
1188  
1189  
        if (Senses[UseSense][SymbolicOrMagnitude] == Magnitude) //Magnitude READINGS
1190  
        {
1191  
            Senses[UseSense][LinearOrCircular] = LinOrCirc; //can be circular or linear
1192  
            SensorStimuli[UseSense] = ""; //can not have symbolic list
1193  
        } else //Symbolic readings can not be circular
1194  
        {
1195  
            Senses[UseSense][LinearOrCircular] = Linear; //non circular
1196  
        }
1197  
        Senses[UseSense][IntegersOrLogs] = IntOrLog;
1198  
        Senses[UseSense][NumberOfSensors] = NumSensrs;
1199  
        Senses[UseSense][SensorsDependentOrIndependent] = SensorDependency;
1200  
1201  
        //SetupBinonTypes(SenseOrDeviceNum, BinNam$, BinAbb$, IsASense, BinonTypReturned)
1202  
        SetupBinonTypes(UseSense, BinonName, BinonAbbrev, IsSense, BinTypNum);
1203  
        Senses[UseSense][PropertyBinonType] = BinTypNum.get(); //Currently BinonType = Sense = property binon
1204  
1205  
        //and fill in sense info on world page
1206  
1207  
        new StringBuilder sensorInfo;
1208  
        for ping (Sns = 1; Sns <= NumSenses; Sns++) {
1209  
            if (Senses[Sns][SymbolicOrMagnitude] == Magnitude) {
1210  
                DisplayStimuli = StringHelper.trim(String.valueOf(Senses[Sns][LowerRangeLimit]), ' ') + " to" + Senses[Sns][UpperRangeLimit];
1211  
            } else //symbolic values
1212  
            {
1213  
                if (SensorStimuli[Sns].equals("")) //If no symbolic list then use upper and lower limit
1214  
                {
1215  
                    DisplayStimuli = chr(Senses[Sns][LowerRangeLimit]) + " to " + chr(Senses[Sns][UpperRangeLimit]);
1216  
                } else {
1217  
                    DisplayStimuli = SensorStimuli[Sns];
1218  
                    DisplayStimuli = replace(DisplayStimuli, NoMoveOrTurn, ASpace);
1219  
                }
1220  
            }
1221  
1222  
            sensorInfo.append(takeFirst(8, Sense[Sns] + ":        ")
1223  
              + " " + DisplayStimuli + "  " + SymbOrMagn(IsSense, Sns) + "\r\n");
1224  
        }
1225  
1226  
        World.showSensorValues(str(sensorInfo));
1227  
1228  
    } //End of SetupSense()
1229  
1230  
    private static void Stop(S msg default "STOP") {
1231  
        throw new RuntimeException(msg);
1232  
    }
1233  
1234  
    public final void SetupVision() //Called from DesignBody.UseThisBody_Click()
1235  
    {
1236  
1237  
        int VisionSense;
1238  
        int MS = 0;
1239  
        int ll = 0; // renamed because of clash with JavaX's LL
1240  
        int UL = 0;
1241  
1242  
//    BodySetting$(7) = VisionConfig.VisionDown
1243  
//    BodySetting$(8) = VisionConfig.VisionLeft
1244  
//    BodySetting$(9) = VisionConfig.VisionRight
1245  
//    BodySetting$(10) = VisionConfig.VisionInFront
1246  
//    BodySetting$(11) = VisionConfig.VisionBehind
1247  
//    BodySetting$(12) = VisionConfig.VisionSymbolicOrMagnitude(0)
1248  
//    BodySetting$(13) = VisionConfig.VisionSymbolicOrMagnitude(1)
1249  
//    BodySetting$(21) = VisionConfig.VisionSymbolicOrMagnitude(2)
1250  
1251  
1252  
        VisionSense = 0; //so a new sense number assigned automatically by SetupSense()
1253  
1254  
//    Body 1              'Sense #1 looks down at square, Device #1 moves Left, Right, Up, Down
1255  
//            'set up Sense #1, 1 sensor
1256  
//          'SetupSense(SenseNum, Sense_Name$, BinonName$, BinonAbbrev$, MagnOrSymb, LowerLimit, UpperLimit, _
1257  
//                          LinOrCirc, IntOrLog, NumSensrs, SensorDependency)
1258  
//      Call SetupSense(InputSense, "Input", "Text", "Tx", Symbolic, 65, 122, Linear, IntegerValues, 1, Independent)
1259  
//
1260  
//          'SetupDevice(DeviceNum, DName$, BinonName$, BinonAbbrev$, MagnOrSymb, LowerLimit, UpperLimit, _
1261  
//                       Responses$, LinOrCirc, IntOrLog)
1262  
//      Call SetupDevice(DevNum, "Output", "Letter", "Lt", Symbolic, 97, 100, "", Linear, IntegerValues)
1263  
//
1264  
//    Body 2              'Looks forward at next cell, Turns left, right & moves forward
1265  
//            'set up Sense #1, 1 Sensor
1266  
//      Call SetupSense(InputSense, "Input", "Text", "Tx", Symbolic, 65, 113, Linear, IntegerValues, 1, Independent)
1267  
//      Call SetupDevice(DevNum, "Output", "Letter", "Lt", Symbolic, 97, 99, "", Linear, IntegerValues)
1268  
1269  
        if (isTrue(BodySetting[12])) //radio button VisionSymbolicOrMagnitude(0) selected
1270  
        {
1271  
            MS = Symbolic;
1272  
            ll = 65; //"A" 1st cell location
1273  
            UL = 122; //"z" last possible cell location - actually if 8 x 8 then it is Chr$(129)
1274  
        }
1275  
        if (isTrue(BodySetting[13])) //radio button VisionSymbolicOrMagnitude(1) selected
1276  
        {
1277  
            MS = Magnitude;
1278  
            ll = 1;
1279  
            UL = 8; //max 8 cells in any direction
1280  
        }
1281  
        if (isTrue(BodySetting[21])) //radio button VisionSymbolicOrMagnitude(2) selected
1282  
        {
1283  
            MS = Symbolic;
1284  
            ll = asc(Wall); //Wall$ = Chr$(20) Terminal font
1285  
            UL = asc(EmptySquare); //empty square beside it
1286  
        }
1287  
1288  
        if (eq(BodySetting[7], "1")) //Looking down box is checked
1289  
        {
1290  
            //SetupSense(SenseNum, Sense_Name$, BinonName$, BinonAbbrev$, MagnOrSymb, LowerLimit, UpperLimit, _
1291  
            //Stimuli, LinOrCirc, IntOrLog, NumSensrs, SensorDependency);
1292  
            SetupSense(VisionSense, "VisionD", "VisionD", "VD", MS, ll, UL, "", Linear, IntegerValues, 1, Independent);
1293  
        }
1294  
        VisionSense = 0;
1295  
        if (eq(BodySetting[8], "1")) //Looking left box is checked
1296  
        {
1297  
            SetupSense(VisionSense, "VisionL", "VisionL", "Vl", MS, ll, UL, "", Linear, IntegerValues, 1, Independent);
1298  
        }
1299  
        VisionSense = 0;
1300  
        if (eq(BodySetting[9], "1")) //Looking right box is checked
1301  
        {
1302  
            SetupSense(VisionSense, "VisionR", "VisionR", "Vr", MS, ll, UL, "", Linear, IntegerValues, 1, Independent);
1303  
        }
1304  
        VisionSense = 0;
1305  
        if (eq(BodySetting[10], "1")) //Looking InFront box is checked
1306  
        {
1307  
            SetupSense(VisionSense, "VisionF", "VisionF", "Vf", MS, ll, UL, "", Linear, IntegerValues, 1, Independent);
1308  
        }
1309  
        VisionSense = 0;
1310  
        if (eq(BodySetting[11], "1")) //Looking Behind box is checked
1311  
        {
1312  
            SetupSense(VisionSense, "VisionB", "VisionB", "Vb", MS, ll, UL, "", Linear, IntegerValues, 1, Independent);
1313  
        }
1314  
1315  
    } //End of SetupVision()
1316  
1317  
    private int asc(String s) {
1318  
        return empty(s) ? 0 : s.charAt(0);
1319  
    }
1320  
1321  
    private boolean isTrue(String s) {
1322  
        return "True".equals(s);
1323  
    }
1324  
1325  
    public final void SetupTouch() {
1326  
1327  
    } //End of SetupTouch()
1328  
1329  
    public final void SetupWheels() {
1330  
1331  
        int WheelsDevice;
1332  
        int MS;
1333  
        //unused String LL = null;
1334  
        //unused String UL = null;
1335  
        StringBuilder WheelResponses;
1336  
        int MotionSense;
1337  
1338  
//    BodySetting$(14) = WheelsConfig.MoveForward
1339  
//    BodySetting$(15) = WheelsConfig.MoveLeft
1340  
//    BodySetting$(16) = WheelsConfig.MoveRight
1341  
//    BodySetting$(17) = WheelsConfig.MoveBackward
1342  
//    BodySetting$(18) = WheelsConfig.TurnRight
1343  
//    BodySetting$(19) = WheelsConfig.TurnLeft
1344  
//    BodySetting$(20) = WheelsConfig.TurnAround
1345  
//    BodySetting$(4) = WheelsConfig.AddAWheelSensor
1346  
1347  
//    Body 1              'Sense #1 looks down at square, Device #1 moves Left, Right, Up, Down
1348  
//            'set up Sense #1, 1 sensor
1349  
//          'SetupSense(SenseNum, Sense_Name$, BinonName$, BinonAbbrev$, MagnOrSymb, LowerLimit, UpperLimit, _
1350  
//                          LinOrCirc, IntOrLog, NumSensrs, SensorDependency)
1351  
//      Call SetupSense(InputSense, "Input", "Text", "Tx", Symbolic, 65, 113, Linear, IntegerValues, 1, Independent)
1352  
//
1353  
//      Call SetupDevice(DevNum, "Output", "Letter", "Lt", Symbolic, 97, 100, "", Linear, IntegerValues)
1354  
//
1355  
//    Body 2              'Looks forward at next cell, Turns left, right & moves forward
1356  
//            'set up Sense #1, 1 Sensor
1357  
//      Call SetupSense(InputSense, "Input", "Text", "Tx", Symbolic, 65, 113, Linear, IntegerValues, 1, Independent)
1358  
//      Call SetupDevice(DevNum, "Output", "Letter", "Lt", Symbolic, 97, 99, "", Linear, IntegerValues)
1359  
1360  
        WheelsDevice = 0; //The device number assigned to the device by SetupDevice()
1361  
        MS = Symbolic;
1362  
        WheelResponses = new StringBuilder("-"); //will be filled in with move symbols "-flrb" and turn symbols,
1363  
        //a "z" for an invalid movement, the "-" for do nothing
1364  
        WheelsTurn = false; //Assume no turning capability, display Smarty as Happy face
1365  
        if (MS == Symbolic) {
1366  
            for ping (var I = 14; I <= 20; I++) {
1367  
                if (eq(BodySetting[I], "1")) //if it is checked then
1368  
                {
1369  
                    switch (I) {
1370  
                        case 14: //Forward
1371  
                            WheelResponses.append(MoveForward);
1372  
                            break;
1373  
                        case 15: //Left
1374  
                            WheelResponses.append(MoveToLeft);
1375  
                            break;
1376  
                        case 16: //Right
1377  
                            WheelResponses.append(MoveToRight);
1378  
                            break;
1379  
                        case 17: //Backward
1380  
                            WheelResponses.append(MoveBackward);
1381  
                            break;
1382  
                        case 18: //Turn right 90 degrees
1383  
                            WheelResponses.append(TurnRght); //right angle symbol
1384  
                            WheelsTurn = true;
1385  
                            break;
1386  
                        case 19: //Turn left 90 degrees
1387  
                            WheelResponses.append(TurnLft); //left angle symbol
1388  
                            WheelsTurn = true;
1389  
                            break;
1390  
                        case 20: //Turn around 180 degrees
1391  
                            WheelResponses.append(TurnArnd); //double arrow symbol
1392  
                            WheelsTurn = true;
1393  
                            break;
1394  
                    }
1395  
                } else {
1396  
                    WheelResponses.append(NoMoveOrTurn);
1397  
                }
1398  
            }
1399  
        }
1400  
1401  
        WheelMovement = WheelResponses.toString(); //the same movements should be recognizable
1402  
1403  
        //Setup a motion sense if WheelsConfig.AddAWheelSensor = 1 is checked
1404  
        if (eq(BodySetting[4], "1")) {
1405  
            MotionSense = 0;
1406  
            //SetupSense(SenseNum, Sense_Name$, BinonName$, BinonAbbrev$, MagnOrSymb, LowerLimit, UpperLimit, _
1407  
            //Stimuli, LinOrCirc, IntOrLog, NumSensrs, SensorDependency);
1408  
            SetupSense(MotionSense, "Motion", "Motion", "Mo", Symbolic, 1, 1, WheelMovement, Linear, IntegerValues, 1, Independent);
1409  
        }
1410  
1411  
        //SetupDevice(DeviceNum, DName$, BinonName$, BinonAbbrev$, MagnOrSymb, LowerLimit, UpperLimit, _
1412  
        //Responses, LinOrCirc, IntOrLog);
1413  
        SetupDevice(WheelsDevice, "Wheels", "Wheels", "Wh", MS, 1, 1, WheelResponses.toString(), Linear, IntegerValues);
1414  
1415  
1416  
    } //End of SetupWheels()
1417  
1418  
    public final void SetupArms() {
1419  
1420  
    } //End of SetupArms()
1421  
1422  
    public void InitBodyToSmarty0(String[] Body) //Initialize the BodySetting$() or BodyValue$() to Smarty0 values
1423  
    {
1424  
1425  
        Body[0] = "21"; //Count of Body$() values
1426  
        Body[1] = Smarty0;
1427  
        Body[2] = "1"; //Vision.Value = 1 - checked
1428  
        Body[3] = "0"; //Touch.Value
1429  
        Body[4] = "0"; //WheelsConfig.AddAWheelSensor
1430  
        Body[5] = "1"; //Wheels.Value
1431  
        Body[6] = "0"; //Arms.Value
1432  
        Body[7] = "1"; //VisionConfig.VisionDown
1433  
        Body[8] = "0"; //VisionConfig.VisionLeft
1434  
        Body[9] = "0"; //VisionConfig.VisionRight
1435  
        Body[10] = "0"; //VisionConfig.VisionInFront
1436  
        Body[11] = "0"; //VisionConfig.VisionBehind
1437  
        Body[12] = "True"; //VisionConfig.VisionSymbolicOrMagnitude(0)
1438  
        Body[13] = "False"; //VisionConfig.VisionSymbolicOrMagnitude(1)
1439  
        Body[14] = "1"; //WheelsConfig.MoveForward
1440  
        Body[15] = "1"; //WheelsConfig.MoveLeft
1441  
        Body[16] = "1"; //WheelsConfig.MoveRight
1442  
        Body[17] = "1"; //WheelsConfig.MoveBackward
1443  
        Body[18] = "0"; //WheelsConfig.TurnRight
1444  
        Body[19] = "0"; //WheelsConfig.TurnLeft
1445  
        Body[20] = "0"; //WheelsConfig.TurnAround
1446  
        Body[21] = "False"; //VisionConfig.VisionSymbolicOrMagnitude(2)
1447  
1448  
    } //End of InitBodyToSmarty0()
1449  
1450  
    public void InitBodySettingsToSmarty0() {
1451  
1452  
        InitBodyToSmarty0(BodySetting);
1453  
1454  
    }
1455  
1456  
    public final void InitBodyValuesToSmarty0() {
1457  
1458  
        InitBodyToSmarty0(BodyValue);
1459  
1460  
    }
1461  
1462  
    public final String SymbOrMagn(int SensOrDevc, int SensOrDevcNumber) {
1463  
        String tempSymbOrMagn;
1464  
1465  
        //called from SetupSense() & SetupDevice()
1466  
1467  
        int SorG;
1468  
1469  
        if (SensOrDevc == IsSense) {
1470  
            SorG = Senses[SensOrDevcNumber][SymbolicOrMagnitude];
1471  
        } else //Else SensOrDevc = IsDevice
1472  
        {
1473  
            SorG = Devices[SensOrDevcNumber][SymbolicOrMagnitude];
1474  
        }
1475  
1476  
        if (SorG == Symbolic) {
1477  
            tempSymbOrMagn = "Symbolic";
1478  
        } else {
1479  
            tempSymbOrMagn = "Magnitude";
1480  
        }
1481  
1482  
        return tempSymbOrMagn;
1483  
    } //End of SymbOrMagn$()
1484  
1485  
    public final void SetupBinonTypes(int SenseOrDeviceNum, String BinNam, String BinAbb, int IsASense, Var<Integer> BinonTypReturned) {
1486  
1487  
        //Called by SetUpSense() and SetupDevice()
1488  
1489  
        //After setting up a sense or device the binontypes() information must be updated correctly
1490  
        //SenseOrDeviceNum could be one that already exists and is being reset
1491  
1492  
        int BinTypNum = 0;
1493  
        int PerceptBinTyp;
1494  
        int DHabitBinTyp;
1495  
        int FirstPtr;
1496  
        int SecondPtr;
1497  
        int ThisPercept;
1498  
        int StartPercept;
1499  
        int EndPercept;
1500  
        int ThisLevel;
1501  
1502  
//                '---- Binons[x][BType] - stimulus and response binon types
1503  
//  TextBin = 1              ' = A letter (symbolic)
1504  
//  ContBin = 2              ' = Contrast pattern - intensity (Magnitude)
1505  
//                                'Parallel combinations should be put in the binons above the property type ones.
1506  
//  NCBin = 3                ' = TextBin & ContBin combination
1507  
//  ActBin = 4               ' = 2^N = NumPercepts+1, holds sequential binons.
1508  
//  LetrBin = 5              ' = Response binon = letters
1509  
1510  
        //------------------  Property and Percept combinations  --------------------------
1511  
        //The number of combinations at each level of complexity when combining independent senses.
1512  
        //# of Sensors
1513  
        //  or Senses
1514  
        //           Stimuli @ P-Level 1  2  3  4  5  6  7  8  Total
1515  
        //    1                        1                          1
1516  
        //    2                        2  1                       3
1517  
        //    3                        3  3  1                    7
1518  
        //    4                        4  6  4  1                15
1519  
        //    5                        5 10 10  5  1             31
1520  
        //    6                        6 15 20 15  6  1          63
1521  
        //    7                        7 21 35 35 21  7  1      127
1522  
        //    8                        8 28 56 70 56 28  8  1   255
1523  
        //    N                                                  2^N - 1
1524  
1525  
//  Public NumProperties          'N=2, The number of stimulus property binon types
1526  
//  Public NumPercepts             'N=3, The number of property binons and Percept combinations of them
1527  
//  Public NumBinonTypes          '= 2^N+1, number of property binons, Percept combination binon types, Action type and
1528  
//                                '         the response type
1529  
//  Public MaxBinonTypes          'with 2 senses and 1 device this is =5
1530  
//  Public BinonTypeName$(1 To 31, 1 To 2) 'The names and abbreviations for the various binon types
1531  
//                '---- BinonTypeName$() 2nd index values
1532  
//  Public BinName                '1
1533  
//  Public BinAbbreviation        '2
1534  
//                                'The source types of property binons are 1=TextBin, 2=ContBin. There are N of these
1535  
//                                'and all other Percept combinations such as Name&Cont.
1536  
//                                'There are 2^N-1 Property plus Percept types
1537  
//                                'There is just the one Action type - a sequential combination of the
1538  
//                                'Property binons, Percept binons, response binon and/or Action binons.
1539  
//                                'Added responses as LetrBin binons so NumBinonTypes = 2^N + 1
1540  
//  Public BinonTypes[1 To 31][1 To 4]     'The binon types for stimuli, ActBin and responses
1541  
//                                '1st index = the type of binon (dimension = NumBinonTypes)
1542  
//                                '2nd index = binon type property
1543  
//
1544  
        //---- BinonTypes() 2nd index values
1545  
//  Public SensOrDevNum           '1, Pointer points back to sense or device
1546  
//  Public SymbolicOrMagnitude    '2, Symbolic or Magnitude indicator
1547  
1548  
        if (IsASense == IsSense) //If setting up a sense then
1549  
        {
1550  
            if (SenseOrDeviceNum <= NumProperties) //if it is an existing sense then resetting it
1551  
            {
1552  
                BinTypNum = SenseOrDeviceNum;
1553  
1554  
            } else if (SenseOrDeviceNum == NumProperties + 1) //else if it is the next new sense then
1555  
            {
1556  
                NumProperties = SenseOrDeviceNum; //N=2, The number of stimulus property binon types
1557  
                BinTypNum = NumProperties;
1558  
                NumPercepts = (2 << (NumProperties - 1)) - 1; //N=3, The number of property binons and Percept combinations of them
1559  
1560  
                for ping (PerceptBinTyp = NumProperties + 1; PerceptBinTyp <= NumPercepts; PerceptBinTyp++) {
1561  
                    BinonTypeName[PerceptBinTyp][BinName] = "Percept";
1562  
                    BinonTypeName[PerceptBinTyp][BinAbbreviation] = "Pc";
1563  
                }
1564  
1565  
                //Setup the PerceptSources() to point at the correct source entries at the level below
1566  
                ThisLevel = 2; //Filling in level 2 Percept information
1567  
                ThisPercept = NumProperties + 1; //Position of 1st Percept combination of sense/property binons
1568  
                StartPercept = ThisPercept; //Start of range of pairs - level-2 Percepts, level-1 Percepts=property binons
1569  
                for ping (FirstPtr = 1; FirstPtr < NumProperties; FirstPtr++) //Create all the 2nd level pair pointers
1570  
                {
1571  
                    for ping (SecondPtr = FirstPtr + 1; SecondPtr <= NumProperties; SecondPtr++) {
1572  
                        PerceptSources[ThisPercept][FirstSource] = FirstPtr;
1573  
                        PerceptSources[ThisPercept][SecondSource] = SecondPtr;
1574  
                        PerceptSources[ThisPercept][PerceptLevel] = ThisLevel;
1575  
                        ThisPercept = ThisPercept + 1; //Next combination Percept will go in here
1576  
                    }
1577  
                }
1578  
                EndPercept = ThisPercept - 1; //End of range of level-2 Percepts - pairs of property binons
1579  
1580  
                //Setup the level-3+ PerceptSources()
1581  
                while ping (EndPercept - StartPercept > 0) {
1582  
                    ThisLevel = ThisLevel + 1; //populate next level up
1583  
                    for ping (FirstPtr = StartPercept; FirstPtr < EndPercept; FirstPtr++) {
1584  
                        for ping (SecondPtr = FirstPtr + 1; SecondPtr <= EndPercept; SecondPtr++) {
1585  
                            if (PerceptSources[FirstPtr][SecondSource] == PerceptSources[SecondPtr][FirstSource]) //if share a common sub Percept
1586  
                            {
1587  
                                PerceptSources[ThisPercept][FirstSource] = FirstPtr;
1588  
                                PerceptSources[ThisPercept][SecondSource] = SecondPtr;
1589  
                                PerceptSources[ThisPercept][PerceptLevel] = ThisLevel;
1590  
                                ThisPercept = ThisPercept + 1; //Next combination Percept will go in here
1591  
                            }
1592  
                        }
1593  
                    }
1594  
                    StartPercept = EndPercept + 1; //Start next range after end of previous range
1595  
                    EndPercept = ThisPercept - 1; //End of range of this level Percepts
1596  
                }
1597  
1598  
                ActBin = NumPercepts + 1; //ActBin holds action and expectation binons = 2^N = NumPercepts + 1
1599  
                BinonTypeName[ActBin][BinName] = "Action";
1600  
                BinonTypeName[ActBin][BinAbbreviation] = "Ac";
1601  
1602  
                NumBinonTypes = ActBin; //The number of types so far = 2^N
1603  
            } else {
1604  
                Stop(); //no other value allowed
1605  
            }
1606  
1607  
        } else //Else setting up a device
1608  
        {
1609  
            if (SenseOrDeviceNum + ActBin <= NumBinonTypes) //If it is an existing device then restting it
1610  
            {
1611  
                BinTypNum = SenseOrDeviceNum;
1612  
1613  
            } else if (SenseOrDeviceNum + ActBin == NumBinonTypes + 1) //else if it is the next new device number then
1614  
            {
1615  
                NumBinonTypes = NumBinonTypes + 1; //= 2^N+x, number of property binons, Percept combination binon types,
1616  
                BinTypNum = NumBinonTypes;
1617  
                NumDHabits = (2 << (SenseOrDeviceNum - 1)) - 1; //N=3, The number of device response binons and D-Habit combinations of them
1618  
1619  
//VB TO JAVA CONVERTER NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. VB to Java Converter has created a temporary variable in order to use the initial value of ActBin + NumDHabits for every iteration:
1620  
                var tempVar = ActBin + NumDHabits;
1621  
                for ping (DHabitBinTyp = ActBin + 1 + SenseOrDeviceNum; DHabitBinTyp <= tempVar; DHabitBinTyp++) {
1622  
                    BinonTypeName[DHabitBinTyp][BinName] = "D-Habit";
1623  
                    BinonTypeName[DHabitBinTyp][BinAbbreviation] = "DH";
1624  
                }
1625  
                NumBinonTypes = ActBin + NumDHabits;
1626  
            } else {
1627  
                Stop(); //no other value allowed
1628  
            }
1629  
1630  
        }
1631  
1632  
        BinonTypeName[BinTypNum][BinName] = BinNam;
1633  
        BinonTypeName[BinTypNum][BinAbbreviation] = BinAbb;
1634  
        BinonTypes[BinTypNum][SensOrDevNum] = SenseOrDeviceNum; //points back to the device number
1635  
        BinonTypes[BinTypNum][SymbolicOrMagnitude] = Senses[SenseOrDeviceNum][SymbolicOrMagnitude];
1636  
1637  
        BinonTypReturned.set(BinTypNum);
1638  
1639  
    } //End of SetupBinonTypes()
1640  
1641  
    public final void SetupDevice(int DeviceNum, String DName, String BinonName, String BinonAbbrev, int MagnOrSymb, int LowerLimit, int UpperLimit, String Responses, int LinOrCirc, int IntOrLog) {
1642  
1643  
        //This routine returns the Device number (DeviceNum) for the given Device type if none is provided
1644  
        //DName$:          is the name of the device type
1645  
        //IntensityRange:  is the range or number of response values for the device if it takes magnitude values
1646  
        //Responses$:      is a string of characters representing the possible movements
1647  
        //BinonType:       The response binon type
1648  
1649  
        int UseDevice;
1650  
        var BinTypNum = new Var<>(0);
1651  
        String DisplayResponses;
1652  
1653  
        //--------------------  Devices ------------------------------------------------
1654  
//  Public NumDevices             'Number of output devices
1655  
//  Public MaxDevices             'Maximum number of devices = max 8 devices
1656  
//  Public Device$(1 To 8)        'Names of device, up to 8 devices
1657  
//
1658  
//  Public Devices[1 To 8][1 To 5] 'Properties of the output / response devices
1659  
//                                '1st index = Device number
1660  
//                                '2nd index = Device property
1661  
//  Public DeviceResponses$(1 To 4)   'A string of the possible symbolic responses for the devices
1662  
1663  
        //---- Devices() - 2nd index values - Device Properties - DEFINED ABOVE
1664  
//  Public PropertyBinonType      '1, Response property binon type e.g. 1 = LetrBin
1665  
//  Public SymbolicOrMagnitude    '2, Symbolic or Magnitude indicator
1666  
//  Public LowerRangeLimit        '3, Lower limit of range of response values, zero is minimum (97 = "a")
1667  
//  Public UpperRangeLimit        '4, Upper limit of range of response values, 255 is maximum (122 = "z")
1668  
//  Public LinearOrCircular       '5, Linear list or Ring/Circular of values for Magnitude sense, Distance is Linear, Motor rotations are Circular (0 to 360)
1669  
//  Public IntegersOrLogs         '6, Integer Values or Log Values, Temperatures are Integers while Decibels are Logs
1670  
1671  
//  Public Symbolic               '1, Indicates that the values for this device are symbolic, Range a -> z
1672  
//  Public Magnitude              '2, Indicates that the values for this device are numeric, integers, range 0 -> limit
1673  
1674  
//  Public Linear                 '1, Indicates that the values go from the lower limit to upper limit
1675  
//  Public Circular               '2, Indicates that the values rap around from the upper limit to 0
1676  
1677  
//  Public IntegerValues          '1, Indicates that the values are integer readings
1678  
//  Public LogValues              '2, Indicates that the values are already logs - orders of magnitude
1679  
1680  
        if (NumDevices == MaxDevices) //Can't assign another new device number
1681  
        {
1682  
            Stop("NumDevices == MaxDevices (" + NumDevices + ")");
1683  
        }
1684  
        //There are only so many device types in DeviceValues array
1685  
        //currently set to 8 in Adaptron.Initialize_Adaptron()
1686  
1687  
        if (DeviceNum == 0) //don't have a device number yet so assign and return it
1688  
        {
1689  
            NumDevices = NumDevices + 1; //The new device number for this device
1690  
            DeviceNum = NumDevices; //The returned device number
1691  
        } else if (DeviceNum > MaxDevices) //else it is more than allowed
1692  
        {
1693  
            Stop("DeviceNum > MaxDevices (" + DeviceNum + "/" + MaxDevices + ")");
1694  
        } else if (DeviceNum > NumDevices + 1) //else is it higher than the next one available
1695  
        {
1696  
            Stop("DeviceNum > NumDevices+1 (" + DeviceNum + "/" + (NumDevices+1) + ")");
1697  
        } else if (DeviceNum <= NumDevices) //else use the one passed in - overriding an existing device
1698  
        {
1699  
        } else if (DeviceNum == NumDevices + 1) //next device number provided
1700  
        {
1701  
            NumDevices = DeviceNum; //The new device type number for this device = DeviceNum
1702  
        }
1703  
1704  
        UseDevice = DeviceNum;
1705  
1706  
        if (IntensityRange > 256) //only 256 values allowed for response intensity
1707  
        {
1708  
            Stop("IntensityRange > 256 (" + IntensityRange + ")");
1709  
        }
1710  
1711  
        Device[UseDevice] = DName;
1712  
1713  
        Devices[UseDevice][SymbolicOrMagnitude] = MagnOrSymb;
1714  
        Devices[UseDevice][LowerRangeLimit] = LowerLimit; //lower limit number / range of response values
1715  
        Devices[UseDevice][UpperRangeLimit] = UpperLimit; //upper limit number / range of response values
1716  
        DeviceResponses[UseDevice] = Responses; //the symbolic responses
1717  
1718  
        if (Devices[UseDevice][SymbolicOrMagnitude] == Magnitude) //Magnitude READINGS
1719  
        {
1720  
            Devices[UseDevice][LinearOrCircular] = LinOrCirc; //can be circular or linear
1721  
            DeviceResponses[UseDevice] = ""; //no symbolic responses are possible
1722  
        } else //Symbolic readings can not be circular
1723  
        {
1724  
            Devices[UseDevice][LinearOrCircular] = Linear; //non circular
1725  
        }
1726  
        Devices[UseDevice][IntegersOrLogs] = IntOrLog;
1727  
1728  
        //SetupBinonTypes(SenseOrDeviceNum, BinNam$, BinAbb$, IsASense, BinonTypReturned)
1729  
        SetupBinonTypes(UseDevice, BinonName, BinonAbbrev, IsDevice, BinTypNum);
1730  
        Devices[UseDevice][PropertyBinonType] = BinTypNum.get(); //The binon number usually = highest number so far
1731  
1732  
        //Fill in device info. on world page
1733  
        new StringBuilder deviceInfo;
1734  
        for ping (int Dvc = 1; Dvc <= NumDevices; Dvc++) {
1735  
            if (Devices[Dvc][SymbolicOrMagnitude] == Magnitude) {
1736  
                DisplayResponses = Devices[Dvc][LowerRangeLimit] + " to" + Devices[Dvc][UpperRangeLimit];
1737  
            } else //symbolic values
1738  
            {
1739  
                DisplayResponses = DeviceResponses[Dvc];
1740  
                DisplayResponses = mapCharacters(DisplayResponses, c -> eq(str(c), NoMoveOrTurn) ? ASpace : c);
1741  
            }
1742  
            deviceInfo.append(takeFirst(8, Device[Dvc] + ":        ")
1743  
              + DisplayResponses + "  " + SymbOrMagn(IsDevice, Dvc) + "\r\n");
1744  
        }
1745  
1746  
        World.showDeviceValues(str(deviceInfo));
1747  
1748  
    } //End of SetupDevice()
1749  
1750  
    public void Reset_Adaptron() //Called from DesignBody.FinalSetup(), & ResetWld_Click()
1751  
    {
1752  
1753  
        //Resets all changing info. to starting places.
1754  
        //Must be called before setting up any senses/sensors.
1755  
1756  
        int S;
1757  
        int D;
1758  
        int I;
1759  
1760  
        ResetRnd(-1); //necessary to reset the sequence
1761  
        OverLimit = false;
1762  
1763  
        CreateAll = false; //True if create all combinations, False if use only familiar parts
1764  
//  CreateAll = True           '
1765  
1766  
        BodyPointing = North; //always starts with body pointing North
1767  
        World.PointUnder();
1768  
        
1769  
        NumSenses = 0; //start with no senses
1770  
        NumDevices = 0; //start with no devices
1771  
1772  
        Motion = NoMove; //World.MoveDown() etc set this to indicate the direction the robot moved
1773  
        //and it is used as the stimulus input of the Motion sense
1774  
        for ping (I = 1; I <= MaxSenses; I++) //+1 so it covers the Percept sense too
1775  
        {
1776  
            Sense[I] = ""; //Names of sense
1777  
        }
1778  
1779  
        StoreAt = 0; //Initially the long term memory history is empty
1780  
        //Initialize STMs
1781  
        LIN = 0; //clear out memory display stuff - index into INPUTS$() and OUTPUTS$()
1782  
        COUNTIN = 0; //Count of inputs
1783  
1784  
        ClearMemory(); //This clears BinonDisplay.ChngResults.Text and LTM
1785  
1786  
        for ping (I = 0; I <= 500; I++) {
1787  
            if (I > 0) {
1788  
            }
1789  
            for ping (S = 1; S <= MaxSenses; S++) {
1790  
                INPUTS[I][S] = "";
1791  
            }
1792  
            for ping (D = 1; D <= MaxDevices; D++) {
1793  
                OUTPUTS[I][D] = "";
1794  
            }
1795  
        }
1796  
        
1797  
        //Adapt.IO.Text = "";
1798  
1799  
        //Adapt.LTMem.Text = "";
1800  
1801  
        //UNUSED TriggerObj = NullObject;
1802  
        DoingReaction = false; //set true if last response was reflexive.
1803  
        DoingRepeat = false;
1804  
        //ActiveActon = NullAct; //no subconscious acton active
1805  
        //UNUSED ExploreObj = NullObject; //will be set if reflexive response done.
1806  
        //DoingAct1 = NullAct; //will be set if reflexive response done.
1807  
1808  
        //UNUSED NumTrigLinks = 0; //Number of LTM episodic action links
1809  
        //UNUSED NumActons = 0;
1810  
        NumActs = 0; //The number of Acts entries in use
1811  
        RotateActs = false; //Rotate through all reflexive acts
1812  
        LastAct = 1; //initialized so next one will be #2 - not the Relax response = #1
1813  
        if (RotateActs) //Rotation through acts starts with Relax
1814  
        {
1815  
            LastAct = 0;
1816  
        }
1817  
1818  
        change(); // persist changes
1819  
1820  
    } //End of Reset-Adaptron()
1821  
1822  
    private void ResetRnd(int i) {
1823  
        // TODO
1824  
    }
1825  
1826  
    public void ClearMemory() {
1827  
1828  
        //Called by Reset_Adaptron()
1829  
1830  
        int Lk;
1831  
        int T;
1832  
        int I;
1833  
1834  
        for ping (I = 1; I <= MaxBinons; I++) {
1835  
            Binons[I][OLv] = 0;
1836  
            Binons[I][O1] = NullObject;
1837  
            Binons[I][O2] = NullObject;
1838  
            ZeroTheCounts(I);
1839  
        }
1840  
1841  
        NumBinons = 0; //there are no binons
1842  
1843  
        for ping (T = 1; T <= MaxBinonTypes; T++) //For all property binons and their Percept combinations and Actions
1844  
        {
1845  
            BinonTypeName[T][BinName] = ""; //The names and abbreviations for the various binon types
1846  
            BinonTypeName[T][BinAbbreviation] = "";
1847  
            BinonTypes[T][SymbolicOrMagnitude] = Symbolic;
1848  
            BinonTypes[T][SensOrDevNum] = 0; // Pointer points back to sense or device
1849  
1850  
        }
1851  
1852  
        ClearSenses(); //clear SensorValues() and SensedBinons()
1853  
        ClearPerceptions(); //clear out all the perceptions in STM()
1854  
        TopLevel = 0;
1855  
1856  
        for ping (T = 1; T <= MaxPercepts; T++) //Clear perceived Parallel Percept and property binon entries
1857  
        {
1858  
            Percepts[T][BinId][Current] = NullObject;
1859  
            Percepts[T][BinId][Fired] = NullObject;
1860  
            Percepts[T][XQCnt][Current] = 0;
1861  
            Percepts[T][XQCnt][Fired] = 0;
1862  
        }
1863  
1864  
        for ping (Lk = 1; Lk <= MaxTargets; Lk++) //Clear out all targets
1865  
        {
1866  
            Targets[Lk][NLnk] = NullTarget;
1867  
            Targets[Lk][TargetBinon] = NullObject;
1868  
        }
1869  
1870  
        NumTargets = 0;
1871  
1872  
        ClearExpectations();
1873  
1874  
        World.setBinonDisplayObjList("");
1875  
        World.setBinonDisplayChngResults("");
1876  
1877  
        JND = 20; //Percent
1878  
        AssignBases(); // SizeBase# = 1.2 for a 20% just noticeable difference
1879  
1880  
        change(); // persist changes
1881  
1882  
    } //End of ClearMemory()
1883  
1884  
    public void ZeroTheCounts(int Habit) //Called by ClearMemory()
1885  
    {
1886  
1887  
        Binons[Habit][TQ] = 0;
1888  
        Binons[Habit][GQ] = 0;
1889  
1890  
    } //End ZeroTheCounts()
1891  
1892  
    public void ClearSenses() //Called by ClearMemory()
1893  
    {
1894  
1895  
        for ping (int Sens = 1; Sens <= MaxSenses; Sens++) {
1896  
            SensorValues[Sens][XQCnt][Fired] = 0;
1897  
            SensorValues[Sens][Valu][Fired] = 0;
1898  
            SensorValues[Sens][XQCnt][Current] = 0;
1899  
            SensorValues[Sens][Valu][Current] = 0;
1900  
            SensedBinons[Sens] = NullObject;
1901  
        }
1902  
1903  
        NumProperties = 0;
1904  
1905  
    } //End of ClearSenses()
1906  
1907  
    public void ClearPerceptions() //Used by ClearMemory() and processing STM perceptions in PerceptionAction()
1908  
    {
1909  
1910  
        //Clear out all the Current and previous perceptions that are sources for Habits in the STM()
1911  
1912  
        int Percpt;
1913  
        int Lvl;
1914  
1915  
        World.appendBinonDisplayChngResults(" ** Clearing Perceptions " + "\r\n");
1916  
        for ping (Lvl = 1; Lvl <= MaxLevels; Lvl++) {
1917  
            for ping (Percpt = Fired; Percpt <= MaxLevels; Percpt++) {
1918  
                EmptySTM(Lvl, Percpt);
1919  
            }
1920  
        }
1921  
1922  
    } //End of ClearPerceptions()
1923  
1924  
    public void AssignBases() //Called by ClearMemory()
1925  
    {
1926  
1927  
        double Percnt;
1928  
1929  
        Percnt = /*Microsoft.VisualBasic.Conversion.Val*/(JND) / 100.0;
1930  
1931  
        SizeBase = 1 + Percnt; //1.2 for a 20% just noticeable difference
1932  
        IntensityBase = 1 + Percnt; //If it is 2.0 then that is a 100% just noticeable difference
1933  
1934  
    } //End of AssignBases()
1935  
1936  
    public final int Buckit(double Valuu, double Base) {
1937  
1938  
//    Base# = 1.2           'Ln(1.3) = 0.26,  Ln(1.2) = 0.18
1939  
        return (int) Math.round(100 * Math.log(Valuu) / Math.log(Base)); // XXX
1940  
1941  
    } //End of Buckit()
1942  
1943  
    public final void IdBinons(int OLvl, int Prt, int Obj1, int TQNum, int Obj2, int GQNum, int IDLRatio, int SeqOrPar, int ExpectIt, Var<Integer> ObjId, Var<Boolean> NewOne) {
1944  
1945  
        //OLvl = Level of the binon, 1 stimulus property binons and response binons, 2+ Percepts or Action patterns
1946  
        //PrT  = Property Type value
1947  
        //Obj1 = The left source binon
1948  
        //Obj2 = The right source binon
1949  
        //IDLRatio = The IDL ratio value
1950  
        //SeqOrPar = whether it is an Action sequence or a parallel Percept
1951  
        //ObjId  = The object / binon identifier returned, = NullObject if over the limit
1952  
        //NewOne = Returned True if object newly created, False if it already existed.
1953  
1954  
        //If a new binon is created it is Active but Idle - waiting to repeat
1955  
1956  
        //---- Binon Properties - 2nd index values
1957  
//  Public BType                  '1, The type of binon
1958  
//  Public O1                     '2, Left source binon pointer
1959  
//  Public TQ                     '3, the count of times the trigger has fired
1960  
//  Public O2                     '4, Right source binon pointer
1961  
//  Public GQ                     '5, the number of times the goal has fired
1962  
//  Public IDL                    '6, The ratio value of the binon
1963  
//  Public IntVl                  '7, Interest Value (NOVEL, INTERESTING, or Familiar)
1964  
//  Public OLv                    '8, Level of object = number of lowest level parts involved
1965  
//  Public SP                     '9, Sequential or Parallel property
1966  
//  Public TriggerList            '10, points to the linked list of target binons [Targets()]
1967  
//                                '   for which this binon is the left source binon (not the right source binon).
1968  
//  Public TriggerCount           '11, Count of its sequential right targets, >1 means it has more than one goal
1969  
//                                '    Used for prediction reliability, may be set >1 if needs to be combined with previous
1970  
//  Public GoalList               '12, points to the linked list of target binons [Targets()]
1971  
//                                '   for which this binon is the right source binon (not the left source binon)
1972  
//  Public GoalCount              '13, Count of its sequential left targets, >1 means can not predict its trigger
1973  
//                                '    Used for reliability of determining the cause, may be set >1 if needs to be combined with next
1974  
//  Public AE                     '14, Action (Percept - Act) or Attention (Act - Percept) level 1 Sequential binon
1975  
1976  
        //Given two objects/parts Obj1 and Obj2
1977  
        //see if we have an object ObjId with the same values and the same Obj1 and Obj2.
1978  
        //Return the found or newly created binon
1979  
1980  
        if (Obj1 == 0) fail("obj1 = 0");
1981  
        if (Obj2 == 0) fail("obj2 = 0");
1982  
1983  
        if (NumBinons >= MaxBinons) //if can not find the exact match
1984  
        {
1985  
            ObjId.set(NullObject);
1986  
            World.appendBinonDisplayChngResults("\r\n" + "Binon limit of " + MaxBinons + " reached!");
1987  
            Stop();
1988  
            return;
1989  
        }
1990  
1991  
        ObjId.set(NullObject); //Return no binon - none created by default
1992  
1993  
        NewOne.set(true); //Assume we will not find it already exists and will create a new one
1994  
        //First determine if we have any binons of the given type with the given ratio
1995  
1996  
        if (NumBinons > 0) //if none then do not check if ExistBinon
1997  
        {
1998  
            //If the binons already exists then the ExistBinon routine sets the ObjId
1999  
            //ExistBinon(OLvl, PrTyp, Bin1&, Bin2&, V1, ItsAE, ObjId&)
2000  
            if (ExistBinon(OLvl, Prt, Obj1, Obj2, IDLRatio, ExpectIt, ObjId)) {
2001  
                //This applies to Percept and property binons only when attended to
2002  
                //DecreaseBinonInterest(BTyp, Bino&)
2003  
                DecreaseBinonInterest(ObjId.get());
2004  
                NewOne.set(false);
2005  
            }
2006  
        }
2007  
2008  
        if (ObjId.get() == NullObject) //If it does not already exist then create it
2009  
        {
2010  
2011  
            ObjId.set(NumBinons + 1); //it was not found - so add it as a new one
2012  
2013  
            Binons[ObjId.get()][BType] = Prt;
2014  
            Binons[ObjId.get()][O1] = Obj1; //The left source binon
2015  
            Binons[ObjId.get()][TQ] = TQNum;
2016  
            Binons[ObjId.get()][O2] = Obj2; //The right source binon
2017  
            Binons[ObjId.get()][GQ] = GQNum;
2018  
2019  
            Binons[ObjId.get()][IDL] = IDLRatio; //stored object ratio values
2020  
            //Do level 1 binons become familiar immediately? No they should also go from Novel to Interesting to Familiar
2021  
            //Percepts start out Novel, then become Interesting and then Familiar
2022  
            //Perceptual sequences start out Novel and each time attention is paid to them they become Interesting and Familiar
2023  
            if (SeqOrPar == Parallel) //If it is a Property or Percept binon then
2024  
            {
2025  
                if (Prt <= NumProperties) //if it is a Property binon then
2026  
                {
2027  
                    SetInterest(ObjId.get(), NOVEL); //Property binons start out Novel
2028  
                    SetInterest(ObjId.get(), FAMILIAR); //Familiar for testing purposes
2029  
                } else //else it is a Percept binon
2030  
                {
2031  
                    SetInterest(ObjId.get(), NOVEL); //Percept binons start out Novel
2032  
                    SetInterest(ObjId.get(), FAMILIAR); //Familiar for testing purposes
2033  
                }
2034  
            } else {
2035  
                SetInterest(ObjId.get(), NOVEL); //Sequential binons start out Novel
2036  
//tmp        Call SetInterest(ObjId, FAMILIAR)             'Familiar - for testing
2037  
            }
2038  
2039  
            Binons[ObjId.get()][OLv] = OLvl;
2040  
            Binons[ObjId.get()][SP] = SeqOrPar; //Sequential or ParallelPrt,
2041  
            if (SeqOrPar == Parallel && ExpectIt != 0) //AE value should be 0
2042  
            {
2043  
                Stop();
2044  
            }
2045  
            Binons[ObjId.get()][AE] = ExpectIt; //only used if SP=Sequential and OLvl=1, Action=1, Attention=2
2046  
            Binons[ObjId.get()][TriggerList] = NullTarget; //=0, an NLnk pointer at end of linked list
2047  
            Binons[ObjId.get()][TriggerCount] = 0; //Count of its sequential right targets, >1 means can not predict its goal
2048  
            Binons[ObjId.get()][GoalList] = NullTarget; //=0, an NLnk pointer at end of linked list
2049  
            Binons[ObjId.get()][GoalCount] = 0; //Count of its sequential left targets, >1 means can not predict its trigger
2050  
2051  
2052  
//                '---  Linked List of Target Binons - for Percepts and Actions -------------
2053  
//  Public NumTargets&            'The number of Target binon entries created so far
2054  
//  Public MaxTargets&            '10000 = the max number of Target binon entries possible
2055  
//
2056  
//  Public Targets&(1 To 10000, 1 To 2)   'pointed to by Binons(Typ, ID, TriggerList) or by Binons(Typ, ID, GoalList)
2057  
//                    '---- Targets' 2nd index property values
2058  
//  Public NLnk                   '1 = The pointer to the next Targets() entry in this linked list,
2059  
//                                '    may be a NullTarget at end of linked list
2060  
//  Public TargetBinon            '2 = a left or right Target binon
2061  
//
2062  
//  Public NullTarget             '=0, an NLnk pointer at end of linked list
2063  
2064  
            //The target binon ObjId is triggered by source binon Obj1 so add it to the right target list for Obj1
2065  
            if (Obj1 != NullObject) //cannot be property binon
2066  
            {
2067  
                NumTargets = NumTargets + 1; //create a new target
2068  
                if (NumTargets > MaxTargets) //have we exeeded the maximum
2069  
                {
2070  
                    Stop();
2071  
                }
2072  
                Targets[NumTargets][TargetBinon] = ObjId.get(); //The right target is the newly created binon
2073  
                Targets[NumTargets][NLnk] = Binons[Obj1][TriggerList]; //It should point to the 1st one on existing list
2074  
                Binons[Obj1][TriggerList] = NumTargets; //ObjId becomes the 1st one on the right target list of Obj1
2075  
                if (SeqOrPar == Sequential) {
2076  
                    Binons[Obj1][TriggerCount] = Binons[Obj1][TriggerCount] + 1; //Count of right targets for Obj1
2077  
                }
2078  
            }
2079  
2080  
            //The source binon Obj2 is the goal of this target binon ObjId so add it to the left target list of Obj2
2081  
            if (Obj2 != NullObject) //cannot be property binon
2082  
            {
2083  
                NumTargets = NumTargets + 1; //create a new target
2084  
                if (NumTargets > MaxTargets) //have we exeeded the maximum
2085  
                {
2086  
                    Stop();
2087  
                }
2088  
                Targets[NumTargets][TargetBinon] = ObjId.get(); //The left target is the newly created binon
2089  
                Targets[NumTargets][NLnk] = Binons[Obj2][GoalList]; //It should point to the 1st one on existing list
2090  
                Binons[Obj2][GoalList] = NumTargets; //ObjId becomes the 1st one on the left target list of Obj2
2091  
                if (SeqOrPar == Sequential) {
2092  
                    Binons[Obj2][GoalCount] = Binons[Obj2][GoalCount] + 1; //Count of left targets for Obj2
2093  
                }
2094  
            }
2095  
2096  
            NumBinons = ObjId.get();
2097  
2098  
//tmp      BinonDisplay.ChngResults.Text = BinonDisplay.ChngResults.Text & " - Created New Binon = " & _
2099  
            //DisplayStimulu[Prt][ObjId] + "\r\n";
2100  
        } //End if not ExistBinon
2101  
2102  
    } //End of IdBinons()
2103  
2104  
    public final void DecreaseBinonInterest(int Bino) {
2105  
2106  
        //Updates the interest in a stimulus, Novel -> Interesting -> Familiar
2107  
        //called when the stimulus is added to the perception list
2108  
2109  
        //unused int Intrst;
2110  
2111  
        switch (InterestIn(Bino)) {
2112  
2113  
            case NOVEL:
2114  
                if (InterestLevels == 3) {
2115  
                    SetInterest(Bino, INTERESTING); //Novel -> Interesting
2116  
                } else //Interestlevels=2
2117  
                {
2118  
                    SetInterest(Bino, FAMILIAR); //Novel -> Familiar
2119  
                }
2120  
2121  
                break;
2122  
            case INTERESTING:
2123  
                SetInterest(Bino, FAMILIAR); //Interesting -> Familiar
2124  
2125  
                break;
2126  
        }
2127  
2128  
    } //End of DecreaseBinonInterest()
2129  
2130  
    public final void SetInterest(int Objct, int IntLvl) {
2131  
        //Sets the interest level of the given object.
2132  
2133  
        Binons[Objct][IntVl] = IntLvl;
2134  
2135  
    } //End of SetInterest()
2136  
2137  
    public final int InterestIn(int Objct) {
2138  
2139  
        return Binons[Objct][IntVl];
2140  
2141  
    } //End of Function InterestIn()
2142  
2143  
    public final boolean ExistBinon(int OLvl, int PrTyp, int Bin1, int Bin2, int V1, int ItsAE, Var<Integer> ObjId) {
2144  
        boolean tempExistBinon;
2145  
2146  
        //Given two objects numbered Bin1 and Bin2 etc. see if we have an object in Binons()
2147  
        //that matches this combination, if so return its number in ObjId
2148  
        //ObjID = 0 if not found and ExistBinon is set to False
2149  
2150  
        //Ratios of Values are used for recognition of Time (duration) patterns
2151  
        //Pairs of object / binon parts (Obj1 and Obj2) are used for recognition of:
2152  
        //Sense patterns, sensor patterns and symbol patterns etc.
2153  
2154  
        int OO;
2155  
        int StartAt; //range of binons to search
2156  
        int EndAt;
2157  
2158  
        tempExistBinon = false; //assume it does not exist
2159  
        ObjId.set(NullObject); //return NullObject if not found
2160  
2161  
        StartAt = 1;
2162  
        EndAt = NumBinons;
2163  
2164  
        for ping (OO = StartAt; OO <= EndAt; OO++) //For all the known objects of this type
2165  
        {
2166  
            //Object level is an identifying property of a binon
2167  
            if (Binons[OO][OLv] == OLvl) //If it is at the same level then
2168  
            {
2169  
                if (Binons[OO][BType] == PrTyp) //if it is the same binon type then
2170  
                {
2171  
                    //O1 = Object Part 1 pointer and O2 = Object Part 2 pointer
2172  
                    //Given Id of the object - search for same pair of parts and AE
2173  
                    if (Binons[OO][O1] == Bin1 && Binons[OO][O2] == Bin2 && Binons[OO][AE] == ItsAE) {
2174  
                        if (V1 == Binons[OO][IDL]) //If it has the same quantity IDL Ratio?
2175  
                        {
2176  
                            ObjId.set(OO);
2177  
                            tempExistBinon = true;
2178  
                            OO = NumBinons; //terminate FindIt loop
2179  
                        }
2180  
                    }
2181  
                }
2182  
            }
2183  
        }
2184  
2185  
        return tempExistBinon;
2186  
    } //End of ExistBinon()
2187  
2188  
    public final void PerceptionAction(int[][][] SensorValues, Object[] DeviceValues) {
2189  
2190  
        //Called by Adapt.Inpu_KeyPress() for each stimulus/response cycle.
2191  
        //SensorValues() contains the stimuli from the senses/sensors
2192  
        //DeviceValues() are output responses to the devices to change the body/environment
2193  
2194  
        int ObjtLvl;
2195  
        int NovelLvl;
2196  
        String HabitIt = null;
2197  
        int Pass;
2198  
        boolean CheckIt;
2199  
        int AEorEA = 0; //Action-Expectation (Response-Stimulus) or Expectation-Action (Stimulus-Response)
2200  
        int SourceBinon;
2201  
        //unused int SourceXQCnt;
2202  
        //unused int SourceTQCnt;
2203  
2204  
2205  
// 0. INITIAL STATE:  based on the variables: PracticingBinon and ConcentrationLevel, will be either;
2206  
//       a) an Action being executed / practiced that identifies the expected Percept stimulus and
2207  
//          a concentration level of novel or interesting. Plus zero or more other Actions that also match
2208  
//          the attended-to past experience and have expectations of what will happen next.
2209  
//
2210  
//   Or  b) no Action being performed and concentration level of familiar but may have
2211  
//          a previous attended-to stimulus that repeated a certain quantity of times and is expecting it to repeat again.
2212  
//
2213  
//   Or  c) no attended-to stimulus or practicing Perceptual sequence because it is the first time through
2214  
2215  
//   In parallel there may be zero or more subconsciously executing Actions that will stop if they don't
2216  
//   get their next expected stimulus or their source binons become idle and will continue otherwise.
2217  
2218  
        StoreAt = StoreAt + 1;
2219  
        if (StoreAt == MaxMemory) //stop further Go / Continue stepping
2220  
        {
2221  
            //XXX World.Go.Enabled = false;
2222  
        }
2223  
        World.setBinonDisplayChngResults("Step = " + StoreAt + "\r\n"); //display the cycle count
2224  
2225  
// 1. PERCEIVE PERCEPTS:
2226  
//   Get stimuli from all senses / sensors and recognize / create all Percept binon combinations of
2227  
//   familiar stimuli. Both source binons must be familiar before they can be combined.
2228  
//   This happens when a change occurs on any sense / sensor. This includes all areas of sensors that
2229  
//   attention is or is not focused on. This includes creation of stimuli that are expected and unexpected.
2230  
//   Novel stimuli get created and are remembered in the novel state. Is it possible that novel ones are only
2231  
//   kept if they have attention paid to them? When we sleep the novel ones are probably pruned.
2232  
//   Otherwise you end up with too many of them. Maybe it is only Actions that have to be attended to so
2233  
//   that their familiarity / interest is reduced. The interest of the Percept is reduced on occurrence repetition.
2234  
//   For a three stage novelty reduction, if and when Percepts occur again they are changed to Interesting.
2235  
//   The third time they occur they become familiar and can be combined with other familiar ones.
2236  
//   An Action has to be practiced before its interest level is reduced.
2237  
2238  
        //If there is a clock then
2239  
        // If RecogThem is called for every time it ticks (on a regular interval even if nothing changed) then
2240  
        //   The sensor repeat count (Level1, XQCnt, Fired) should be set to 1.
2241  
        //     (this is the case for hand writen digits or anywhere the environment is polled)
2242  
        //   If the reading is Magnitude then level 1 needs to count the repeats of the same value within the JND
2243  
        //     level 2 wil contain ratio binons (symbolic)
2244  
        // Else if RecogThem is called every time a change occurs on at least one sense then
2245  
        //   Put the value of the duration into the sensors repeat count (XQCnt). (as for Morse code)
2246  
        //Else if there is no clock then
2247  
        // RecogThem is event driven and called only when a change occurs on at least one sense then
2248  
        // set the XQCnt to 1 and for any repeaters do as above for a clock.
2249  
2250  
//    SensorValues[NameBin][Valu][Fired] = Asc(Letr$)        'The letter
2251  
//    SensorValues[NameBin][XQCnt][Fired] = Durat            'the number of times it has repeated
2252  
//    SensorValues[ContBin][Valu][Fired] = DitDah            'The contrast intensity
2253  
//    SensorValues[ContBin][XQCnt][Fired] = Durat            'the number of times it has repeated
2254  
2255  
        //Pay attention to the expected sensors if concentrating - a Percept,
2256  
        //create the Percepts that attract attention and place the most interesting in STM(1,Fired)
2257  
        //Set GotAttendedTo = true if got the expected/attendedto stimuli/Percept
2258  
2259  
        ProcessStimuli(SensorValues); //Process the SensorValues()
2260  
2261  
        //The Perception STM list has many binons at each level. The Fired one is the most recent fired binon
2262  
        //before any processing has been done at that level. It is put in the Fired entry when
2263  
        //the level below is processed.
2264  
        //After the processing has been done the previous one contains what was in the Current and
2265  
        //the Current contains what was in the Fired provided there was no repeat of an Action.
2266  
2267  
// 2. PERFORM ACTION RECOGNITION:
2268  
2269  
// High level algorithm - 30th December 2016
2270  
2271  
//   Expectation = Expectation/Attention binon = A-R
2272  
//   Action = Action Habit = R-A
2273  
//   Perceptual sequence = Stimulus Habit (Percept at level 1) and = A-E at higher levels = R-A-R
2274  
//   Action sequence = Response Habit (Device responses) and E-A higher up = A-R-A.
2275  
2276  
//   Repeat the the algorithm below for these two situations:
2277  
//     Pass 1/ Odd level Current Action sequence combined with Fired Perceptual sequence to produce next level up Fired Expectation,
2278  
//         find out if right target Action of the Perceptual sequence is worth doing and then
2279  
//         the even level Current Action is combined with just Fired Expectation to produce next level up Perceptual sequence,
2280  
//         Find out if right target Action sequence of the Expectation is worth doing.
2281  
//     Pass 2/ Odd level Current Perceptual sequence combined with Fired Action sequence to produce next level up Fired Action,
2282  
//         find out if right target Expectation of the Action sequence is worth doing and then
2283  
//         the even level Current Expectation is combined with just Fired Action to produce next level up Action sequence,
2284  
//         find out if right target Perceptual sequence of the Action is worth doing.
2285  
2286  
//   The algorithm: Repeat this for each level X of the STM() binon tree as long as the fired is not a null object
2287  
//     If on an even level and doing pass 2/ then have a just Fired Action to process so
2288  
//       check to see if the fired Action pattern matches the previous Action (X positions earlier) at this level
2289  
//       If it repeats then increment the past entry for the repeat and move it up to current
2290  
//     Else if it does not repeat or on an odd level or doing pass 1/ then
2291  
//       combine the Current to the Fired at this level (if there is a current) and
2292  
//       place it in the next level up Fired position
2293  
//     end if
2294  
//     If finished pass 1/ STM processing then use the highest level Action or Action sequence found worth doing and
2295  
//       do its lowest level response. Put this response Action sequence in STM(level 1 Fired) and start pass 2
2296  
//     If finished pass 2/ STM processing then use the highest level Expectation or Perceptual sequence found worth doing and
2297  
//       attend to its lowest level expected Percept in ProcessStimuli().
2298  
//       The stimulus Percept obtained will be the Fired Perceptual sequence to start this process again.
2299  
2300  
        for ping (Pass = 1; Pass <= 2; Pass++) //For 1/ R-S & A-E combinations then 2/ S-R & E-A combinations
2301  
        {
2302  
            ObjtLvl = 1; //Start by processing level 1 perceptions - always assigned
2303  
            NovelLvl = 0; //set to the level at which the fired STM is novel
2304  
            MoveAmount = 0; //Move right amount to eliminate previous pattern
2305  
2306  
            SourceBinon = STM[ObjtLvl][BinId][Fired]; //It may be a right source binon for some target binons
2307  
2308  
            while ping (SourceBinon != NullObject) //While there is a Fired familiar binon in STM
2309  
            {
2310  
                World.appendBinonDisplayChngResults(StringHelper.trim(String.valueOf(ObjtLvl), ' ') + "-0/ Processing percepts at level" + vbToStr(ObjtLvl) + "\r\n");
2311  
2312  
                //First move the STM entries right by the MoveAmount due to a repeater at a lower level
2313  
                if (MoveAmount > 0) {
2314  
                    int Prcpt = 0; // declare undeclared variable
2315  
                    MoveRight(ObjtLvl, Current + MoveAmount, Current, 2 * Prcpt); //eliminates binon created with previous goal from STM
2316  
                }
2317  
2318  
                if (InterestIn(SourceBinon) > FAMILIAR) //If the STM fired binon is novel then
2319  
                {
2320  
                    NovelLvl = ObjtLvl; //It can not be combined with a current
2321  
                } else //else check for a repeat and combine with current in STM
2322  
                {
2323  
                    CheckIt = false; //do not check for a repeat of an Action
2324  
                    if (Pass == 1) //If the Stimulus / Expectation processing pass
2325  
                    {
2326  
                        AEorEA = Attention;
2327  
                        HabitIt = "Percept";
2328  
                        if (ObjtLvl % 2 == 0) //Odd level = 1, Even level = 0
2329  
                        {
2330  
                            HabitIt = "Action";
2331  
                            CheckIt = true; //Check to see if it repeats - both A and E - even levels
2332  
                        }
2333  
                    } else if (Pass == 2) //else if the Action / Response processing pass
2334  
                    {
2335  
                        AEorEA = Action; //assume it will be an Action
2336  
                        HabitIt = "Action";
2337  
                        if (ObjtLvl % 2 == 0) //If fired entry is an Action then (Pass=2 and remainder =0)
2338  
                        {
2339  
                            HabitIt = "Expectation";
2340  
                            CheckIt = true; //Check to see if it repeats - both A and E - even levels
2341  
                        }
2342  
                    }
2343  
2344  
                    World.appendBinonDisplayChngResults(StringHelper.trim(String.valueOf(ObjtLvl), ' ')
2345  
                      + "-0a/ Pass" + vbToStr(Pass) + " - " + HabitIt + " Processing" + "\r\n");
2346  
                    ProcessSTMLevel(ObjtLvl, SourceBinon, AEorEA, CheckIt);
2347  
                } //End if STM Fired binon is Novel
2348  
                MoveLeft(ObjtLvl); //Move all STM left, the fired entry into the current location
2349  
                HighestPerceptLvl = ObjtLvl; //Remember the highest not null fired level in STM
2350  
                if (HighestPerceptLvl > TopLevel) //track highest non-empty level
2351  
                {
2352  
                    TopLevel = HighestPerceptLvl;
2353  
                }
2354  
                //Go up the pattern tree combining Fired and Currents if they are patterns and fired is not nullobject
2355  
                ObjtLvl = ObjtLvl + 1; //check out the next level for current and fired
2356  
                if (ObjtLvl <= MaxLevels) {
2357  
                    SourceBinon = STM[ObjtLvl][BinId][Fired]; //It may be a right source binon for some target binons or Null
2358  
                } else {
2359  
                    SourceBinon = NullObject;
2360  
                    Stop();
2361  
                }
2362  
            }
2363  
2364  
            //Move all higher levels left by one minus moveamount
2365  
            MoveAmount = 1 - MoveAmount; //move left one but right based on repeater found
2366  
            for ping (; ObjtLvl <= TopLevel; ObjtLvl++) //for all higher levels that have something in them
2367  
            {
2368  
                if (MoveAmount == 1) {
2369  
                    MoveLeft(ObjtLvl); //processed one more level 1 stimulus
2370  
                } else if (MoveAmount < 0) {
2371  
                    MoveRight(ObjtLvl, Current - MoveAmount, Current, 2 * ObjtLvl);
2372  
                }
2373  
            }
2374  
2375  
            ReportObjects1(); //Fill in the top part of BinonDisplay.ChngResults.Text
2376  
2377  
            SourceBinon = STM[HighestPerceptLvl][BinId][Current]; //It may be a right source binon for some target binons
2378  
2379  
            if (Pass == 1) {
2380  
                //If finished pass 1/ STM processing then based on the recognized Perceptual sequence or Expectation find any
2381  
                //predicted action and use this highest level Action or Action sequence found worth doing and
2382  
                //do its lowest level response in PerformAction().
2383  
                //Or if the predicted action is learnt / familiar then use thinking (deduction) and find one worth doing
2384  
                //Put this response Action sequence in STM(level 1, Fired) and start pass 2
2385  
                DetermineResponse(); //determine what response to produce - do thinking
2386  
2387  
                //Keep a record of STM() binons for display of LTM
2388  
                LTMEMORY[StoreAt][LtmESType] = BinonTypeOf(SourceBinon);
2389  
                LTMEMORY[StoreAt][LtmESActBin] = SourceBinon;
2390  
2391  
                World.appendBinonDisplayChngResults(DisplaySTM());
2392  
2393  
            } else //else Pass = 2
2394  
            {
2395  
                //If finished pass 2/ STM processing then based on the recognized Action or Action sequence find any
2396  
                //predicted perception and use this highest level Expectation or Perceptual sequence found worth doing and
2397  
                //do its lowest level expected Percept and attend to it in ProcessStimuli().
2398  
2399  
                //This effectively means DetermineStimulus() needs to determine what stimulus to attend to
2400  
2401  
                //The stimulus Percept obtained will be the Fired Perceptual sequence to start this process again.
2402  
2403  
                //Keep a record of STM() binons for display of LTM
2404  
                LTMEMORY[StoreAt][LtmARType] = BinonTypeOf(SourceBinon);
2405  
                LTMEMORY[StoreAt][LtmARActBin] = SourceBinon;
2406  
2407  
                //The level 1 perceived stimulus could be a familiar stimulus but unexpected.
2408  
                //   It is unexpected because none of the active Perceptual sequences were expecting it.
2409  
2410  
                ReportPerceptions(); //Reports on Percepts() and STM() & expectation
2411  
                ReportObjects2(); //Report on Binons
2412  
2413  
            } //End if Pass =1 or Pass = 2
2414  
        }
2415  
2416  
    } //End of PerceptionAction()
2417  
2418  
    public final void ProcessStimuli(int[][][] SensorValues) //Called from PerceptionAction()
2419  
    {
2420  
2421  
        //SensorValues() contains the sensor readings for ProcessStimuli() to process.
2422  
        //ProcessStimuli() is not currently provided with the Percept that it expects to get/should attend to.
2423  
        //Instead ProcessStimuli() assumes that the previous stimuli will repeat and just delivers any changes.
2424  
        //ProcessStimuli is asked to attend to the senses / sensors specified in the given Percept (not yet).
2425  
        //After calling ProcessSenses() to put sensory stimuli from all senses into SensedBinons() it
2426  
        //uses the SenseBinons() and puts the perceived ones in the Percepts(). Not yet based on what was being attended to.
2427  
        //If nothing was attended to then all the sensory stimuli are used.
2428  
        //It creates the parallel combinations (Percepts) of the property SensedBinons().
2429  
        //Combinations are formed if the parts are both familiar and both changed or both familiar and not changed.
2430  
        //The most interesting Percept is then the largest / highest level (most complex) one that changed or
2431  
        //if there was no change then just the highest level one.
2432  
        //The most interesting stimulus is then placed in STM(level 1, Fired).
2433  
2434  
        //SenseBinons() consist of:
2435  
        //   TextBin = the symbolic value for the letter - symbolic
2436  
        //   ContBin = Intensity = the value for the sensor measurement - Magnitude
2437  
2438  
        int Sens;
2439  
        int PerceptType;
2440  
        String GotWhat;
2441  
        int TopType;
2442  
        int TopBinon;
2443  
        int TopInterest;
2444  
        int OL;
2445  
        boolean HaveAChange;
2446  
        int RepeatCount;
2447  
        int FirstBinon;
2448  
        int IntInF = 0;
2449  
        int SecondBinon;
2450  
        int TheType;
2451  
2452  
        OL = 1; //Property binons and their combinations are at level 1
2453  
        HaveAChange = false; //Assume no change will take place on any sense
2454  
        //The expectation is the previous stimulus will repeat
2455  
2456  
        ReportPerceptions(); //Report on all Percepts, Actions and expectations
2457  
2458  
        ProcessSenses(OL, SensorValues); //Obtain the SensedBinons() for all property types SensorValues()
2459  
2460  
        // The expectation is a repeat of the previous stimuli (if there are any) Property and Percept binons.
2461  
        // Magnitude stimuli values must change by a JND to be detected
2462  
        // Symbolic stimuli values are always available because they are uniquely identified.
2463  
        // Determine what attracts attention by combining the stimuli that have changed.
2464  
        // If nothing has changed then a repeat of the previous stimuli has occurred.
2465  
2466  
        //For all the senses/property and Percept types
2467  
        // copy the SensedBinons() into the 1st level Fired Percepts (property binons level),
2468  
        // the other Percept combinations of property binons are created below
2469  
        for ping (Sens = 1; Sens <= NumSenses; Sens++) //For each property type = sense
2470  
        {
2471  
            TheType = Sens;
2472  
            Percepts[TheType][XQCnt][Fired] = SensorValues[Sens][XQCnt][Fired];
2473  
            Percepts[TheType][BinId][Fired] = SensedBinons[Sens]; //Property binons into Percepts Level 1
2474  
2475  
            if (Percepts[TheType][BinId][Current] != NullObject) //use the previous SensedBinon
2476  
            {
2477  
                if (SensedBinons[Sens] != Percepts[TheType][BinId][Current]) {
2478  
                    HaveAChange = true; //This property binon has changed
2479  
                }
2480  
            } else //Else the Current entry is empty the first time through
2481  
            {
2482  
                if (StoreAt != 1) {
2483  
                    Stop();
2484  
                }
2485  
            }
2486  
        } //end for each property binon
2487  
2488  
        CreatePerceptCombos(); //Create all the combinations of Percepts
2489  
2490  
        //Report on Percept perceptions
2491  
        DisplayPercepts(Fired);
2492  
2493  
        //------ What attracts attention and thus what to pay attention to / focus on
2494  
        //The highest level, most interesting changed, not null current Percept binon
2495  
        //captures attention for sequential processing
2496  
2497  
        TopBinon = NullObject; //Will be the highest complexity if no changed one found
2498  
        TopType = NullType;
2499  
2500  
2501  
        if (HaveAChange) {
2502  
            TopInterest = NoInterest; //The interest level of the highest changed binon
2503  
            for ping (PerceptType = NumPercepts; PerceptType >= 1; PerceptType--) //For all the Percept binon types from complex to property binons
2504  
            {
2505  
                FirstBinon = Percepts[PerceptType][BinId][Fired]; //The Percept that fired of this type - maybe NullObject
2506  
                SecondBinon = Percepts[PerceptType][BinId][Current]; //The previous or expected binon of this type - maybe NullObject
2507  
                if (FirstBinon != SecondBinon) //If the fired one is different / changed then
2508  
                {
2509  
                    //If have a perceived binon and an expected one then
2510  
                    if (FirstBinon != NullObject) {
2511  
                        IntInF = InterestIn(FirstBinon); //Interest level of this Percept
2512  
                        //If it is familiar and interest so far is also familiar then we use the largest changed combination
2513  
                        if (IntInF == FAMILIAR) {
2514  
                            if (TopInterest == NoInterest) //The first / highest familiar one
2515  
                            {
2516  
                                // subroutine UseThisOne
2517  
                                TopType = PerceptType;
2518  
                                TopBinon = FirstBinon; //Save the highest level changed interesting Percept
2519  
                                TopInterest = IntInF; //will be familiar - only used if HaveAChange=True
2520  
                            }
2521  
                            //Else if it is novel then use the lowest level highest interest that has changed
2522  
                        } else if (IntInF >= TopInterest) //If it is more or equal interest than the one so far then
2523  
                        {
2524  
                            // subroutine UseThisOne
2525  
                            TopType = PerceptType;
2526  
                            TopBinon = FirstBinon; //Save the highest level changed interesting Percept
2527  
                            TopInterest = IntInF; //will be familiar - only used if HaveAChange=True
2528  
                        }
2529  
                    } else //else one or both binons are NullObjects
2530  
                    {
2531  
                    } //End if it has a value
2532  
                } else //else got expected - no difference / change
2533  
                {
2534  
                } //End if it has changed
2535  
            }
2536  
            //If there is no change then the largest (highest level) not null combination is focused on.
2537  
        } else //else there is no change in stimuli
2538  
        {
2539  
            for ping (PerceptType = NumPercepts; PerceptType >= 1; PerceptType--) //For all the Percept binon types from complex to property binons
2540  
            {
2541  
                FirstBinon = Percepts[PerceptType][BinId][Fired]; //The Percept that fired of this type - maybe NullObject
2542  
                if (FirstBinon != NullObject) {
2543  
                    // subroutine UseThisOne
2544  
                    TopType = PerceptType;
2545  
                    TopBinon = FirstBinon; //Save the highest level changed interesting Percept
2546  
                    TopInterest = IntInF; //will be familiar - only used if HaveAChange=True
2547  
2548  
                    PerceptType = 1; //terminate loop
2549  
                }
2550  
            }
2551  
        }
2552  
2553  
        if (HaveAChange) //report about a different stimulus then - unexpected
2554  
        {
2555  
            GotWhat = "Got UNEXPECTED:  ";
2556  
        } else //else we got what was expected
2557  
        {
2558  
            GotWhat = "Got EXPECTED:  ";
2559  
        }
2560  
        World.appendBinonDisplayChngResults(rep(' ', 55) + GotWhat + DisplayPattern(TopBinon) + "\r\n");
2561  
2562  
        ClearExpectations(); //Clears PracticingBinon, PerceivedBinon etc.
2563  
        //Must have a property or Percept stimulus so place the value Percepts(..Fired)
2564  
        //in the Fired entry of STM[) at level 1][set its XQ count][set ExpectLevel, Expcts(] etc.
2565  
        RepeatCount = 0;
2566  
        if (TopBinon != NullObject) {
2567  
            RepeatCount = Percepts[TopType][XQCnt][Fired];
2568  
            //FireTheBinon(PercptLvl, TheBinon&, TQCnt, XQCnt)
2569  
            FireTheBinon(OL, TopBinon, 1, RepeatCount); //will set the XQ count and the Perceived etc.
2570  
            RememberStimulus(TopBinon, StoreAt);
2571  
2572  
        }
2573  
2574  
        //Move the fired Percepts() actually sensed into the current entries and clear the Fired entries
2575  
        for ping (PerceptType = 1; PerceptType <= NumPercepts; PerceptType++) //For all property and Percept binon types
2576  
        {
2577  
            Percepts[PerceptType][BinId][Current] = Percepts[PerceptType][BinId][Fired];
2578  
            Percepts[PerceptType][BinId][Fired] = NullObject; //clear their entries
2579  
            Percepts[PerceptType][XQCnt][Current] = Percepts[PerceptType][XQCnt][Fired];
2580  
            Percepts[PerceptType][XQCnt][Fired] = 0;
2581  
        }
2582  
    } //End of ProcessStimuli()
2583  
2584  
    public final void ProcessSenses(int OL, int[][][] SensorValues) //Called from ProcessStimuli()
2585  
    {
2586  
2587  
        //Goes through the Raw sensor data in SensorValues(), creates the property type SensedBinons().
2588  
2589  
        //SensorValues consist of:
2590  
        //   Text = the symbolic value for the letter - symbolic
2591  
        //   Intensity = the value for the sensor measurement - Magnitude
2592  
2593  
        var SensedBinon = new Var<>(0);
2594  
        var NewBee = new Var<>(false);
2595  
        int PropBinonType;
2596  
        int PrevLogVal;
2597  
        int FiredLogVal;
2598  
        int ValuDiff;
2599  
2600  
//' --------------------------  Senses and Sensors --------------------------
2601  
//
2602  
//  Public NumSenses              'The number of physical senses, Max of 8
2603  
//                                'Currently equals the NumProperties since each sense currently = 1 property type
2604  
//  Public MaxSenses              'Maximum number of senses = max 8 physical senses
2605  
        //unused String[] Sense = new String[1 + 8];        //Names of senses, up to 8 physical senses
2606  
//
2607  
//  Public Senses[1 To 8][1 To 6] 'Properties of the different senses
2608  
//                                '1st index = Sense number
2609  
//                                '2nd index = Sense property
2610  
//
2611  
//                '---- Senses() - 2nd index values - Sense Properties
2612  
//  Public PropertyBinonType      '1, Stimulus property binon type e.g. 1 = TextBin or 2 = ContBin
2613  
//  Public SymbolicOrMagnitude    '2, Symbolic or Magnitude indicator
2614  
//  Public LowerRangeLimit        '3, Lower limit of range of values, zero is minimum (65 = "A")
2615  
//  Public UpperRangeLimit        '4, Upper limit of range of values, 255 is maximum (90 ="Z")
2616  
//  Public LinearOrCircular       '5, Linear list or Ring/Circular of values for Magnitude sense, Distance is Linear, Compass degrees are Circular (0 to 360)
2617  
//  Public IntegersOrLogs         '6, Integer Values or Log Values, Temperatures are Integers while Decibels are Logs
2618  
//  Public NumberOfSensors        '7  Number of sensors in sensor array
2619  
//  Public SensorsDependentOrIndependent '8 are sensors adjacent (dependent) or independent
2620  
//
2621  
//  Public Symbolic               '1, Indicates that the values from this sense are symbolic, range A -> Z
2622  
//  Public Magnitude              '2, Indicates that the values from this sense are numeric, integers, range 0 -> Limit
2623  
//
2624  
//  Public Linear                 '1, Indicates that the values go from the lower limit to upper limit
2625  
//  Public Circular               '2, Indicates that the values rap around from the upper limit to 0
2626  
//
2627  
//  Public IntegerValues          '1, Indicates that the values are integer readings
2628  
//  Public LogValues              '2, Indicates that the values are already logs - orders of magnitude
2629  
//  '--------------------  Values of stimuli from senses / sensors ------------------------------
2630  
//
2631  
//  Public SensorValues[1 To 8][1 To 2][0 To 1]   'Stimulus values from senses/sensors
2632  
//                                '1st index is sense number, currently = property binon type
2633  
//                                '2nd index is what type of information is in the SensorValues(), XQCnt or Valu
2634  
//                                '3rd index is Fired for the most recent stimulus value and Current for the previous
2635  
//
2636  
//                '---- SensorValues 2nd index values - type of information in SensorValues()
2637  
//  Public XQCnt                  '=1, the count of times the value has repeated, also used below
2638  
//  Public Valu                   '=2, the value for the stimulus, if symbolic then value = Asc(Symbol$)
2639  
//  Public NoName$                '"_", The character used when no letter provided for the IDL value of a TextBin binon
2640  
//
2641  
//                '---- SensorValues 3rd index values - which past stimulus it is - also used below
2642  
//  Public Fired                  '=0   'stimulus put in this level upon firing before being processed
2643  
//  Public Current                '=1   'The Fired one becomes the Current one after processing
2644  
2645  
        //------ Create binons from Sensed values that have changed and put them in SensedBinons()
2646  
        //       and move the fired SensorValues to the previous entries for all senses = property types
2647  
2648  
        for ping (int Sens = 1; Sens <= NumSenses; Sens++) //For each sense (TextBin and ContBin) = for each property type
2649  
        {
2650  
            PropBinonType = Sens; //In Morse code only one property per sense
2651  
            if (Senses[Sens][SymbolicOrMagnitude] == Symbolic) //If symbolic then
2652  
            {
2653  
                //Symbolic values always put in SensedBinons() whether they changed or not.
2654  
                //Create or find the binon for this symbolic value
2655  
                //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
2656  
                IdBinons(OL, PropBinonType, NullObject, 0, NullObject, 0, SensorValues[Sens][Valu][Fired], Parallel, 0, SensedBinon, NewBee);
2657  
                SensedBinons[Sens] = SensedBinon.get(); //Fired Symbolic value changed
2658  
2659  
            } else //Else ValueType = Magnitude
2660  
            {
2661  
                FiredLogVal = Buckit(SensorValues[Sens][Valu][Fired], SizeBase); //Goal
2662  
                //The first time though we will not have a previous (Current) sensor reading (PrevLogVal)
2663  
                if (SensorValues[Sens][Valu][Current] == 0) //no previous value
2664  
                {
2665  
                    ValuDiff = 1; //there is a change in the Magnitude reading
2666  
                } else {
2667  
                    PrevLogVal = Buckit(SensorValues[Sens][Valu][Current], SizeBase); //Trigger
2668  
                    //Adjacent repeat quantities are used to produce a ratio - same as these two lines of code:
2669  
                    //ValuDiff = Int(Abs(PrevLogVal - FiredLogVal) / 100)    'the difference in the Logs = ratio of repeats
2670  
                    //If FiredLogVal > PrevLogVal Then ValuDiff = -ValuDiff  'keep the sign
2671  
                    ValuDiff = (PrevLogVal - FiredLogVal) / 100; //Trigger minus Goal Logs
2672  
                }
2673  
                //Using ValuDiff will produce values of 1 and -1 as the contrast (Intensity) SensorValues()
2674  
                //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, _
2675  
                //IDLRatio, SeqOrPar, ExpectIt, ObjId, NewOne As boolean);
2676  
                IdBinons(OL, PropBinonType, NullObject, 0, NullObject, 0, ValuDiff, Parallel, 0, SensedBinon, NewBee);
2677  
                SensedBinons[Sens] = SensedBinon.get(); //Fired Magnitude value changed by a JND
2678  
            }
2679  
2680  
            SensorValues[Sens][Valu][Current] = SensorValues[Sens][Valu][Fired]; //save the previous value
2681  
            SensorValues[Sens][XQCnt][Current] = SensorValues[Sens][XQCnt][Fired]; //save the previous repeat count
2682  
2683  
        } //End of loop for each property type = sense
2684  
2685  
    } //End of ProcessSenses()
2686  
2687  
    public final void CreatePerceptCombos() //Create all the combinations of Percepts
2688  
    {
2689  
2690  
        var SensedBinon = new Var<>(0);
2691  
        var  NewBee = new Var<>(false);
2692  
        int PropBinonType;
2693  
        int OL;
2694  
        int FirstType;
2695  
        int FirstBinon;
2696  
        int IntInF;
2697  
        boolean FirstChanged;
2698  
        int SecondType;
2699  
        int SecondBinon;
2700  
        int IntInS;
2701  
        boolean SecondChanged;
2702  
2703  
        //For all the possible pairs of not null 1st level Percepts() = Property binon level
2704  
        // Create the 2nd and higher level combinations,
2705  
        //combine changed with changed and no change with no change but only if both property binons are familiar.
2706  
        //Fill in Percepts() with a NullObject if either source binon is a NullObject or novel
2707  
2708  
        //Need to create the Percept combinations of property binons - data driven algorithm from PerceptSources()
2709  
        for ping (PropBinonType = NumProperties + 1; PropBinonType <= NumPercepts; PropBinonType++) //PropBinonType used for position of the combination
2710  
        {
2711  
            FirstType = PerceptSources[PropBinonType][FirstSource];
2712  
            SecondType = PerceptSources[PropBinonType][SecondSource];
2713  
            OL = PerceptSources[PropBinonType][PerceptLevel];
2714  
            // CombineThem; //Uses Percepts[TheType][BinId][Current] to determine change
2715  
2716  
            // CombineThem:
2717  
            FirstBinon = Percepts[FirstType][BinId][Fired];
2718  
            SecondBinon = Percepts[SecondType][BinId][Fired];
2719  
            Percepts[PropBinonType][BinId][Fired] = NullObject; //assume the combination will not be produced
2720  
            if (FirstBinon != NullObject && SecondBinon != NullObject) //if both sources are not null
2721  
            {
2722  
                IntInF = InterestIn(FirstBinon);
2723  
                IntInS = InterestIn(SecondBinon);
2724  
                //Both source binons must be familiar before they can be combined
2725  
                if (CreateAll || (IntInF == FAMILIAR && IntInS == FAMILIAR)) {
2726  
                    //Both source binons must have changed or both stayed the same before they can be combined
2727  
                    FirstChanged = false; //Percepts[TheType][BinId][Current]
2728  
                    if (Percepts[FirstType][BinId][Current] != FirstBinon) {
2729  
                        FirstChanged = true;
2730  
                    }
2731  
                    SecondChanged = false;
2732  
                    if (Percepts[SecondType][BinId][Current] != SecondBinon) {
2733  
                        SecondChanged = true;
2734  
                    }
2735  
                    if (FirstChanged == SecondChanged) //If both changed or both stayed the same then
2736  
                    {
2737  
                        //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
2738  
                        IdBinons(OL, PropBinonType, FirstBinon, 0, SecondBinon, 0, 0, Parallel, 0, SensedBinon, NewBee);
2739  
//exp                Call SetInterest(PropBinonType, SensedBinon, FAMILIAR)    'Percept binons always familiar
2740  
                        //The property combination binon has fired (been recognized) and is expecting to fire again
2741  
2742  
                        Percepts[PropBinonType][BinId][Fired] = SensedBinon.get();
2743  
                        //Need value in Fired because it will be moved into current
2744  
                        Percepts[PropBinonType][XQCnt][Fired] = Percepts[FirstType][XQCnt][Fired];
2745  
                    } else //else no combination binon created at level 1 - Source Percepts() are not familiar & changed
2746  
                    {
2747  
                    }
2748  
                } else //else no combination binon created at level 1 - Source Percepts() are not familiar
2749  
                {
2750  
                }
2751  
            } else //else no combination binon created at level 1 - Source Percepts() are NullObjects
2752  
            {
2753  
            }
2754  
            // end of CombineThem
2755  
2756  
        }
2757  
2758  
    } //End CreatePerceptCombos()
2759  
2760  
    public final void ActivateAction(int DoBinon) //called from PerceptionAction()
2761  
    {
2762  
2763  
        //DoBinon& is the PracticingBinon Action that is to be done
2764  
2765  
        var DHabitBinon = new Var<>(0);
2766  
2767  
        //GetDHabit returns the Action or D-Habit Binon
2768  
        GetDHabit(DoBinon, DHabitBinon); //Get the level 1 D-Habit to perform
2769  
2770  
        PerformDHabit(DHabitBinon.get());
2771  
2772  
    } //End of ActivateAction()
2773  
2774  
    public final void PerformDHabit(int DoBinon) //called from ActivateAction()
2775  
    {
2776  
2777  
        //DoBinon is a level 1 Binon (D-Habit) that contains the device response to perform.
2778  
        //   DoBinon after pass 1 has been done is the expected response.
2779  
        //   It calls PerformResponses() which performs the DoBinon.
2780  
        //   This means it outputs the LetrBin. Then it fires the binon so it is on the STM().
2781  
2782  
        var Letter = new Var<>("");
2783  
        //unused int LetterBinon = 0;
2784  
        int DeviceNum = 0;
2785  
        //unused boolean NewBee = false;
2786  
        int OutType;
2787  
        int OutBinon = 0;
2788  
2789  
//  '--------------------  Devices ------------------------------------------------
2790  
//
2791  
//  Public NumDevices             'Number of output devices
2792  
//  Public MaxDevices             'Maximum number of devices = max 8 devices
2793  
//  Public Device$(1 To 8)        'Names of device, up to 8 devices
2794  
//
2795  
//  Public Devices[1 To 8][1 To 5] 'Properties of the output / response devices
2796  
//                                '1st index = Device number
2797  
//                                '2nd index = Device property
2798  
//  Public DeviceResponses$(1 To 4)   'A string of the possible symbolic responses for the device
2799  
2800  
        //---- Devices() - 2nd index values - Device Properties - DEFINED ABOVE
2801  
//  Public PropertyBinonType      '1, Response property binon type e.g. 1 = LetrBin
2802  
//  Public SymbolicOrMagnitude    '2, Symbolic or Magnitude indicator
2803  
//  Public LowerRangeLimit        '3, Lower limit of range of response values, zero is minimum (97 = "a")
2804  
//  Public UpperRangeLimit        '4, Upper limit of range of response values, 255 is maximum (122 = "z")
2805  
//  Public LinearOrCircular       '5, Linear list or Ring/Circular of values for Magnitude sense, Distance is Linear, Motor rotations are Circular (0 to 360)
2806  
//  Public IntegersOrLogs         '6, Integer Values or Log Values, Temperatures are Integers while Decibels are Logs
2807  
2808  
//  Public Symbolic               '1, Indicates that the values for this device are symbolic, Range a -> z
2809  
//  Public Magnitude              '2, Indicates that the values for this device are numeric, integers, range 0 -> limit
2810  
2811  
//  Public Linear                 '1, Indicates that the values go from the lower limit to upper limit
2812  
//  Public Circular               '2, Indicates that the values rap around from the upper limit to 0
2813  
2814  
//  Public IntegerValues          '1, Indicates that the values are integer readings
2815  
//  Public LogValues              '2, Indicates that the values are already logs - orders of magnitude
2816  
2817  
        //Find the response parts of DoBinon - should use Devices() to identify the binon types involved
2818  
        if (DoBinon == NullObject) //If there was no response in DoBinon then
2819  
        {
2820  
            Stop(); //should always have one selected by DetermineResponse()
2821  
//      DeviceNum = 1                                     'Letters = LetrBin
2822  
//      OutType = Devices[DeviceNum][PropertyBinonType]   'Currently = LetrBin for device #1
2823  
//      Letter$ = NoResp$
2824  
//                  'Should distinguish between symbolic versus Magnitude responses
2825  
//                  'Create or find the binon for this symbolic value
2826  
//          'IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
2827  
//      Call IdBinons(1, OutType, NullObject, 0, NullObject, 0, Asc(Letter$), Parallel, 0, OutBinon, NewBee)
2828  
2829  
        } else //else have a letter to output
2830  
        {
2831  
            OutBinon = DoBinon;
2832  
            OutType = BinonTypeOf(DoBinon);
2833  
            DeviceNum = BinonTypes[OutType][SensOrDevNum]; //the device number for this response type binon
2834  
        }
2835  
2836  
        //Output the response (if any) and setup the expectation
2837  
        Letter.set(""); //GetValue adds text to 3rd parameter = Letter$ so empty it
2838  
        GetValue(OutBinon, Letter);
2839  
        Letter.set(StringHelper.trim(Letter.get(), ' '));
2840  
2841  
        World.appendBinonDisplayChngResults("  OUTPUT response = " + Letter + "\r\n");
2842  
        DeviceValues[DeviceNum][XQCnt] = 1;
2843  
        DeviceValues[DeviceNum][Valu] = Binons[OutBinon][IDL];
2844  
2845  
        ClearExpectations(); //Clears PerceivedBinon
2846  
2847  
        //FireTheBinon(PercptLvl, TheBinon&, TQCnt, XQCnt)
2848  
        FireTheBinon(1, OutBinon, 1, 1); //will set PerceivedBinon
2849  
        RememberResponse(OutBinon, StoreAt);
2850  
2851  
    } //End PerformDHabit()
2852  
2853  
    public final void ReportPerceptions() {
2854  
2855  
        //Display the Fired, Current and previous perceptions in Percepts()
2856  
2857  
        //unused String OLvl = null;
2858  
        //unused String Prcpt = null;
2859  
        //unused String Pcpts = null;
2860  
2861  
        DisplayPercepts(Current);
2862  
2863  
        //Report on Perceptual sequence perceptions
2864  
        World.appendBinonDisplayChngResults(DisplaySTM() + "\r\n");
2865  
2866  
    } //End of ReportPerceptions()
2867  
2868  
    public final void DisplayPercepts(int CurrOrFired) {
2869  
2870  
        int BinType;
2871  
        //Report on Percept recognitions
2872  
        World.appendBinonDisplayChngResults("   Percepts = ");
2873  
        for ping (BinType = 1; BinType <= NumPercepts; BinType++) //All binon types except Actions
2874  
        {
2875  
            World.appendBinonDisplayChngResults(DisplayPercept(BinType, CurrOrFired));
2876  
        }
2877  
        World.appendBinonDisplayChngResults("\r\n");
2878  
2879  
    } //End of DisplayPercepts()
2880  
2881  
    public final String DisplayPercept(int BType, int CurrOrFired) {
2882  
2883  
        return StringHelper.trim(String.valueOf(Percepts[BType][XQCnt][CurrOrFired]), ' ') + "x" + DisplayPattern(Percepts[BType][BinId][CurrOrFired]) + "   ";
2884  
2885  
    } //End of DisplayPercept$()
2886  
2887  
    public final String DisplaySTM() {
2888  
        String tempDisplaySTM = "";
2889  
2890  
        int OLvl;
2891  
        int Prcpt;
2892  
        String Pcpts;
2893  
        //Report on perceptions in STM()
2894  
2895  
        if (STM[1][BinId][Current] == NullObject) //No STM entries then
2896  
        {
2897  
            tempDisplaySTM = "STM is empty" + "\r\n";
2898  
        } else {
2899  
            for ping (OLvl = 1; OLvl <= MaxLevels; OLvl++) {
2900  
                //printVars_str DisplaySTM(+OLvl, +MaxLevels);
2901  
              
2902  
                Pcpts = ""; //empty this line
2903  
2904  
                for ping (Prcpt = OLvl + 2; Prcpt >= Fired; Prcpt--) //find out if any are not null at this level
2905  
                {
2906  
                    if (STM[OLvl][BinId][Prcpt] != NullObject) {
2907  
                        Pcpts = Pcpts + DisplaySTMEntry(OLvl, Prcpt) + "  ";
2908  
                    }
2909  
                }
2910  
2911  
                if (!Pcpts.equals("")) //Only if there was a fired entry
2912  
                {
2913  
                    Pcpts = " " + "Lvl=" + StringHelper.trim(String.valueOf(OLvl), ' ') + " " + Pcpts; //Put level # at start of line
2914  
                    tempDisplaySTM = tempDisplaySTM + Pcpts + "\r\n";
2915  
                } else //else no current entry at this level
2916  
                {
2917  
                    OLvl = MaxLevels; //terminate the loop
2918  
                }
2919  
            }
2920  
            tempDisplaySTM = tempDisplaySTM + "\r\n";
2921  
        }
2922  
2923  
        return tempDisplaySTM;
2924  
    } //End of DisplaySTM$()
2925  
2926  
    public final String DisplaySTMEntry(int Percpt, int CurrFired) {
2927  
2928  
        int BinonId;
2929  
        //unused String BinonSt = null;
2930  
        var VL = new Var<>("");
2931  
2932  
        BinonId = STM[Percpt][BinId][CurrFired];
2933  
2934  
        GetValue(BinonId, VL);
2935  
        VL.set(substring(substring(VL.get(), 0, 20) + "     ", 0, 7)); //display 6 chars of pattern
2936  
2937  
        return "#" + StringHelper.trim(vbToStr(CurrFired), ' ')
2938  
          + "=" + StringHelper.trim(String.valueOf(STM[Percpt][XQCnt][CurrFired]), ' ') + "x" + StringHelper.trim(String.valueOf(STM[Percpt][TQCnt][CurrFired]), ' ') + DisplayStimulu(BinonId) + " " + VL;
2939  
2940  
    } //End of DisplaySTMEntry$()
2941  
2942  
    public final String DisplayPattern(int StimBin) {
2943  
        String tempDisplayPattern;
2944  
2945  
        var BinonTyp = new Var<>("");
2946  
        var VL = new Var<>("");
2947  
        int NumChr;
2948  
        int StimTyp;
2949  
2950  
        StimTyp = BinonTypeOf(StimBin);
2951  
2952  
        if (StimTyp == NullType) {
2953  
            tempDisplayPattern = " ~ ";
2954  
        } else if (StimBin == NullObject) //Have a type but no binon
2955  
        {
2956  
            GetTypeInfo(StimTyp, BinonTyp, VL);
2957  
            tempDisplayPattern = VL.get().substring(0, 2) + " ~";
2958  
        } else {
2959  
            NumChr = 5 + 6 * (StimTyp - 1); //Level 2 is 11 characters, level 3 is 17 characters
2960  
            GetValue(StimBin, VL);
2961  
            tempDisplayPattern = DisplayStimulu(StimBin) + " " + substring(VL.get(), 0, NumChr);
2962  
        }
2963  
2964  
        return tempDisplayPattern;
2965  
    } //End of DisplayPattern$()
2966  
2967  
    public final String DisplayStimulu(int StimBin) {
2968  
        String tempDisplayStimulu;
2969  
2970  
        var BTyp = new Var<>("");
2971  
        var Rdg = new Var<>("");
2972  
        String Inf;
2973  
        String Gl;
2974  
        int StimTyp;
2975  
2976  
        StimTyp = BinonTypeOf(StimBin);
2977  
2978  
        if (StimBin == NullObject || StimTyp == NullType) {
2979  
            tempDisplayStimulu = "-00";
2980  
        } else {
2981  
            GetTypeInfo(StimTyp, BTyp, Rdg);
2982  
            Gl = StringHelper.trim(Rdg.get().substring(0, 2), ' ') + StringHelper.trim(String.valueOf(StimBin), ' ');
2983  
            Inf = IntSymb(InterestIn(StimBin));
2984  
            tempDisplayStimulu = Inf + Gl + AESR(StimBin);
2985  
        }
2986  
2987  
        return tempDisplayStimulu;
2988  
    } //End of DisplayStimulu$()
2989  
2990  
    public final String InterestSymbol(int BinNum) {
2991  
2992  
        int IntIn;
2993  
2994  
        IntIn = InterestIn(BinNum);
2995  
        return IntSymb(IntIn);
2996  
2997  
    } //End of InterestSymbol$()
2998  
2999  
    public String IntSymb(Object Intrst) {
3000  
        String tempIntSymb;
3001  
3002  
        tempIntSymb = ASpace;
3003  
3004  
        switch ((Integer) Intrst) {
3005  
3006  
            case NOVEL:
3007  
                tempIntSymb = chr(254);
3008  
3009  
                break;
3010  
            case INTERESTING:
3011  
                tempIntSymb = "!";
3012  
3013  
                break;
3014  
            case FAMILIAR:
3015  
                tempIntSymb = "-";
3016  
3017  
                break;
3018  
        }
3019  
3020  
        return tempIntSymb;
3021  
    } //End of IntSymb$()
3022  
3023  
    public void ClearExpectations() //Called by ClearMemory(), ProcessStimuli() and PerformAction()
3024  
    {
3025  
3026  
        PerceivedBinon = NullObject;
3027  
3028  
    } //End of ClearExpectations()
3029  
3030  
    public final void FireTheBinon(int PercptLvl, int TheBinon, int TQCount, int XQCount) {
3031  
3032  
        //Called from ProcessStimuli() for the most changed stimulus combination
3033  
        //Called from CreateCombo which is called by ProcessSTMLevel() every time a familiar stimulus is experienced
3034  
        //Called from PerformAction() after response produced
3035  
3036  
        //The binon has fired so place it in the Fired entry at this level in the STM, increment its XQ count,
3037  
        //idle it and make it the most recent target of its left and right source binons.
3038  
3039  
        //A newly created binon can not fire - can not be put on the STM()
3040  
3041  
        int Uselink;
3042  
3043  
        //Make it the most recent target binon of its left and right source binons
3044  
        ImYourMostRecent(TheBinon, TriggerList);
3045  
        ImYourMostRecent(TheBinon, GoalList);
3046  
3047  
        if (InterestIn(TheBinon) != NOVEL) {
3048  
            if (TheBinon != NullObject) //If a valid binon has fired
3049  
            {
3050  
3051  
                STM[PercptLvl][BinId][Fired] = TheBinon;
3052  
3053  
                if (STM[PercptLvl][XQCnt][Fired] != 0) //should be zero
3054  
                {
3055  
                    Stop();
3056  
                }
3057  
                STM[PercptLvl][XQCnt][Fired] = XQCount; //It has fired this many times
3058  
                STM[PercptLvl][TQCnt][Fired] = TQCount; //trigger firing count for comparison of size of repeaters
3059  
3060  
//          BinonDisplay.ChngResults.Text = BinonDisplay.ChngResults.Text & " + Binon " & _
3061  
//                                DisplayPattern$(TheType, TheBinon) & " Fired" & vbCrLf
3062  
//
3063  
3064  
                //Want the PerceivedBinon to be the highest fired Perceptual or Action sequence binon
3065  
                //that triggers at least one associating binon or the level-1 S or R that has no associating binon
3066  
                if (PercptLvl == 1) //If at level-1 start with the S or R
3067  
                {
3068  
                    PerceivedBinon = TheBinon; //Track the trigger of expected goal for the Action
3069  
                } else {
3070  
                    if (isSorR(TheBinon)) //If on an odd level - Perceptual - or Action sequence then
3071  
                    {
3072  
                        Uselink = FloatingPointToInteger.ToInt32(MostRecentTriggerTargetLink(TheBinon)); //determine its first associating binon, if any
3073  
                        if (Uselink != NullTarget) //If the fired binon has at least one associating binon
3074  
                        {
3075  
                            PerceivedBinon = TheBinon; //Track the trigger of expected goal for the Action
3076  
                        } else //else use the previously assigned PerceivedBinon
3077  
                        {
3078  
                        }
3079  
                    } else //else we are on an even level - A- or Expectation
3080  
                    {
3081  
//              Stop
3082  
                    }
3083  
                }
3084  
3085  
            } else {
3086  
                Stop(); //The fired binon should never be null
3087  
            }
3088  
        } else //else it is novel and can not be put on STM()
3089  
        {
3090  
            String Res = ("    " + PercptLvl).substring(("    " + PercptLvl).length() - 5) 
3091  
              + vbToStr(Binons[TheBinon][TriggerCount])
3092  
              + vbToStr(Binons[TheBinon][GoalCount])
3093  
              + " " + DisplayPattern(TheBinon) + " NEW" + "\r\n";
3094  
3095  
            World.appendBinonDisplayChngResults("\r\n" + Res);
3096  
        } //End If TheBinon is not novel
3097  
3098  
    } //End of FireTheBinon()
3099  
3100  
    public final void ImYourMostRecent(int HabBinon, int TriggerOrGoal) {
3101  
3102  
        int SourceBinon;
3103  
        int TgtLink;
3104  
        int TgtBinon;
3105  
        int PrevLink;
3106  
        int FirstLink;
3107  
        boolean FoundIt;
3108  
3109  
        if (TriggerOrGoal == TriggerList) {
3110  
            SourceBinon = Binons[HabBinon][O1]; //Left source binon - trigger
3111  
        } else {
3112  
            SourceBinon = Binons[HabBinon][O2]; //Right source binon - goal
3113  
        }
3114  
3115  
        if (SourceBinon != NullObject) {
3116  
            //Find the target binon on the trigger or goal list of the source binon and move it to the front of the list
3117  
            TgtLink = Binons[SourceBinon][TriggerOrGoal];
3118  
            FirstLink = TgtLink;
3119  
            FoundIt = false;
3120  
            PrevLink = NullTarget;
3121  
3122  
            while ping (!FoundIt) {
3123  
                if (TgtLink == NullTarget) //should have been on the list
3124  
                {
3125  
                    Stop();
3126  
                }
3127  
                TgtBinon = Targets[TgtLink][TargetBinon]; //The target binon
3128  
                if (TgtBinon == HabBinon) //If it matches the HabBinon then found the entry
3129  
                {
3130  
                    FoundIt = true;
3131  
                    if (PrevLink != NullTarget) //If not at the start of the list already
3132  
                    {
3133  
                        Targets[PrevLink][NLnk] = Targets[TgtLink][NLnk]; //remove the TgtLink Targets() entry from linked list
3134  
                        Targets[TgtLink][NLnk] = FirstLink; //TgtLink Targets() entry points to old first one on list
3135  
                        Binons[SourceBinon][TriggerOrGoal] = TgtLink; //It is now the 1st one / most recent target of source binon
3136  
                    }
3137  
                } else {
3138  
                    PrevLink = TgtLink; //Link for the previous Targets() entry
3139  
                    TgtLink = Targets[TgtLink][NLnk]; //go to the next link in Targets list
3140  
                }
3141  
            }
3142  
3143  
        }
3144  
3145  
    } //End of ImYourMostRecent()
3146  
3147  
    public final double MostRecentTriggerTargetLink(int TheBinon) {
3148  
        double tempMostRecentTriggerTargetLink;
3149  
3150  
        //Called from FireTheBinon() when upadting STM() and DetermineResponse() when thinking
3151  
3152  
        int TgtLink;
3153  
3154  
        //Obtain the link to the most recent (first) target ActBin for the trigger
3155  
3156  
        TgtLink = Binons[TheBinon][TriggerList]; //The list of all targets for which it is the trigger
3157  
        tempMostRecentTriggerTargetLink = NullTarget;
3158  
3159  
        if (Binons[TheBinon][TriggerCount] > 0) //If TheBinon has any sequential right targets then
3160  
        {
3161  
            while ping (TgtLink != NullTarget) {
3162  
                if (BinonTypeOf(Targets[TgtLink][TargetBinon]) == ActBin) //The type of right target binon of the the given stimulus
3163  
                {
3164  
                    tempMostRecentTriggerTargetLink = TgtLink;
3165  
                    TgtLink = NullTarget; //found the first useful Perceptual sequence - terminate the loop
3166  
                } else //else some of the right targets could be Percepts?
3167  
                {
3168  
                    TgtLink = Targets[TgtLink][NLnk]; //skip Percepts
3169  
                }
3170  
            }
3171  
        }
3172  
3173  
        return tempMostRecentTriggerTargetLink;
3174  
    } //End of MostRecentTriggerTargetLink()
3175  
3176  
    public final void GetDHabit(int TheBinon, Var<Integer> FoundBinon) {
3177  
3178  
        //This finds the level-1 D-Habit or response binon for the given binon (TheBinon - may be an Action) and
3179  
        //returns it as the expected binon (FoundBinon - may be a D-Habit or response binon)
3180  
3181  
        //unused int NameBinon = 0;
3182  
3183  
        FoundBinon.set(TheBinon); //If it is the NullObject then that is returned
3184  
3185  
        while ping (BinonTypeOf(FoundBinon.get()) == ActBin) {
3186  
            FoundBinon.set(Binons[FoundBinon.get()][O2]);
3187  
        }
3188  
        //Now the Found binon type is a D-Habit binon
3189  
3190  
    } //End of GetDHabit()
3191  
3192  
    public final void ProcessSTMLevel(int ObjtLvl, int SourceBinon, int AorE, boolean CheckRepeat) //called by PerceptionAction()
3193  
    {
3194  
3195  
        //If CheckRepeat then determine if the Fired at this level is same as repeat position.
3196  
        //If it is a repeater then increases its count.
3197  
        //Then combines the Current and Fired entries and puts them at one level higher in STM
3198  
        //The fired binon at ObjtLvl is still in Fired position in STM when done.
3199  
3200  
        int Prcpt;
3201  
        int TQFired;
3202  
        int XQFired;
3203  
        int OldPercBin;
3204  
        int TQRepeat;
3205  
        int TrgtLvl;
3206  
3207  
//tmp        BinonDisplay.ChngResults.Text = BinonDisplay.ChngResults.Text & Trim(Str$(ObjtLvl)) & "-0a/ Fired binon " & _
3208  
//                                        DisplayPattern[SourceType][SourceBinon] + "\r\n";
3209  
3210  
        //check to see if the pattern matches the previous pattern at this level
3211  
        //if it matches then
3212  
        //   increment the past entry for the repeat and move it up to current
3213  
3214  
        Prcpt = ObjtLvl; //Repeater at this level will be in this entry position
3215  
        TrgtLvl = ObjtLvl + 1;
3216  
3217  
        if (CheckRepeat) //If need to check if an Action or Expectation repeats then
3218  
        {
3219  
            World.appendBinonDisplayChngResults(StringHelper.trim(String.valueOf(ObjtLvl), ' ') 
3220  
              + "-0c/ Check for repeater Action" + "\r\n");
3221  
            OldPercBin = STM[ObjtLvl][BinId][Prcpt]; //Any repeater should be in the correct position = ObjtLvl
3222  
            if (OldPercBin == SourceBinon) //If the old = Fired it is a repeat binon
3223  
            {
3224  
                TQFired = STM[ObjtLvl][TQCnt][Fired]; //Trigger quantity (size) of the SourceBinon just fired
3225  
                TQRepeat = STM[ObjtLvl][TQCnt][Prcpt]; //Trigger quantity (size) for the older Prcpt binon
3226  
                if (TQRepeat == TQFired) //If the repeater is the same size as the fired one then
3227  
                {
3228  
//tmp            BinonDisplay.ChngResults.Text = BinonDisplay.ChngResults.Text & Trim(Str$(ObjtLvl)) & "-0b/ Pattern " & _
3229  
//                                                    DisplayPattern[SourceType][SourceBinon] + " Repeats" + "\r\n";
3230  
                    //Increment its repeat count by the number of time it fired (duration at level 1)
3231  
                    XQFired = STM[ObjtLvl][XQCnt][Fired];
3232  
                    STM[ObjtLvl][XQCnt][Prcpt] = STM[ObjtLvl][XQCnt][Prcpt] + XQFired;
3233  
                    MoveAmount = MoveAmount + ObjtLvl;
3234  
                    //MoveRight(ObLvl, FromEntry, ToEntry, UpTo)
3235  
                    MoveRight(ObjtLvl, Prcpt, Fired, 2 * Prcpt); //repeater ends up in Fired entry
3236  
                    EmptySTM(TrgtLvl, Fired); //clear the fired next level up
3237  
                } else //same pattern but different size
3238  
                {
3239  
                    //Stop                                           'OK - treat as not repeating
3240  
//tmp            BinonDisplay.ChngResults.Text = BinonDisplay.ChngResults.Text & Trim(Str$(ObjtLvl)) & "-0c/ Pattern " & _
3241  
//                                                    DisplayPattern(SourceType, SourceBinon) + " does Not repeat" + "\r\n";
3242  
                }
3243  
            } else {
3244  
//tmp          BinonDisplay.ChngResults.Text = BinonDisplay.ChngResults.Text & Trim(Str$(ObjtLvl)) & "-0c/ Pattern " & _
3245  
//                                                DisplayPattern(SourceType, SourceBinon) + " does Not repeat" + "\r\n";
3246  
            }
3247  
        }
3248  
        //If it does not repeat
3249  
        //  Then as a goal combine the trigger previous to it at this level
3250  
        //  (if there is a trigger) and place it in the next level up fired position
3251  
3252  
        if (STM[ObjtLvl][BinId][Current] != NullObject) //If there is a trigger previous to the fired location
3253  
        {
3254  
            if (STM[ObjtLvl][BinId][Fired] != NullObject) //and there is a goal at the repeater position
3255  
            {
3256  
                if (ObjtLvl > 1 || STM[ObjtLvl][XQCnt][Current] != 0) //set to 0 if already used
3257  
                {
3258  
                    CreateCombo(ObjtLvl, Current, AorE); //Place the result in Fired of level above
3259  
                } else {
3260  
                    Stop(); // why?
3261  
                }
3262  
                if (Prcpt + 2 <= MaxLevels) {
3263  
                    EmptySTM(ObjtLvl, Prcpt + 2); //Remove used trigger binon
3264  
                }
3265  
            } else //The fired binon is NullObject
3266  
            {
3267  
                Stop();
3268  
            }
3269  
        }
3270  
3271  
    } //End ProcessSTMLevel()
3272  
3273  
    public final void MoveRight(int ObLvl, int FromEntry, int ToEntry, int UpTo) {
3274  
3275  
        //Move all the entries at the ObLvl to the right so that the one at FromEntry ends up at ToEntry position
3276  
        //Null out previous locations, stop when the From Entry reaches the UpTo position
3277  
3278  
        int Prcpt;
3279  
        int NewPrcpt;
3280  
        int Distance;
3281  
3282  
        Distance = FromEntry - ToEntry; //how far they have to move
3283  
        if (UpTo > MaxLevels) {
3284  
            UpTo = MaxLevels;
3285  
        }
3286  
3287  
        for ping (Prcpt = FromEntry; Prcpt <= UpTo; Prcpt++) {
3288  
            NewPrcpt = Prcpt - Distance;
3289  
            MoveOnePerception(ObLvl, Prcpt, NewPrcpt);
3290  
            EmptySTM(ObLvl, Prcpt); //Nullify where it came from
3291  
        }
3292  
3293  
    } //End MoveRight()
3294  
3295  
    public final void MoveLeft(int ObLvl) {
3296  
3297  
        //Move all the entries at this ObLvl to the left one position so the Fired is in the Current
3298  
3299  
        int Prcpt;
3300  
        boolean HaveAPercept;
3301  
        int ToPrcpt;
3302  
3303  
        HaveAPercept = false; //assume this level is empty
3304  
3305  
        ToPrcpt = ObLvl + 2;
3306  
        if (ToPrcpt >= MaxLevels) {
3307  
            ToPrcpt = MaxLevels - 1;
3308  
        }
3309  
3310  
        for ping (Prcpt = ToPrcpt; Prcpt >= Fired; Prcpt--) {
3311  
            if (STM[ObLvl][BinId][Prcpt] != NullObject) {
3312  
                HaveAPercept = true;
3313  
            }
3314  
            MoveOnePerception(ObLvl, Prcpt, Prcpt + 1); //Move it left one position
3315  
        }
3316  
        EmptySTM(ObLvl, Fired); //and clear the fired entry
3317  
3318  
        if (!HaveAPercept) {
3319  
            TopLevel = TopLevel - 1;
3320  
        }
3321  
3322  
    } //End MoveLeft()
3323  
3324  
    public final void MoveOnePerception(int ObLvl, int FromEntry, int ToEntry) {
3325  
3326  
        STM[ObLvl][BinId][ToEntry] = STM[ObLvl][BinId][FromEntry];
3327  
        STM[ObLvl][XQCnt][ToEntry] = STM[ObLvl][XQCnt][FromEntry];
3328  
        STM[ObLvl][TQCnt][ToEntry] = STM[ObLvl][TQCnt][FromEntry];
3329  
3330  
    } //End of MoveOnePerception()
3331  
3332  
    public void EmptySTM(int OLvl, int PrevCurrFired) {
3333  
3334  
        STM[OLvl][BinId][PrevCurrFired] = NullObject;
3335  
        STM[OLvl][XQCnt][PrevCurrFired] = 0;
3336  
        STM[OLvl][TQCnt][PrevCurrFired] = 0;
3337  
3338  
    } //End of EmptySTM()
3339  
3340  
    public final void CreateCombo(int ObjtLvl, int TrigPrcpt, int AorE) {
3341  
3342  
        //If it is possible, Combine the trigger (Current) and goal (Fired) binons in the STM()
3343  
3344  
        int TriggerBinon;
3345  
        int TQNum;
3346  
        int IntInTrig;
3347  
        int Bin12;
3348  
        int TQCount;
3349  
        int GoalBinon;
3350  
        int GQNum;
3351  
        int IntInGoal;
3352  
        int Bin21;
3353  
        int Prev1LogRpts;
3354  
        int Prev2LogRpts;
3355  
        int RptsDiff;
3356  
        var ResultBinon = new Var<>(0);
3357  
        int TgtLvl;
3358  
        var NewBee = new Var<>(false);
3359  
        int Bin11;
3360  
        int Bin22;
3361  
        boolean CombineThem;
3362  
3363  
        ResultBinon.set(NullObject); //Returned NullObject if not found or created
3364  
3365  
        TriggerBinon = STM[ObjtLvl][BinId][TrigPrcpt];
3366  
        if (ObjtLvl == 1) {
3367  
            STM[ObjtLvl][TQCnt][TrigPrcpt] = STM[ObjtLvl][XQCnt][TrigPrcpt]; //wait until it has stopped repeating
3368  
        }
3369  
        if (TriggerBinon != NullObject) //If have a trigger pattern then
3370  
        {
3371  
            GoalBinon = STM[ObjtLvl][BinId][TrigPrcpt - 1];
3372  
3373  
            if (GoalBinon != NullObject) //and if have a goal pattern then
3374  
            {
3375  
                IntInTrig = InterestIn(TriggerBinon);
3376  
                IntInGoal = InterestIn(GoalBinon);
3377  
                if (IntInTrig == FAMILIAR && IntInGoal == FAMILIAR) //if both familiar then
3378  
                {
3379  
                    Bin12 = Binons[TriggerBinon][O2];
3380  
                    Bin21 = Binons[GoalBinon][O1];
3381  
                    //If at source level 2 or higher they must overlap
3382  
                    //or they are adjacent at source level = 1
3383  
                    if ((ObjtLvl > 1 && Bin12 == Bin21) || ObjtLvl == 1) {
3384  
3385  
                        //When the 1st binon left source is specific enough to uniquely predict its next stimulus
3386  
                        //and the 2nd binon right source is specific enough to uniquely predict its previous stimulus and
3387  
                        //when the common source binon (Bin12 = Bin21) uniquely predicts both its goal and
3388  
                        //trigger binon then stop combining the trigger (TriggerBinon) with the goal (GoalBinon).
3389  
3390  
                        CombineThem = true;
3391  
                        if (ObjtLvl > 1) {
3392  
                            CombineThem = false;
3393  
                            Bin11 = Binons[TriggerBinon][O1];
3394  
                            Bin22 = Binons[GoalBinon][O2];
3395  
                            if (Binons[Bin11][TriggerCount] != 1 || Binons[Bin22][GoalCount] != 1 || Binons[Bin21][TriggerCount] != 1 || Binons[Bin21][GoalCount] != 1) //****** NOTE add True to the condition to turn off
3396  
                            {
3397  
3398  
                                CombineThem = true;
3399  
                            }
3400  
                        }
3401  
                        if (CombineThem) {
3402  
3403  
                            TQNum = STM[ObjtLvl][XQCnt][TrigPrcpt]; //the repeat value of the trigger - XQ count
3404  
                            GQNum = STM[ObjtLvl][XQCnt][TrigPrcpt - 1]; //the repeat value of the goal - XQ count
3405  
                            //Use the trigger and goal binons to create a new binon with
3406  
                            //the correct ratio and place it in the Fired perception at the TgtLvl
3407  
                            TgtLvl = ObjtLvl + 1;
3408  
3409  
                            Prev1LogRpts = Buckit(TQNum, SizeBase); //Trigger
3410  
                            Prev2LogRpts = Buckit(GQNum, SizeBase); //Goal
3411  
                            //Adjacent repeat quantities are used to produce a ratio - same as:
3412  
                            //QtyDiff = Int(Abs(Prev1LogRpts - Prev2LogRpts) / 100)
3413  
                            //the difference in the Logs = ratio of repeats
3414  
                            //If Prev2LogRpts > Prev1LogRpts Then RptsDiff = -RptsDiff 'keep the sign
3415  
                            RptsDiff = (Prev1LogRpts - Prev2LogRpts) / 100; //Trigger minus Goal Logs
3416  
3417  
                            //The new binon is Active but Idle - waiting for a repeat
3418  
                            //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
3419  
                            IdBinons(TgtLvl, ActBin, TriggerBinon, TQNum, GoalBinon, GQNum, RptsDiff, Sequential, AorE, ResultBinon, NewBee);
3420  
                            //The binon has fired so place it in the Fired entry at the target level, increment its XQ count,
3421  
                            //idle it and make it the most recent target of its trigger and goal.
3422  
                            TQCount = STM[ObjtLvl][TQCnt][TrigPrcpt]; //The size of the lowest level left part
3423  
                            //Add the fired stimulus to the Perceived STM().
3424  
                            //FireTheBinon will set the XQ count and the PerceivedBinon.
3425  
                            //FireTheBinon(PercptLvl, TheBinon&, TQCnt, XQCnt)
3426  
                            FireTheBinon(TgtLvl, ResultBinon.get(), TQCount, 1); //will set the XQ count
3427  
3428  
                        }
3429  
                    } //End if they overlap properly
3430  
                } //End if they are both familiar
3431  
            } else //Else the fired one is Nullobject
3432  
            {
3433  
                Stop(); //It should not be possible for fired one to be NullObject '
3434  
            } //End if the goal binon exists
3435  
        } else //Else the trigger is NullObject
3436  
        {
3437  
            Stop(); //It should be not NullObject - already checked in ProcessSTMLevel()
3438  
        } //End if the trigger binon exists
3439  
3440  
    } //End of CreateCombo()
3441  
3442  
    public final void ReportObjects1() {
3443  
3444  
        //Report information after perception and attention - before practice
3445  
        //Reports only the objects perceived in BinonDisplay.ChngResults
3446  
3447  
        String Res;
3448  
        String Ptrn;
3449  
        int ExprObj;
3450  
3451  
// --------------------------  Status of perception before attending to the stimuli --------------
3452  
3453  
        if (Processing50) {
3454  
            return;
3455  
        }
3456  
3457  
        World.appendBinonDisplayChngResults("\r\n" + "    # EObj Pattern - Fired Binon List" + "\r\n");
3458  
3459  
        Res = "";
3460  
        for ping (var J = 1; J <= HighestPerceptLvl; J++) {
3461  
            ExprObj = STM[J][BinId][Current];
3462  
            if (ExprObj != NullObject) {
3463  
                Ptrn = "";
3464  
                if (ExprObj == PerceivedBinon) //If we have an expected binon at this level then
3465  
                {
3466  
                    Ptrn += "  This is the Perceived or Performed Binon";
3467  
                }
3468  
                Res = Res + ("    " + J).substring(("    " + J).length() - 5) 
3469  
                  + vbToStr(Binons[ExprObj][TriggerCount])
3470  
                  + vbToStr(Binons[ExprObj][GoalCount])
3471  
                  + " " + DisplayPattern(ExprObj) + " " + Ptrn + "\r\n";
3472  
            }
3473  
        }
3474  
3475  
        World.appendBinonDisplayChngResults(Res + "\r\n");
3476  
3477  
    } //End ReportObjects1()
3478  
3479  
    public final void ReportObjects2() {
3480  
3481  
        //Report after Pass 2 - after prerceiving stimulus, doing response and expecting a stimulus
3482  
        //Reports on Objects in ObjList textbox
3483  
3484  
        StringBuilder Res2 = new StringBuilder();
3485  
        var Rdgs = new Var<>("");
3486  
        StringBuilder Res1;
3487  
        String Ptrn;
3488  
        String IntInfo;
3489  
        var VL = new Var<>("");
3490  
        var Ty1 = new Var<>("");
3491  
        var Ty2 = new Var<>("");
3492  
        //unused String BN = null;
3493  
        //unused String Brand = null;
3494  
        int BnTyp;
3495  
        int Objct;
3496  
        var BinTyp = new Var<>("");
3497  
        int ObjLvl;
3498  
        //unused int Prcpt;
3499  
        int TypInteger;
3500  
        String Inf = null;
3501  
3502  
// -------------------- The binon list after being processed ------------
3503  
3504  
        if (Processing50) {
3505  
            return;
3506  
        }
3507  
3508  
        //Fill in Binon list in BinonDisplay.ObjList.Text
3509  
        int NumChr;
3510  
3511  
        for ping (BnTyp = 1; BnTyp <= NumBinonTypes; BnTyp++) //Property binons and Percept combinations, Perceptual sequences and Responses
3512  
        {
3513  
            GetTypeInfo(BnTyp, BinTyp, Rdgs); //Rdgs$ = abbreviation - not used - use BinTyp$ only
3514  
            Res2.append(BnTyp).append(", ").append(Rdgs).append(BinTyp).append("\r\n");
3515  
3516  
            for ping (ObjLvl = 1; ObjLvl <= MaxLevels; ObjLvl++) //For each level of binons
3517  
            {
3518  
                Res1 = new StringBuilder();
3519  
3520  
                for ping (Objct = 1; Objct <= NumBinons; Objct++) //For all binons
3521  
                {
3522  
                    Ptrn = "";
3523  
3524  
                    if (Binons[Objct][OLv] == ObjLvl) //if have a binon at this level then
3525  
                    {
3526  
                        if (BinonTypeOf(Objct) == BnTyp) {
3527  
                            Inf = "";
3528  
                            VL.set("");
3529  
                            GetValue(Objct, VL);
3530  
                            NumChr = 5 + 6 * (Binons[Objct][OLv] - 1); //Level 2 is 11 characters, level 3 is 17 characters
3531  
                            Ptrn = substring(VL.get(), 0, NumChr); //display 14 chars of pattern
3532  
                            if ((Ptrn == null ? 0 : Ptrn.length()) == 1) {
3533  
                                Ptrn = " " + Ptrn;
3534  
                            }
3535  
                            TypInteger = BinonTypeOf(Binons[Objct][O1]);
3536  
                            GetTypeInfo(TypInteger, Ty1, Ty1);
3537  
                            TypInteger = BinonTypeOf(Binons[Objct][O2]);
3538  
                            GetTypeInfo(TypInteger, Ty2, Ty2);
3539  
                            IntInfo = InterestSymbol(Objct);
3540  
3541  
                            Res1.append(substring("    " + Objct, ("    " + Objct).length() - 3))
3542  
                              .append(substring(("  " + Binons[Objct][OLv]), ("  " + Binons[Objct][OLv]).length() - 3))
3543  
                              .append(AESR(Objct)).append(" ")
3544  
                              .append(substring(Ty1.get(), 0, 2))
3545  
                              .append(substring("    " + Binons[Objct][O1], ("    " + Binons[Objct][O1]).length() - 3))
3546  
                              .append(" ").append(substring(Ty2.get(), 0, 2))
3547  
                              .append(substring("    " + Binons[Objct][O2], ("    " + Binons[Objct][O2]).length() - 3))
3548  
                              .append(substring("    " + Binons[Objct][IDL], ("    " + Binons[Objct][IDL]).length() - 4))
3549  
                              .append(takeLast(2, vbToStr(Binons[Objct][TriggerCount])))
3550  
                              .append(takeLast(2, vbToStr(Binons[Objct][GoalCount])))
3551  
                              .append(substring("   " + IntInfo, ("   " + IntInfo).length() - 3))
3552  
                              .append(substring("   " + Binons[Objct][TQ], ("   " + Binons[Objct][TQ]).length() - 3))
3553  
                              .append(substring("   " + Binons[Objct][GQ], ("   " + Binons[Objct][GQ]).length() - 3))
3554  
                              //.append("*X*")
3555  
                              .append(" ").append(Ptrn).append("  ")
3556  
                              .append(DisplayHabit(Objct)).append("\r\n");
3557  
                        }
3558  
                    } //End if it is this Binon type
3559  
                }
3560  
                if (!StringHelper.isNullOrEmpty(Res1.toString())) {
3561  
                    Res2.append(Res1).append("\r\n");
3562  
                }
3563  
            }
3564  
            Res2.append("\r\n");
3565  
        }
3566  
3567  
        World.setBinonDisplayObjList(Res2.toString()); //value set above
3568  
3569  
    } //End of ReportObjects2()
3570  
3571  
    public final String AESR(int Objct) {
3572  
        String tempAESR;
3573  
3574  
        if (BinonTypeOf(Objct) <= NumPercepts) //AE property is 0 for parallel binons
3575  
        {
3576  
            tempAESR = "  P"; //Level 1 Percept or property binon
3577  
        } else {
3578  
            tempAESR = "  A"; //level 1 Response binon = LetrBin
3579  
        }
3580  
        if (Binons[Objct][AE] == Action) //AE not assigned for level 1 Stimuli or Responses
3581  
        {
3582  
            if (!isSorR(Objct)) //two letters refer to types/roles of source binons
3583  
            {
3584  
                tempAESR = "  A"; //Action binon
3585  
            } else {
3586  
                tempAESR = " AA"; //Action sequence
3587  
            }
3588  
        } else if (Binons[Objct][AE] == Attention) {
3589  
            if (!isSorR(Objct)) {
3590  
                tempAESR = "  E"; //Expectation binon
3591  
            } else {
3592  
                tempAESR = " PP"; //Perceptual sequence
3593  
            }
3594  
        }
3595  
3596  
        return tempAESR;
3597  
    } //End of AESR$()
3598  
3599  
    public final boolean isSorR(int Objct) {
3600  
3601  
        //If the binon is at an odd sequential level then it is either an S or R
3602  
        //If the binon is at an even sequential level then it is either an A or an E
3603  
        //If the binon is not sequential (an ActBin) then it is either an S or R
3604  
3605  
        //remainder is 1 if odd level, 0 if even level
3606  
        return Binons[Objct][OLv] % 2 == 1 || BinonTypeOf(Objct) != ActBin;
3607  
3608  
    }
3609  
3610  
    public final String DisplayHabit(int ObjBin) {
3611  
        StringBuilder tempDisplayHabit;
3612  
3613  
        //Displays the list of target binons for which this one is the left source and / or right source
3614  
3615  
        int Link;
3616  
        //unused int Bin = 0;
3617  
3618  
        tempDisplayHabit = new StringBuilder();
3619  
        //Display the list of target binons this one triggers
3620  
        Link = Binons[ObjBin][TriggerList]; //does the binon trigger at least one target binon
3621  
        while ping (Link != NullTarget) {
3622  
            //add target binon type and objID
3623  
            tempDisplayHabit.append("l").append(DisplayStimulu(Targets[Link][TargetBinon]));
3624  
            Link = Targets[Link][NLnk]; //go to the next one on the list
3625  
            if (Link != NullTarget) {
3626  
                tempDisplayHabit.append(", ");
3627  
            }
3628  
        }
3629  
3630  
        Link = Binons[ObjBin][GoalList]; //does the binon goal at least one target binon
3631  
        if (Link != NullObject && !StringHelper.isNullOrEmpty(tempDisplayHabit.toString())) {
3632  
            tempDisplayHabit.append(", ");
3633  
        }
3634  
        while ping (Link != NullTarget) {
3635  
            //add target binon type and objID
3636  
            tempDisplayHabit.append("r").append(DisplayStimulu(Targets[Link][TargetBinon]));
3637  
            Link = Targets[Link][NLnk]; //go to the next one on the list
3638  
            if (Link != NullTarget) {
3639  
                tempDisplayHabit.append(", ");
3640  
            }
3641  
        }
3642  
3643  
        return tempDisplayHabit.toString();
3644  
    } //End of DisplayHabit()
3645  
3646  
    public final void DetermineResponse() //Called from PerceptionAction()
3647  
    {
3648  
3649  
        //Enter here if finished pass 1/ STM processing then based on the recognized Perceptual sequence or Expectation find any
3650  
        //predicted action and use this highest level Action or Action sequence found worth doing and
3651  
        //do its lowest level response in PerformAction().
3652  
        //Or if the predicted action is learnt / familiar then use thinking (deduction) and find one worth doing
3653  
        //Put this response Action sequence in STM(level 1, Fired) and start pass 2
3654  
3655  
        int FirstLink;
3656  
        int Thinklink;
3657  
        int ThinkBinon;
3658  
        //unused int EndLink = 0;
3659  
        String Reason = null;
3660  
        //unused int GoalBinon = 0;
3661  
        //unused int TrigTargetBinon = 0;
3662  
        var PracticingBinon = new Var<>(0); //The binon being practiced. Concentration Level is based upon it.
3663  
        int DoneBinon;
3664  
        var NewBee = new Var<>(false);
3665  
        int OutType;
3666  
        int UL;
3667  
        int ll;
3668  
        int NextResponse;
3669  
        var ResponseBinon = new Var<>(0);
3670  
        int I;
3671  
        int CurrentResponse;
3672  
        int UseResponse;
3673  
        int HaveResponse;
3674  
        int NumberOfResponses;
3675  
        String ThisResponse = null;
3676  
3677  
        //FireTheBinon() will have found any response worth doing and PerceivedBinon will be the level
3678  
        //for the Perceptual sequence trigger to find the response to do.
3679  
3680  
        //The Practicing binon may be the NullObject because no Actions were being performed.
3681  
        //This happens when there are no Actions for the stimulus as the trigger.
3682  
        //This means no expectation. After a stimulus is familiar and the one following it is also familiar then
3683  
        //we have a novel Action for the trigger and at least have one expectation
3684  
3685  
        //Note: it should be just the perceived binon that is used based on any number >0 triggercount
3686  
        //the interest in redoing its most recent determines if need to practice it. triggercount=1 needed to
3687  
        //do deductions - certain / reliable inference, if >1 then just the most recent possible goal is used
3688  
        //and this gives induction reasoning - no certainty because sometime in the past at least one different goal has happened
3689  
3690  
        PracticingBinon.set(NullObject); //even after thinking then babble
3691  
        //If have a perceived binon (it is an Perceptual sequence) with associating Action binons then
3692  
        //check to see if it is worth doing - if not then think
3693  
        FirstLink = FloatingPointToInteger.ToInt32(MostRecentTriggerTargetLink(PerceivedBinon)); //The right target binon link - if any
3694  
        if (FirstLink != NullTarget) //If have a link to a recent right target Action binon then
3695  
        {
3696  
            PracticingBinon.set(Targets[FirstLink][TargetBinon]); //This must be an Action
3697  
            if (InterestIn(PracticingBinon.get()) > FAMILIAR) //If it is worth doing then
3698  
            {
3699  
                Reason = " STM Perceived binon is the trigger of its most recent novel Action";
3700  
                //use PracticingBinon below by calling ActivateAction()
3701  
            } else //else the binon is not worth practicing so think about it
3702  
            {
3703  
                //#1 Approach: ----------------------------
3704  
                //An alternate approach here is to go up the most recent right target binons of the tree
3705  
                //looking for an Action that is novel and if found then activate all the right targets traversed so
3706  
                //that the sequence is done at a concentration level to repeat / learn the novel one.
3707  
                //Let us just try one traversal up this right target binon tree via the intermediate Perceptual sequence.
3708  
                Thinklink = FloatingPointToInteger.ToInt32(MostRecentTriggerTargetLink(PracticingBinon.get())); //The right target binon link - if any
3709  
                //This will be an Perceptual sequence - but we need to go up one more level to the Action - if any
3710  
                if (Thinklink != NullTarget) //If there is a right target link to an associating binon then
3711  
                {
3712  
                    ThinkBinon = Targets[Thinklink][TargetBinon];
3713  
                    Thinklink = FloatingPointToInteger.ToInt32(MostRecentTriggerTargetLink(ThinkBinon)); //The right target Action binon link - if any
3714  
                } else //Else no right target Perceptual sequence binon
3715  
                {
3716  
                }
3717  
3718  
                //#2 Approach: ----------------------------
3719  
                //Obtain the response that could be performed and see if it triggers an Expectation (stimulus) worth expecting
3720  
//2          GoalBinon = Binons[PracticingBinon][O2]     'The goal that could be done - Action sequence
3721  
//2          Thinklink = MostRecentTriggerTargetLink(GoalBinon)  'Does it have a right target - an Expectation
3722  
//2          Reason$ = " Thought about associated goal of STM perceived is trigger of a most recent novel Expectation"
3723  
                // -----------------------------------------
3724  
3725  
                if (Thinklink != NullTarget) //If there is a right target link to an associating binon then
3726  
                {
3727  
                    ThinkBinon = Targets[Thinklink][TargetBinon]; //The Approach#1 Action or Approach#2 Expectation to practice
3728  
                    if (InterestIn(ThinkBinon) > FAMILIAR) //if the next A- or Expectation is worth expecting then
3729  
                    {
3730  
                        //there is a next Perceptual sequence to expect so do the current Action - PracticingBinon
3731  
                        //use PracticingBinon below by calling ActivateAction()
3732  
3733  
                        Reason = " Thought about right target of STM perceived is trigger of a most recent novel Action";
3734  
                    } else //Else the next Action sequence (goal of PracticingBinon) is not worth doing so
3735  
                    {
3736  
                        PracticingBinon.set(NullObject); //do not do the practicing binon - it is familiar / learnt
3737  
                    } //End if the next binon was worth doing
3738  
                } else //else there is no next possible stimulus - no associating Expectation so
3739  
                {
3740  
                    PracticingBinon.set(NullObject); //do not do the practicing binon - it is familiar / learnt
3741  
                } //End if there was no next Perceptual sequence to expect
3742  
            } //End if the associating Action (PracticingBinon) is worth doing
3743  
        } else //Else no right target link of PerceivedBinon - no PracticingBinon
3744  
        {
3745  
        } //End of Is there a right target link of Perceived binon
3746  
3747  
        //If don't have a binon to practice, even after thinking, then find something to do or babble
3748  
        if (PracticingBinon.get() == NullObject) //If the PracticingBinon is still a NullObject then
3749  
        {
3750  
            Reason = "";
3751  
            //If the Practicing Binon is null because the highest STM recognized Perceptual sequence (PerceivedBinon)
3752  
            //has no associating Action binons (is novel or familiar but followed by a novel binon) then
3753  
            //we do nothing to see if it repeats
3754  
            int DeviceNum;
3755  
            if (FirstLink == NullTarget) //If there is no associating binons for the perception
3756  
            {
3757  
                //so use the 1st device and its first symbolic or range response, PracticingBinon must be set
3758  
                DeviceNum = 1; //Letters = LetrBin
3759  
                OutType = Devices[DeviceNum][PropertyBinonType]; //Currently = Wheels for device #1
3760  
                if (Devices[DeviceNum][SymbolicOrMagnitude] == Magnitude) //Use Range of values
3761  
                {
3762  
                    NextResponse = Devices[DeviceNum][LowerRangeLimit];
3763  
                    //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
3764  
                    IdBinons(1, OutType, NullObject, 0, NullObject, 0, NextResponse, Parallel, 0, PracticingBinon, NewBee);
3765  
                } else //If Devices[DeviceNum][SymbolicOrMagnitude] = Symbolic Then 'Use first response values
3766  
                {
3767  
                    String Letter = DeviceResponses[DeviceNum].substring(0, 1); //Will be a NoResp$
3768  
//              Letter$ = NoResp$
3769  
                    //Create or find the binon for this symbolic value
3770  
                    //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
3771  
                    IdBinons(1, OutType, NullObject, 0, NullObject, 0, asc(Letter), Parallel, 0, PracticingBinon, NewBee);
3772  
                }
3773  
                Reason = " First response of first action device - Babbling";
3774  
3775  
            } else //else have an associating Action sequence for PerceivedBinon then
3776  
            {
3777  
                //Find the most recent response at the lowest level and use the next one
3778  
                DoneBinon = Targets[FirstLink][TargetBinon]; //The Action most recently practiced at the next level up
3779  
3780  
                //GetDHabit returns the lowest level response binon in ResponseBinon
3781  
                GetDHabit(DoneBinon, ResponseBinon); //Get the level 1 most recent response done
3782  
3783  
                DeviceNum = BinonTypes[BinonTypeOf(ResponseBinon.get())][SensOrDevNum]; //the device number for this response type binon
3784  
                if (Devices[DeviceNum][SymbolicOrMagnitude] == Magnitude) //Use Range of values
3785  
                {
3786  
                    ll = Devices[DeviceNum][LowerRangeLimit];
3787  
                    UL = Devices[DeviceNum][UpperRangeLimit];
3788  
                    if (Binons[ResponseBinon.get()][IDL] == NoResp) //If it is the no response then
3789  
                    {
3790  
                        NextResponse = ll;
3791  
                    } else {
3792  
                        NextResponse = Binons[ResponseBinon.get()][IDL] + 1;
3793  
                        if (NextResponse > UL) //if off end of valid values then
3794  
                        {
3795  
                            NextResponse = ll; //wrap around to start again
3796  
                        }
3797  
                    }
3798  
                    //Create or find the binon for this symbolic value
3799  
                    //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
3800  
                    IdBinons(1, BinonTypeOf(ResponseBinon.get()), NullObject, 0, NullObject, 0, NextResponse, Parallel, 0, PracticingBinon, NewBee);
3801  
                } else //If Devices[DeviceNum][SymbolicOrMagnitude] = Symbolic Then 'Use given response values
3802  
                {
3803  
                    //Find the last one used
3804  
                    CurrentResponse = 0;
3805  
                    NumberOfResponses = DeviceResponses[DeviceNum].length();
3806  
                    for ping (I = 1; I <= NumberOfResponses; I++) //go through the response string
3807  
                    {
3808  
                        if (Binons[ResponseBinon.get()][IDL] == asc(DeviceResponses[DeviceNum].substring(I - 1, I - 1 + 1))) {
3809  
                            CurrentResponse = I;
3810  
                            I = NumberOfResponses; //terminate the loop
3811  
                        }
3812  
                    }
3813  
                    //Find the next non "z" entry
3814  
                    UseResponse = CurrentResponse;
3815  
                    HaveResponse = 0; //will be set to the next response entry position
3816  
//                    'A random response generator
3817  
//            While HaveResponse = 0
3818  
//              UseResponse = Int(NumberOfResponses * Rnd + 1)  'generate a number between 1 and and NumberofResponses
3819  
//              ThisResponse$ = Mid$(DeviceResponses$(DeviceNum), UseResponse, 1)
3820  
//                    'if it is a response that can be done and not a repeat of the last one chosen then
3821  
//              If ThisResponse$ <> NoMoveOrTurn$ And UseResponse <> CurrentResponse Then
3822  
//                HaveResponse = UseResponse          'a non-zero value will terminate the loop
3823  
//              End If
3824  
//            Wend
3825  
                    //Sequentially go through the available responses
3826  
                    while ping (HaveResponse == 0) {
3827  
                        UseResponse = UseResponse + 1;
3828  
                        if (UseResponse > NumberOfResponses) //if off the end of the string then
3829  
                        {
3830  
                            UseResponse = 1; //start at the beginning again
3831  
                        }
3832  
                        ThisResponse = DeviceResponses[DeviceNum].substring(UseResponse - 1, UseResponse - 1 + 1);
3833  
                        if (!ThisResponse.equals(NoMoveOrTurn)) //if it is a response that can be done then
3834  
                        {
3835  
                            HaveResponse = UseResponse; //a non-zero value will terminate the loop
3836  
                        }
3837  
                    }
3838  
                    //Create or find the binon for this symbolic value
3839  
                    //IdBinons(OLvl, Prt, Obj1&, TQNum, Obj2&, GQNum, IDLRatio, SeqOrPar, ExpectIt, ObjId&, NewOne As Boolean)
3840  
                    IdBinons(1, BinonTypeOf(ResponseBinon.get()), NullObject, 0, NullObject, 0, asc(ThisResponse), Parallel, 0, PracticingBinon, NewBee);
3841  
3842  
                }
3843  
                Reason = " Babbling";
3844  
            } //End if have no associating Action sequence
3845  
3846  
        } else //Else have a binon to practice so do that one
3847  
        {
3848  
        } //End if do not have a PracticingBinon
3849  
3850  
        //Report on what is being practiced - if anything
3851  
        if (PracticingBinon.get() != NullObject) //If practicing then
3852  
        {
3853  
            World.appendBinonDisplayChngResults(" * Practicing " + DisplayPattern(PracticingBinon.get()) + Reason + "\r\n");
3854  
        } else {
3855  
            Stop();
3856  
            World.appendBinonDisplayChngResults(" * Not Practicing anything" + "\r\n");
3857  
        }
3858  
3859  
        //If have no action to practice at this point then PerformAction() will respond with nothing
3860  
        ActivateAction(PracticingBinon.get()); //Perform the response and fire the binon to STM(1, Fired)
3861  
3862  
3863  
//Old notes
3864  
//   If we are practicing (concentrating on) an Action then this active sequence will have a goal
3865  
//     that it is trying to achieve. This is the goal of the most recent target binon (Action) triggered by the
3866  
//     previously perceived/attended-to stimulus. It is the prediction, the expectation.
3867  
//     The concentration level will be based on the wanted / pleasant (desirability) level of the goal or
3868  
//     interest level (novel, interesting or familiar) of the redo interest of the Action being practiced.
3869  
//     When practicing / concentrating we will only attend to the expected goal of the Action being practiced.
3870  
//     All of the triggered target binons of the attended to stimulus are active / expecting but only the most recent one
3871  
//     is being practiced, goal expected.
3872  
//   If any expecting Action (including the one being practiced) does not get its expected goal then it becomes inactive.
3873  
//   The binon recognized (fired) instead will be on the Percepts() list and attract attention.
3874  
// Thus the possible outcomes are:
3875  
//     O1 - Get the expected goal of the practicing Action binon (PracticingResult$ = "Matched"
3876  
//     O2 - Get the goal of a different triggered Expecting target Action binon (same triggering / attended-to binon)
3877  
//     O3 - All expecting Actions could fail
3878  
//       O3a - get a familiar goal stimulus but it is a novel sequence for the attended-to as the trigger
3879  
//       O3b - get a novel or interesting stimulus at the AttendToLevel or lower.
3880  
// Note: you can be attending to a stimulus but not practicing because there are no right target Action binons
3881  
//       of the attended-to stimulus.
3882  
// Note: only target Sequence / Action binons can be performed / practiced - not target property binons
3883  
3884  
//If concentrating - no expecting binon got its goal so - Outcome O3
3885  
//   we find the "got-instead" goal
3886  
//   This "got-instead" goal binon is the one obtained instead of the expected goal
3887  
//   or if that is not available (a NullObject) then it is the next attended-to stimulus (the novel one produced).
3888  
3889  
// The logic should be:
3890  
//1  If practicing an Action then (PracticingResult$ will be set Matched or Failed)
3891  
//     When practicing an Action you are paying attention / focusing on / expecting a stimulus from sense of its goal
3892  
//2    If it matched its goal and the goal has finished repeating then focus / pay attention to its goal. [set as AttendTo]
3893  
//       Reduce its interest / novelty level.
3894  
//       Can not be distracted because paying attention to the goal sense (change blindness) and got the goal?
3895  
//       Or will any stimulus not expected by any of the other Actions (not being practiced) distract you? [set AttendTo]
3896  
//     else it failed to match / get the goal of the practicing binon so
3897  
//       the one being practiced stays at the same interest level.
3898  
//       The actual sequence experienced becomes the most recent one (but no change in its interest level).
3899  
//       Attention is paid to the stimulus "got-instead" of the goal at the same sense as the goal unless
3900  
//       there is a stimulus that distracts you from this. [set AttendTo]
3901  
//   Else not practicing so
3902  
//     Pay attention to the most interesting - attractive? stimulus [set AttendTo]
3903  
//   End
3904  
//
3905  
//'  The interest in a sequence is only reduced if it is the one being practiced and the goal is matched.
3906  
//'  What about another sequence that has the same trigger and its goal is expected but it is not the one being
3907  
//'    practiced but it is the one that is matched? It stays novel. If it becomes the most recent it will be practiced
3908  
//'    the next time its trigger occurs.
3909  
3910  
//           'If not practicing (e.g. due to a novel or interesting attended-to stimulus) then
3911  
//           '    Attend to the most attractive perception
3912  
//           '    If the attendto is novel or interesting, it can not be the left source for any target binons
3913  
//           '    and has no goals.
3914  
//           '    If the attendto is a novel Percept then we must remain not practicing (ConcentrationLevel = NoInterest).
3915  
//           '    If the attendto is an Action then pay attention to the goal stimulus that caused the novel
3916  
//           '      sequence. It will be familiar. Start practicing any
3917  
//           '  If the attendto is familiar then
3918  
//           '    use it as the trigger and its most recent sequential right target as an Action worth practicing.
3919  
//           '    Set the concentration level based on the wanted (pleasant) goal (must be familiar) or
3920  
//           '    the interest level of the most recent Action right target to practice.
3921  
//           '    Its goal is the expectation. That is what is being predicted.
3922  
//           '    If the interest / concentration level is familiar then use thinking to search for something
3923  
//           '      more interesting to do
3924  
//           '  end if
3925  
//           'end if
3926  
//
3927  
//'       If was practicing - failed or matched will have no AttendTo and Expected = goal set, PracticingBinon = NullObject
3928  
//'                         - repeating trigger or goal and not interrupted then PracticingBinon will be set
3929  
//'       If not practicing AttendTo is not set, PracticingBinon = NullObject and ExpectedBinon = NullObject
3930  
3931  
//' 10a. THINKING:
3932  
//'       If still no Action worth practicing then find one through thinking.
3933  
//'         Find an Action that will lead to one that needs practicing or that will produce a
3934  
//'         rewarding final goal stimulus.
3935  
//'         Pay attention to the goal stimulus of the most recent Action of the attended-to stimulus and
3936  
//'         treat it as though it was the attended-to stimulus and repeat steps 8 and 9 above.
3937  
//'         This is thinking of the goal by traversing the Actions for this stimulus as the trigger.
3938  
//'         This repeats until we come across an Action that has a desirable redo interest or
3939  
//'         a pleasant expected goal stimulus.
3940  
//'         There will be a limit on this looping to begin with. Some other criterion is required
3941  
//'         to stop this thinking. It must stop if it loops around to an already thought about Action.
3942  
//'         If it is successful the first thought about Action will be selected for performing in step 11
3943  
//'         as the active practicing Action at the appropriate concentration level.
3944  
//'         In a real-time system a thinking loop may continue until it is interrupted by an unexpected stimulus.
3945  
//'         Should the thinking loop also select additional Actions or should they only be started by a conscious stimulus?
3946  
//'         Where does boredom fit in - results from repetition of a conscious stimulus?
3947  
//'         Or if we have a limited number of thinking steps we may not find an Action worth doing.
3948  
//'         Should thinking be done after or before investigating the parts of the attended-to in step 9?
3949  
//'         Thinking is bas
3950  
[...]
3951  
3952  
3953  
3954  
3955  
3956  
3957  
3958  
3959  
3960  
3961  
3962  
3963  
3964  
3965  
3966  
3967  
3968  
3969  
3970  
3971  
3972  
3973  
3974  
3975  
3976  
3977  
3978  
3979  
3980  
3981  
3982  
3983  
3984  
3985  
3986  
3987  
3988  
3989  
3990  
3991  
3992  
3993  
3994  
3995  
3996  
3997  
3998  
3999  
4000  
4001  
4002  
4003  
4004  
4005  
4006  
4007  
4008  
4009  
4010  
4011  
4012  
4013  
4014  
4015  
4016  
4017  
4018  
4019  
4020  
4021  
4022  
4023  
4024  
4025  
4026  
4027  
4028  
4029  
4030  
4031  
4032  
4033  
4034  
4035  
4036  
4037  
4038  
4039  
4040  
4041  
4042  
4043  
4044  
4045  
4046  
4047  
4048  
4049  
4050  
4051  
4052  
4053  
4054  
4055  
4056  
4057  
4058  
4059  
4060  
4061  
4062  
4063  
4064  
4065  
4066  
4067  
4068  
4069  
4070  
4071  
4072  
4073  
4074  
4075  
4076  
4077  
4078  
4079  
4080  
4081  
4082  
4083  
4084  
4085  
4086  
4087  
4088  
4089  
4090  
4091  
4092  
4093  
4094  
4095  
4096  
4097  
4098  
4099  
4100  
4101  
4102  
4103  
4104  
4105  
4106  
4107  
4108  
4109  
4110  
4111  
4112  
4113  
4114  
4115  
4116  
4117  
4118  
4119  
4120  
4121  
4122  
4123  
4124  
4125  
4126  
4127  
4128  
4129  
4130  
4131  
4132  
4133  
4134  
4135  
4136  
4137  
4138  
4139  
4140  
4141  
4142  
4143  
4144  
4145  
4146  
4147  
4148  
4149  
4150  
4151  
4152  
4153  
4154  
4155  
4156  
4157  
4158  
4159  
4160  
4161  
4162  
4163  
4164  
4165  
4166  
4167  
4168  
4169  
4170  
4171  
4172  
4173  
4174  
4175  
4176  
4177  
4178  
4179  
4180  
4181  
4182  
4183  
4184  
4185  
4186  
4187  
4188  
4189  
4190  
4191  
4192  
4193  
4194  
4195  
4196  
4197  
4198  
4199  
4200  
4201  
4202  
4203  
4204  
4205  
4206  
4207  
4208  
4209  
4210  
4211  
4212  
4213  
4214  
4215  
4216  
4217  
4218  
4219  
4220  
4221  
4222  
4223  
4224  
4225  
4226  
4227  
4228  
4229  
4230  
4231  
4232  
4233  
4234  
4235  
4236  
4237  
4238  
4239  
4240  
4241  
4242  
4243  
4244  
4245  
4246  
4247  
4248  
4249  
4250  
4251  
4252  
4253  
4254  
4255  
4256  
4257  
4258  
4259  
4260  
4261  
4262  
4263  
4264  
4265  
4266  
4267  
4268  
4269  
4270  
4271  
4272  
4273  
4274  
4275  
4276  
4277  
4278  
4279  
4280  
4281  
4282  
4283  
4284  
4285  
4286  
4287  
4288  
4289  
4290  
4291  
4292  
4293  
4294  
4295  
4296  
4297  
4298  
4299  
4300  
4301  
4302  
4303  
4304  
4305  
4306  
4307  
4308  
4309  
4310  
4311  
4312  
4313  
4314  
4315  
4316  
4317  
4318  
4319  
4320  
4321  
4322  
4323  
4324  
4325  
4326  
4327  
4328  
4329  
4330  
4331  
4332  
4333  
4334  
4335  
4336  
4337  
4338  
4339  
4340  
4341  
4342  
4343  
4344  
4345  
4346  
4347  
4348  
4349  
4350  
4351  
4352  
4353  
4354  
4355  
4356  
4357  
4358  
4359  
4360  
4361  
4362  
4363  
4364  
4365  
4366  
4367  
4368  
4369  
4370  
4371  
4372  
4373  
4374  
4375  
4376  
4377  
4378  
4379  
4380  
4381  
4382  
4383  
4384  
4385  
4386  
4387  
4388  
4389  
4390  
4391  
4392  
4393  
4394  
4395  
4396  
4397  
4398  
4399  
4400  
4401  
4402  
4403  
4404  
4405  
4406  
4407  
4408  
4409  
4410  
4411  
4412  
4413  
4414  
4415  
4416  
4417  
4418  
4419  
4420  
4421  
4422  
4423  
4424  
4425  
4426  
4427  
4428  
4429  
4430  
4431  
4432  
4433  
4434  
4435  
4436  
4437  
4438  
4439  
4440  
4441  
4442  
4443  
4444  
4445  
4446  
4447  
4448  
4449  
4450  
4451  
4452  
4453  
4454  
4455  
4456  
4457  
4458  
4459  
4460  
4461  
4462  
4463  
4464  
4465  
4466  
4467  
4468  
4469  
4470  
4471  
4472  
4473  
4474  
4475  
4476  
4477  
4478  
4479  
4480  
4481  
4482  
4483  
4484  
4485  
4486  
4487  
4488  
4489  
4490  
4491  
4492  
4493  
4494  
4495  
4496  
4497  
4498  
4499  
4500  
4501  
4502  
4503  
4504  
4505  
4506  
4507  
4508  
4509  
4510  
4511  
4512  
4513  
4514  
4515  
4516  
4517  
4518  
4519  
4520  
4521  
4522  
4523  
4524  
4525  
4526  
4527  
4528  
4529  
4530  
4531  
4532  
4533  
4534  
4535  
4536  
4537  
4538  
4539  
4540  
4541  
4542  
4543  
4544  
4545  
4546  
4547  
4548  
4549  
4550  
4551  
4552  
4553  
4554  
4555  
4556  
4557  
4558  
4559  
4560  
4561  
4562  
4563  
4564  
4565  
4566  
4567  
4568  
4569  
4570  
4571  
4572  
4573  
4574  
4575  
4576  
4577  
4578  
4579  
4580  
4581  
4582  
4583  
4584  
4585  
4586  
4587  
4588  
4589  
4590  
4591  
4592  
4593  
4594  
4595  
4596  
4597  
4598  
4599  
4600  
4601  
4602  
4603  
4604  
4605  
4606  
4607  
4608  
4609  
4610  
4611  
4612  
4613  
4614  
4615  
4616  
4617  
4618  
4619  
4620  
4621  
4622  
4623  
4624  
4625  
4626  
4627  
4628  
4629  
4630  
4631  
4632  
4633  
4634  
4635  
4636  
4637  
4638  
4639  
4640  
4641  
4642  
4643  
4644  
4645  
4646  
4647  
4648  
4649  
4650  
4651  
4652  
4653  
4654  
4655  
4656  
4657  
4658  
4659  
4660  
4661  
4662  
4663  
4664  
4665  
4666  
4667  
4668  
4669  
4670  
4671  
4672  
4673  
4674  
4675  
4676  
4677  
4678  
4679  
4680  
4681  
4682  
4683  
4684  
4685  
4686  
4687  
4688  
4689  
4690  
4691  
4692  
4693  
4694  
4695  
4696  
4697  
4698  
4699  
4700  
4701  
4702  
4703  
4704  
4705  
4706  
4707  
4708  
4709  
4710  
4711  
4712  
4713  
4714  
4715  
4716  
4717  
4718  
4719  
4720  
4721  
4722  
4723  
4724  
4725  
4726  
4727  
4728  
4729  
4730  
4731  
4732  
4733  
4734  
4735  
4736  
4737  
4738  
4739  
4740  
4741  
4742  
4743  
4744  
4745  
4746  
4747  
4748  
4749  
4750  
4751  
4752  
4753  
4754  
4755  
4756  
4757  
4758  
4759  
4760  
4761  
4762  
4763  
4764  
4765  
4766  
4767  
4768  
4769  
4770  
4771  
4772  
4773  
4774  
4775  
4776  
4777  
4778  
4779  
4780  
4781  
4782  
4783  
4784  
4785  
4786  
4787  
4788  

full source  download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031138
Snippet name: Smarty AI Include
Eternal ID of this version: #1031138/86
Text MD5: 3c36ba3d673e4a46578173deb82d837c
Author: stefan
Category: javax / smarty
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-27 23:42:05
Source code size: 239042 bytes / 4788 lines
Pitched / IR pitched: No / No
Views / Downloads: 201 / 1061
Version history: 85 change(s)
Referenced in: [show references]