codesimian
Interface CodeSimian

All Known Implementing Classes:
Above, AbsoluteValue, Add, AddParam, AddressShape, AddressShape.Fractal, AddressShape.Linear, AddressShape.Root, ArcSin, Ask, BayesNet, BayesNode, BayesNode.VerifyCountP, BayesNodeDependence, BayesNodePredictError, BayesNodeUpdate, BeforeExec, Binary, ButtonCS, ClassObject, ColorCS, CommandLine, CompareNumbers, CompareNumbers.EqualB, CompareNumbers.EqualC, CompareNumbers.EqualD, CompareNumbers.EqualF, CompareNumbers.EqualI, CompareNumbers.EqualJ, CompareNumbers.EqualS, CompareNumbers.EqualZ, CompareNumbers.LessB, CompareNumbers.LessC, CompareNumbers.LessD, CompareNumbers.LessEqualB, CompareNumbers.LessEqualC, CompareNumbers.LessEqualD, CompareNumbers.LessEqualF, CompareNumbers.LessEqualI, CompareNumbers.LessEqualJ, CompareNumbers.LessEqualS, CompareNumbers.LessF, CompareNumbers.LessI, CompareNumbers.LessJ, CompareNumbers.LessS, CompareNumbers.MoreB, CompareNumbers.MoreC, CompareNumbers.MoreD, CompareNumbers.MoreEqualB, CompareNumbers.MoreEqualC, CompareNumbers.MoreEqualD, CompareNumbers.MoreEqualF, CompareNumbers.MoreEqualI, CompareNumbers.MoreEqualJ, CompareNumbers.MoreEqualS, CompareNumbers.MoreF, CompareNumbers.MoreI, CompareNumbers.MoreJ, CompareNumbers.MoreS, CompareNumbers.NotEqualB, CompareNumbers.NotEqualC, CompareNumbers.NotEqualD, CompareNumbers.NotEqualF, CompareNumbers.NotEqualI, CompareNumbers.NotEqualJ, CompareNumbers.NotEqualS, CompareNumbers.NotEqualZ, Compile, Compile.CompilerPipeline, Compile.LParenSymbol, Compile.MyFuelSymbol, Compile.NameSymbol, Compile.ParseObjects, Compile.ParseObjectsByPriority, Compile.RParenSymbol, Compile.SimpleCompiler, Compile.SmallSymbol, Compile.Symbol, Compile.TokenizeCode, Compile.TokensToObjects, Compile.WhitespaceSymbol, Const, Const.ConstByte, Const.ConstDouble, Const.ConstFalse, Const.ConstFloat, Const.ConstInt, Const.ConstShort, Const.ConstTrue, Const.ConstWithUselessParams, ContinuousBayesNode, CopyParams, CopyParamToParam, Count, CS, DeepCopy, DefaultCS, Delay, DeleteParam, DieSpam, DieSpam.ButtonClicked, Divide, EqualP, EqualRecurse2, Err, EvolveCode, Exec, Exec.Calc, Exec.CalcFuel, Exec.CalcFuelNan, Exec.CalcFuelNanNoPrev, Exec.CalcFuelNoPrev, Exec.CalcNan, Exec.CalcNanNoPrev, Exec.CalcNoPrev, Exec.Fuel, Exec.FuelNan, Exec.FuelNanNoPrev, Exec.FuelNoPrev, Exec.Nan, Exec.NanNoPrev, Exec.NoPrev, Exec.SetPrevExecButNeverUseIt, ExecParam, FileOfShorts, FileOrURL, Files.LoadCSFromFile, Files.SaveCSToFile, Files.TextFileWriter, FList, FTime, Function, GetJavaCompiler, GetResource, GraphSeq, GraphSeq.FastUnordered, GUI, HumanTypesCommand, IfElse, ImageCS, ImagePixels, IndentCode, IndependentCS, InternalFiles.AllInternalFileNames, InternalFiles.DeleteInternalFile, InternalFiles.GetInternalFile, InternalFiles.SetInternalFile, Interpolate, InterpretText, InterpretText.AllLetterPairs, InterpretText.AllLetterTriples, InterpretText.Concat, InterpretText.Normalize, InterpretText.SelectIndexs, InterpretText.Str, InterpretText.WordIndexs, InterpretText.WordPairDistance, InterpretText.WrapAroundSmallerRangeAndAverageOverlappingValues, InvokeMethod, Jars.JarTest, Jars.SaveUpdatedSelf, JavaMethod2, JavaObject, JavaType, JavaTypeConst, Keyboard, Keyboard.KeyDown, Keyboard.KeyUp, Layout, ListFindIndexFast, ListOfStringsGUI, Log, Logic, Logic.And, Logic.Not, Logic.Or, Logic.Xor, Loop, Loop.DynamicLoop, Loop.DynamicLoop.DynamicForLoop, Loop.DynamicLoop.DynamicRepeatLoop, Loop.DynamicLoop.DynamicWhileLoop, Loop.ForEach, Loop.StaticLoop, Loop.StaticLoop.StaticForLoop, Loop.StaticLoop.StaticRepeatLoop, Max, Median, Microphone, Min, Mod, MouseNumberList, MousePanel, MoveMouse, Multiply, N, NatLangType, NaturalLanguage.RemoveEverythingExceptLetters, Neg, Network, New, NothingList, Num, Object3d, ParamCount, PNewInstance, Pow, PrimitiveArray, PrimitiveArray.ByteArray, PrimitiveArray.IntArray, Ptr, Ptr.FieldPtr, Ptr.IndividualPtrs, Ptr.Null, Ptr.ParamPtr, Ptr.PtrSet, RandGaussian, RandomExampleCode, RandomlyCombineCode, RandomNeuron, RandRange, RecurseP, RecurseP.RecursePD, ReflectedFunctions.addP, ReflectedFunctions.addPx, ReflectedFunctions.addPxx, ReflectedFunctions.addPxxx, ReflectedFunctions.addPxxxx, ReflectedFunctions.B, ReflectedFunctions.BForProxy, ReflectedFunctions.C, ReflectedFunctions.CForProxy, ReflectedFunctions.cost, ReflectedFunctions.countP, ReflectedFunctions.D, ReflectedFunctions.decrementMyFuel, ReflectedFunctions.deleteP, ReflectedFunctions.deletePx, ReflectedFunctions.description, ReflectedFunctions.DForProxy, ReflectedFunctions.equals, ReflectedFunctions.F, ReflectedFunctions.FForProxy, ReflectedFunctions.fuel, ReflectedFunctions.getClass, ReflectedFunctions.getExec, ReflectedFunctions.getObject, ReflectedFunctions.hashCode, ReflectedFunctions.heap, ReflectedFunctions.I, ReflectedFunctions.IForProxy, ReflectedFunctions.indexP, ReflectedFunctions.indexPName, ReflectedFunctions.insertB, ReflectedFunctions.insertC, ReflectedFunctions.insertD, ReflectedFunctions.insertF, ReflectedFunctions.insertI, ReflectedFunctions.insertJ, ReflectedFunctions.insertL, ReflectedFunctions.insertL1, ReflectedFunctions.insertLx, ReflectedFunctions.insertP, ReflectedFunctions.insertS, ReflectedFunctions.insertZ, ReflectedFunctions.J, ReflectedFunctions.javaCode, ReflectedFunctions.JForProxy, ReflectedFunctions.keyword, ReflectedFunctions.L, ReflectedFunctions.LForProxy, ReflectedFunctions.LForProxyx, ReflectedFunctions.Lx, ReflectedFunctions.maxP, ReflectedFunctions.minP, ReflectedFunctions.myFuel, ReflectedFunctions.name, ReflectedFunctions.newInstance, ReflectedFunctions.notify, ReflectedFunctions.notifyAll, ReflectedFunctions.P, ReflectedFunctions.parent, ReflectedFunctions.parsePriority, ReflectedFunctions.PB, ReflectedFunctions.PC, ReflectedFunctions.PD, ReflectedFunctions.PF, ReflectedFunctions.PI, ReflectedFunctions.PJ, ReflectedFunctions.PL, ReflectedFunctions.prevB, ReflectedFunctions.prevC, ReflectedFunctions.prevD, ReflectedFunctions.prevF, ReflectedFunctions.prevI, ReflectedFunctions.prevJ, ReflectedFunctions.prevL, ReflectedFunctions.prevS, ReflectedFunctions.prevZ, ReflectedFunctions.PS, ReflectedFunctions.PType, ReflectedFunctions.PZ, ReflectedFunctions.S, ReflectedFunctions.setB, ReflectedFunctions.setBx, ReflectedFunctions.setC, ReflectedFunctions.setCost, ReflectedFunctions.setCx, ReflectedFunctions.setD, ReflectedFunctions.setDescription, ReflectedFunctions.setDx, ReflectedFunctions.setExec, ReflectedFunctions.setF, ReflectedFunctions.setFuel, ReflectedFunctions.setFx, ReflectedFunctions.setHeap, ReflectedFunctions.setI, ReflectedFunctions.setIx, ReflectedFunctions.setJ, ReflectedFunctions.setJx, ReflectedFunctions.setL, ReflectedFunctions.setL1, ReflectedFunctions.setLx, ReflectedFunctions.setLxx, ReflectedFunctions.setMyFuel, ReflectedFunctions.setName, ReflectedFunctions.setObject, ReflectedFunctions.setP, ReflectedFunctions.setParent, ReflectedFunctions.setParsePriority, ReflectedFunctions.setPrevExec, ReflectedFunctions.setPType, ReflectedFunctions.setS, ReflectedFunctions.setSx, ReflectedFunctions.setZ, ReflectedFunctions.setZx, ReflectedFunctions.SForProxy, ReflectedFunctions.toString, ReflectedFunctions.V, ReflectedFunctions.VForProxy, ReflectedFunctions.wait, ReflectedFunctions.waitx, ReflectedFunctions.waitxx, ReflectedFunctions.Z, ReflectedFunctions.ZForProxy, ReflectJavaClass, Reverse, RoundToInt, S, ScreenPixels, Scroll, SelfPredictingPrimeHashingNumberList, SetEqual, SetEqual.EqualP, SetEqual.SetB, SetEqual.SetC, SetEqual.SetD, SetEqual.SetF, SetEqual.SetI, SetEqual.SetJ, SetEqual.SetL, SetEqual.SetS, SetEqual.SetZ, SetParam, Sets.UnionOfSets, SimpleBayesNet, SimpleBayesNet.BayesNodeIndependentChildsDependentParent, SimpleBayesNet.Test, SimpleNeuralNode, SimpleNeuralNode.ChainSimpleNeuralNodesTogether, SimpleNeuralNode.WordStringsToNodes, Sine, SlideBar, SlideBarReacts, SlowMP3, Sound, SoundQuality, SpamData, SplitPane, Squares, Stacks.Peek, Stacks.Pop, Stacks.Push, Stacks.StackSize, Static.DefaultExec, Static.DefaultList, Static.DefaultStack, Static.SingletonList, Strings.PrintCS, Strings.PrintNumber, Strings.PrintString, Strings.ReadChar, Strings.StringSplit, Strings.TokenizeAllCharPairs, TextAreaCS, TimerCS, ToStr, TradeCalcExec, TreeList, TreeOfCode, TreeOfCodeGUI, TreeType, Try, Try.CatchException, Try.CatchOther, Try.CatchThrowable, TypeCheckedList, Valid, View2d, View3d, WeightedAverage, WholeMP3, WindowCS

public interface CodeSimian

CodeSimian is not yet (but will be) the root of the CodeSimian software. Next is CS, then DefaultCS and IndependentCS, then most of the other classes descending from DefaultCS.

CodeSimian is a small interface, and CS is a large class with no variables (only functions). CS has lots of functions for approximately the same thing, each with a different return type and other options. Example: CodeSimian has insertL(int,Object) but CS also has insertF(int,float) insertP(int,CS) insertZ(int,boolean) etc. insertL(int,Object) can do all of those. For primitives, use Objects like new java.lang.Float(1334f).

I plan to make a class that converts a CodeSimian to a CS, like this:
CodeSimian a = ...;
CS b = new CodeSimianToCS(a);

All functions in CS can be REFLECTED through CodeSimian's fewer more-general functions.
Its much easier to connect CodeSimian software (not CodeSimian.java) to external software if you only have to implement 1 interface (CodeSimian.java) instead of extend a class, because you can take the most important classes in your software and make them all implement the interface. You dont have to build a separate wrapper-class. You build the wrapper in. Or if you have more time, it might work better to build a subclass of CS.java (or easier: DefaultCS.java).



CodeSimian.java was made by copy/pasting code from codesimian2.java and L.java, which will be removed, but first their javadoc needs to be copied to this file and modified to read well together.

---------------------BELOW IS codesimian2.java's javadoc---------------------

This is the root interface of all of CodeSimian. Theoretically, anything that any subclass of CodeSimian can do, this class can do.

THE MAIN HEIRARCHY IS:
CodeSimian --> L --> CS --> (DefaultCS and IndependentCS) --> ...

All functions in this class do the same thing, but in different ways for convenience and sometimes for a little more efficiency. They can theoretically reflect any Java function, combinations of CodeSimian objects, or anything else, or can be a general interface to anything.

Reflect whats real and/or reflect anything you can create a consistent illusion of. The ILLUSIONS are most useful for artificial-intelligence (AI) and artificial-life (ALIFE).


DETAILS OF THE HEIRARCHY:

CodeSimian --> L --> CS --> (DefaultCS and IndependentCS) --> ...

CodeSimian is the simplest possible thing that can use all other programs.

L is the next simplest (than CodeSimian), and adds much efficiency for LISTS and COMPOSITES (things that contain things recursively).

CS is more practical (than L) because it has many more functions for LISTS and COMPOSITES multiplied by all Java primitives objects and arrays. For each important function, there are approximately 10 parallel functions, 1 for each type of thing: Java primitives objects and array. Thats for efficiency of using those different parts of Java. CS has no variables (to use less memory).

DefaultCS is practical enough to extend (create a superclass of) in less than 1 minute. Most subclasses of CodeSimian are subclasses of DefaultCS. DefaultCS is big and often has variables that are never used. Each DefaultCS is approximately 70 bytes in memory (my best guess 7/06, I have not measured).

IndependentCS is parallel to DefaultCS (both extend CS), and has NO VARIABLES and no behaviors. All functions return the IndependentCS they're called from, 0, false, or null. IndependentCS is necessary to solve some technical problems related to creating the first few CS objects.


FUZZY: One of the more frustrating things about CodeSimians, Ls, and any subclass, is that you can find some of the things it contains, but other things are hidden until you know EXACTLY what you're looking for. CodeSimian is intentionally designed this way because forcing an Object to be able to describe itself perfectly causes unnecessary restrictions. I choose freedom over certainty. CodeSimian is FUZZY.

---------------------BELOW IS L.java's javadoc---------------------

L is almost the root interface of CodeSimian (second to CodeSimian itself). Its 1 of the only 2 .java files higher than CS.java.

Think of L as the superclass of CS. L is an interface (not a class and therefore not a superclass) because interface is more flexible than a class. CS is a class (not an interface) because classes are faster than interfaces (30% faster last time I tested it).

If you're making a program that uses CodeSimian and you want it to be simpler (at the cost of being slower) then use CSs as Ls (or simpler: as CodeSimians) instead of CSs. Every CS is also an L (and therefore a CodeSimian), and has many more functions than a pure L.

L is much smaller and simpler than CS, but can theoretically do anything a CS can do.
For example: someCS.setFuel(new N(50)) -or- someL.setL("fuel",new N(50))
Ls have no fuel() or setFuel(). They have to use L(Object) and setL(Object,Object) to do those things that a CS has a natural ability to do, like this:
someL.L("fuel") -and- someL.setL("fuel",someCS)

The reason this works is that every CS has all L functions and those functions are supposed to call all the other functions if given those function's names (or abbreviations).

L has some non-L functions (like deleteP(int,int)) because they are necessary to use an L as a list of Ls. deleteP(int,int) removes 1 or more things from any part of the list. But functions like countP() must be used this way: ((Number) someL.L("countP")).intValue();
someL.L("countP") returns a Number because Number is Java's wrapper for primitives, and CS.countP() returns an int primitive.

FUZZY:

One of the more frustrating things about CodeSimians, Ls, and any subclass, is that you can find some of the things it contains, but other things are hidden until you know EXACTLY what you're looking for. Example: a CS may choose to accept any String with an odd number of 'x' chars.

Since there are an infinite number of Strings like that (abxc abxxxc abxxxxxc...), all things that have a name can not be put into a list because that list would have infinite size.

CodeSimian is intentionally designed this way because forcing an Object to be able to describe itself perfectly causes unnecessary restrictions. I choose freedom over certainty. CodeSimian is FUZZY.

See Also:
CS

Method Summary
 boolean deleteP(int startIndex, int indexQuantity)
           
 boolean insertL(int startIndex, java.lang.Object value)
           
 boolean insertL1(int singleIndex, java.lang.Object value)
           
 java.lang.Object L(int startIndex, java.lang.Object key, int indexQuantity)
           
 java.lang.Object L(java.lang.Object key)
          common keys have type Class (try to cast to that type), Number (return something from index Number.intValue()), or String (return something with that name, often has an int index too)
 java.lang.Object reflect(java.lang.Object[] nameAndParameters)
          Calls any function by reflection, including reflective functions on higher levels, reflection of reflection of reflection...
 java.lang.Object reflect(java.lang.String name, java.lang.Object[] parameters)
          same as reflect(Object[]) except the array is 1 smaller, and all indexs are 1 lower, and the first element which was taken out is String name,

This function is useful because it can use the same array as java.lang.reflect.Method.invoke(Object[]); Name should equal java.lang.reflect.Method.getName() of some Java function (Method).
 boolean setL(int startIndex, java.lang.Object value)
           
 boolean setL(int startIndex, java.lang.Object value, int indexQuantity)
           
 boolean setL(java.lang.Object key, java.lang.Object value)
           
 boolean setL1(int singleIndex, java.lang.Object value)
           
 void voidReflect(java.lang.Object[] returnAndNameAndParameters)
          Same as reflect(Object[]) except the array is 1 bigger, and returnAndNameAndParameters[0] is replaced by the return-value of the reflected function being called, and all indexs are 1 higher.
 

Method Detail

L

java.lang.Object L(java.lang.Object key)
common keys have type Class (try to cast to that type), Number (return something from index Number.intValue()), or String (return something with that name, often has an int index too)


L

java.lang.Object L(int startIndex,
                   java.lang.Object key,
                   int indexQuantity)

setL

boolean setL(int startIndex,
             java.lang.Object value,
             int indexQuantity)

setL

boolean setL(int startIndex,
             java.lang.Object value)

setL

boolean setL(java.lang.Object key,
             java.lang.Object value)

setL1

boolean setL1(int singleIndex,
              java.lang.Object value)

insertL1

boolean insertL1(int singleIndex,
                 java.lang.Object value)

insertL

boolean insertL(int startIndex,
                java.lang.Object value)

deleteP

boolean deleteP(int startIndex,
                int indexQuantity)

reflect

java.lang.Object reflect(java.lang.Object[] nameAndParameters)
Calls any function by reflection, including reflective functions on higher levels, reflection of reflection of reflection...

        THE FOLLOWING CODE NEEDS TO BE CHECKED FOR RECURSIVE ARRAY ERRORS...
        

//These 4 examples do the same thing, but with increasing levels of reflection... Boolean setLReturnedTrue1 = new Boolean( someCS.setL(2,"countP",3) ); Boolean setLReturnedTrue2 = (Boolean) someL.reflect( new Object[]{"setL", new Integer(2), "countP", new Integer(3)} ); Boolean setLReturnedTrue3 = (Boolean) someL.reflect( new Object[]{ "reflect", new Object[]{"setL", new Integer(2), "countP", new Integer(3)} } ); Boolean setLReturnedTrue4 = (Boolean) someL.reflect( new Object[]{ "reflect", new Object[]{ "reflect", new Object[]{"setL", new Integer(2), "countP", new Integer(3)} } } ); Boolean setLReturnedTrue5 = (Boolean) someL.reflect( new Object[]{ "reflect", new Object[]{ "reflect", new Object[]{ "reflect", new Object[]{"setL", new Integer(2), "countP", new Integer(3)} } } } ); //Infinite reflection...


If this L is a CS, it should also reflect the functions in CS.

The easiest and most general way to do this is by using the java.lang.reflect package, but


reflect

java.lang.Object reflect(java.lang.String name,
                         java.lang.Object[] parameters)
same as reflect(Object[]) except the array is 1 smaller, and all indexs are 1 lower, and the first element which was taken out is String name,

This function is useful because it can use the same array as java.lang.reflect.Method.invoke(Object[]); Name should equal java.lang.reflect.Method.getName() of some Java function (Method).


voidReflect

void voidReflect(java.lang.Object[] returnAndNameAndParameters)
Same as reflect(Object[]) except the array is 1 bigger, and returnAndNameAndParameters[0] is replaced by the return-value of the reflected function being called, and all indexs are 1 higher.

This is useful if you want to store everything about a function-call together in 1 array.

EFFICIENCY: Depending on the object, reflect(Object[]) or voidReflect(Object[]) may be a little more efficient than the other, even though they do the same thing, because usually reflect calls voidReflect or voidReflect calls reflect.

        //USE THIS CODE IF YOU'RE LAZY (interfaces cant contain code):  
        public void voidReflect(Object returnAndNameAndParameters[]){
                Object nameAndParams[] = new Object[returnAndNameAndParameters.length-1];
                //Insert code here to modify nameAndParams, if you want.
                System.arraycopy(nameAndParams, 0, returnAndNameAndParameters, 1, nameAndParams.length);
                returnAndNameAndParameters[0] = reflect(nameAndParams);
        }