473,327 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Self-Rejuvenating Immortal Artificial Intelligence

http://www.scn.org/~mentifex/jsaimind.html is a free, public-domain AI
in JavaScript that may be copied to your Web site with your own changes.

Freshly updated and modified from the AI Mind-1.1 appearing in
http://isbn.nu/0595654371 -- AI4U textbook of artificial intelligence --
the new AI Mind forgets its oldest unused memories in order to make
room for memories of fresh experience, and is therefore immortal.

Interested parties may start the immortal AI Mind running in the
Microsoft Internet Explorer Web browser and see how long it lives.

When you go out to lunch, leave the AI Mind running on your PC
and see what reactions you get from others when you return.

Any Chief Web Officer (CWO) or JavaScript programmer may customize
the free AI source code and install it anew as a chaotic attractor.

http://victoria.tc.ca/~uj797/jsaimind.html is another Seed AI. Have fun.
Jul 20 '05 #1
5 2268
Arthur T. Murray:
Freshly updated and modified from the AI Mind-1.1 appearing in
http://isbn.nu/0595654371 -- AI4U textbook of artificial intelligence --
the new AI Mind forgets its oldest unused memories in order to make
room for memories of fresh experience, and is therefore immortal.


Designed to forget? Immortal? Sounds more like ephemeral.

Cheers,
Michael C Price
----------------------------------------
http://mcp.longevity-report.com
http://www.hedweb.com/manworld.htm
Jul 20 '05 #2
uj***@victoria.tc.ca (Arthur T. Murray) wrote in message news:<41******@news.victoria.tc.ca>...
Interested parties may start the immortal AI Mind running in the
Microsoft Internet Explorer Web browser and see how long it lives.


Why not a decent browser like Mozilla?

--
Dan
Jul 20 '05 #3
uj***@victoria.tc.ca (Arthur T. Murray) wrote:
http://www.scn.org/~mentifex/jsaimind.html is a free, public-domain AI
in JavaScript that may be copied to your Web site with your own changes. Freshly updated and modified from the AI Mind-1.1 appearing in
http://isbn.nu/0595654371 -- AI4U textbook of artificial intelligence --
the new AI Mind forgets its oldest unused memories in order to make
room for memories of fresh experience, and is therefore immortal. Interested parties may start the immortal AI Mind running in the
Microsoft Internet Explorer Web browser and see how long it lives. When you go out to lunch, leave the AI Mind running on your PC
and see what reactions you get from others when you return. Any Chief Web Officer (CWO) or JavaScript programmer may customize
the free AI source code and install it anew as a chaotic attractor. http://victoria.tc.ca/~uj797/jsaimind.html is another Seed AI. Have fun.


Anyone contemplating participating should probably read this first:

http://www.nothingisreal.com/mentifex_faq.html

FYI

xanthian.
Jul 20 '05 #4
Arthur T. Murray wrote:
http://www.scn.org/~mentifex/jsaimind.html is a free,
public-domain AI in JavaScript
Scripts that are expected to execute in a web browser environment need
to be written with a consideration of that environment. Some
considerations are common to many programming projects, others directly
follow from the choice of a browser as an environment. A factor that is
common to both is the use of global variables. Common principles that
are applied to programming (and certainly applicable to javascript
programming) are: 1. never give a variable more scope than it needs, 2.
never create more global variables than are absolutely necessary.

The second follows form the first to some extent, but is very important
in a web browser environment as most browser scripts do not get used in
isolation. They share the global scope with all other scripts used on a
given page, and anything that the browser decides should be available as
a property of the global object (which includes all HTML elements that
are given a name or an ID attribute in Internet Explorer). The risk of
naming collisions is real and should be directly addressed in script
design.

When a script declares 90 global variables, but does not declare one
function local variable, then the design of that script seems
ill-conceived form the outset. A perception that is re-enforced by that
observation that, for example, the variable - c - is declared globally
but is only used within one function, where the first reference to it
assigns it a - keyCode - value form an - event - object.

This mass of global variables seems to be being partly employed in place
of passing functions arguments as parameters. A strange design decision
that results in code that is excessively convoluted, repetitive and
difficult to follow. Code that will eventually exceed its creator's
ability to comprehend its complexity, and may already have done so. A
global variable is declared as:-

| var midway = 0; // audRecog: a stopping point for backward searches.

- and used to limit various loop statements such as:-

| for (i = t; i > midway; --i) { // loop backwards through time
| audMemory[i].audExam(); // activate auditory engram nodes
| audMemory[i] = new audNode(aud0,0,aud2,aud3,aud4,aud5);
| } // End of cycling back to the loosely "midway" time-point.

Yet the - midway - variable is never incremented, decremented or
assigned a value. It remains zero throughout the execution of the code.
Whatever concept the name "midway" was chosen to represent has become
lost in the spaghetti if indirect references, and its actual use in
place of the value zero is also concealing the possibility of using more
efficient looping constructs such as:-

if((i = t) > 0){
do{
... // loop body
}while(i--);
}

Another important factor in the design of a browser script is its
efficiency. In addition to executing scripts, web browsers have a mass
of other tasks that they need to do, such as maintaining and refreshing
the display, processing user input, and the like. Usually a long running
script will seriously inhibit those processes. Breaking long script
execution up using setTimout or event driven execution helps to allow
the browser to keep up with its required house-keeping tasks but it is
still necessary to code efficiently.

This script is so intensive when it is executing that the browser GUI
virtually grinds to a halt. As a result it is worth considering the
extent to which that is a consequence of what the script must do, as
opposed to just being a consequence of bad implementation. A question
that is partly answered by an examination of some of the code, such as
the - Listen - function:-

| function Listen() { // ATM 2aug2002; or your ID & date.
| quiet = false; // So that aLife() will not yet call Think().
| fyi = "Calling the Listen module; when done press [ENTER]";
| Voice(); // Display the Voice:brain fyi message.
| inert = 0; // Upon input, retreat from calling Ego().
| pov = "*"; // symbol to display "external" point-of-view
| document.onkeypress = function (evt) {
| c = event.keyCode;
<snip - 40 lines of code>
| return true; // The work of the module is done.
| } // End of "document.onkeypress"
| } // End of Listen() for each character of user input.

The - Listen - function is called from an onkeydown event handler on the
text input field:-

| <INPUT TYPE="TEXT" NAME="ear" value=""
| SIZE="80" onKeyDown="Listen()">

As a result it will be executed whenever a key is pressed down while
that field has focus. The - Listen - function itself assigns an event
handler to the - document.onkeypress - each time it is executed, though
no other part of the script ever re-sets or re-assigns anything to that
property. However, the function assigned is not merely a reference to a
function, it is a function expression evaluated within the body of a
function. Meaning that each evaluation of the expression results in the
creation of a *new* anonymous function object and the assigning of a
reference to that function object to the - document.onkeypress -
property. And this happens every time the user presses a key down while
entering text within the text field, even though all of the function
objects created (and subsequently freed and garbage collected) are
essentially identical. This is a ludicrous processing overhead to impose
on an action as simple as entering text, and completely avoidable.

Similar absurd inefficiencies manifest themselves throughout the rest of
the code. E.G.:-

| function Tutorial() { // ATM 14may2002; or your ID & date.
| if (document.all["cb3"].checked == true) {

An - if - statement evaluates its expression and passes the result to
the internal - ToBoolean - function (which will type-convert a
non-boolean value, or just return a boolean when its argument is already
that type), making its decision based on the result. The type-converting
comparison operator - == - always produces a boolean result but, when
comparing a boolean property (such as the - checked - property of a
checkbox) with a boolean literal (true or false) the result is always
directly related to the trueness of the original boolean property. Thus
a comparison operation with a boolean literal is redundant:-

if( document.all["cb3"].checked ){
... // checked is true.
}

if( !document.all["cb3"].checked ){
... // checked is NOT true (false).(! - is the NOT operator)
}

| tutor = true; // a flag for Tutorial()

The - tutor - global variable is set to - true - in this branch (when -
checked - is true) and - false - in the other (when - checked - is
false). The two branches are mutually exclusive and set - tutor - to a
value directly related to the value of - checked -, so it would be more
efficient to directly assign the value of - checked - to the - tutor -
variable, and doing so in the expression of the - if - statement would
avoid having to re-resolve the - checked - property of the checkbox
element:-

if( (tutor = document.all["cb3"].checked) ){
... // checkbox is checked
}
// the current value of - checked - has been assigned to - tutor.

| document.all["teacher"].style.visibility='visible';
| msg++; // Increment so as to cycle through the Tutorial display.
|
| if (msg==1) meme="There is no warranty [...]";
| if (msg==2) meme="You may put AI as mi [...]";
| if (msg==3) meme="Entry of user input [...]";
<snip - 43 other similar - if - statements>
| if (msg==48) meme="The AI Textbook is t [...]";
| if (msg==49) meme="On supercomputers yo [...]";
| if (msg==50) meme="You are witnessing t [...]";

49 consecutive - if - statement in which the evaluation of any one
expression to true logically precludes the possibility of any of the
following - if - statement expressions evaluating as true is massively
inefficient coding. An - if/else if - logic would be better (as
evaluation would stop an the first true result) but 49 - if/else if -
clauses, where the value of one variable is compared with a sequence of
numbers, is exactly the situation that the - switch - statement was
designed to handle.

However, defining the 49 output strings as elements of an array (in a
suitably stable containing scope, probably globally) and using the
numeric - msg - variable to index that array would reduce that entire
sizeable block of code down to one property accessor expression:-

stringsListArray[ msg ]

- that could just replace - meme - in the following string construction.

| memeplus = ("<font size='+2' color='navy'>" + meme +"<\/b><\/font>");
^^^^^
A closing B tag, without a corresponding opening tag, in this context is
an error and will be subject to browser error-correction when assigned
to the - innerHTML - property. The browsers has no choice but ignore the
invalid closing B tag, but asking it to process that input, recognise
the error and correct it, is needlessly wasteful in such a processor
intensive script.

| document.all.teacher.innerHTML = memeplus;
| if (msg>49) msg = 0; // Loop back through the Tutorial messages.
| } // end of if-clause to see if Tutorial is checked.
| if (document.all["cb3"].checked == false) {

Again, a comparison of a boolean property with a boolean value is
pointless and inefficient. However, this - if - statement is mutually
exclusive with the one for the preceding branch so a simple - else -
separating the two branches is all that is required (avoiding the second
test entirely):-

if( (tutor = document.all["cb3"].checked) ){
... // String outputting branch
}else{
... // output hiding branch
}

| document.all["teacher"].style.visibility='hidden';
| tutor = false;
| } // end of if-clause to see if Tutorial is NOT checked.
| document.forms[0].ear.focus(); // await input

continuously re-focusing the form input field will encourage the browser
to scroll the page so that the field is within the display, making the
troubleshooting and transcript outputs inaccessible when they exceed the
remaining display area in the browser window.

| } // end of Tutorial() function

The dubious - if - statement logic re-occurs in many locations
including:-

| function psiDecay() { // ATM 21jun2002; or your ID & date.
| for (i = t; i>midway; --i) { // Loop backwards in recent time.
^ ^ ^
The variable - i - is a global variable, it really should be local. If
it were local it would be resolved quicker, and there would be less
chance of chaos following if a future modification decided to call a
function within this loop that also attempted to loop with the same
global - i - variable (as all but 4 of the loops within the code use the
same - i - variable that is likely to happen at some point).

| Psi[i].psiExam(); // Cycle through recent Psi nodes.
| if (psi1 > 0) { // Find any mindcore psi1 positive activation.
| if (psi1 == 1) psi1 = 0;
| if (psi1 == 2) psi1 = 0;
| if (psi1 == 3) psi1 = 0;
| if (psi1 == 4) psi1 = 0;
| if (psi1 == 5) psi1 = 0;
| if (psi1 == 6) psi1 = 0;
| if (psi1 == 7) psi1 = 0;
| if (psi1 == 8) psi1 = 0;
| if (psi1 == 9) psi1 = 0;
| if (psi1 == 10) psi1 = 0;
| if (psi1 == 11) psi1 = 0;
| if (psi1 == 12) psi1 = 0;
| if (psi1 == 13) psi1 = 0;
| if (psi1 == 14) psi1 = 0;
| if (psi1 == 15) psi1 = 0;
| if (psi1 == 16) psi1 = 0;
| // if (psi1 == 17) psi1 = 0;
| // if (psi1 == 18) psi1 = 0;
| // if (psi1 == 19) psi1 = 0;
| // if (psi1 == 20) psi1 = 0;
| // if (psi1 == 21) psi1 = 0;
| // if (psi1 == 22) psi1 = 0;
| // if (psi1 == 23) psi1 = 0;
| if (psi1 > 16) psi1 = (psi1 - 16); // above the range.
| Psi[i] = new psiNode(psi0,psi1,psi2,psi3,psi4,psi5,psi6);
| } // end of if-clause finding and reducing positive activations
| } // end of backwards loop
| } // End of psiDecay(); return to Think().

If - psi1 - is greater than zero it must either be less than or equal to
16 (so set to zero) or greater than 16 (so set to (psi1 - 16)).
Simplifying the code to:-

function psiDecay() {
for (var i = t; i>midway; --i) {
Psi[i].psiExam();
if (psi1 > 0) {
psi1 -= (psi1 > 16)?16:psi1;
Psi[i] = new psiNode(psi0,psi1,psi2,psi3,psi4,psi5,psi6);
}
}
}

- and avoiding the execution of up to 16 unnecessary statements.
that may be copied to your Web site
with your own changes.
Given that the script referenced above errored, locked-up and then
crashed my IE 6 twice in succession, exposing innocent members of the
public to it would not be a good idea.
Freshly updated and modified from the AI Mind-1.1 appearing
in http://isbn.nu/0595654371 -- AI4U textbook of artificial
intelligence -- the new AI Mind forgets its oldest unused
memories in order to make room for memories of fresh
experience, and is therefore immortal.
This is not a definition of immortality that I would recognise.
Interested parties may start the immortal AI Mind running
in the Microsoft Internet Explorer Web browser and see how
long it lives.

<snip>

There is no good reason that the script should only "work" on IE
browsers, beyond its author's superficial familiarity with web browser
scripting.

As an exercise in javascript authoring the script is very badly designed
and ineptly implemented. It has no merits whatsoever, even if it did
achieve what is claimed for it (which doesn't appear to be the case). So
you should stop spamming comp.lang.javascript with cross-posted
references to your javascript "AI" as the only interest that group may
have in it would be as an example of how not to design and implement a
browser script.

Richard.
Jul 20 '05 #5
Richard Cornford wrote:
Arthur T. Murray wrote:
http://www.scn.org/~mentifex/jsaimind.html is a free,
public-domain AI in JavaScript


[a ca. 300 lines essay about how (not) to write scripts]


I really appreciate your explanations, though most of it known,
but do you really think ATM is worth it? Do not feed the troll:

<http://www.nothingisreal.com/mentifex>

And BTW, please do not crosspost over main hierarchies and
please do not crosspost without Followup-to. Thanks.
X-Post sci.* cut, F'up2 poster

PointedEars
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the instances: def initVariables(self): self.e =...
15
by: Ralf W. Grosse-Kunstleve | last post by:
****************************************************************************** This posting is also available in HTML format: http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html...
18
by: Ralf W. Grosse-Kunstleve | last post by:
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object):...
4
by: David Coffin | last post by:
I'd like to subclass int to support list access, treating the integer as if it were a list of bits. Assigning bits to particular indices involves changing the value of the integer itself, but...
4
by: marek.rocki | last post by:
First of all, please don't flame me immediately. I did browse archives and didn't see any solution to my problem. Assume I want to add a method to an object at runtime. Yes, to an object, not a...
7
by: Andrew Robert | last post by:
Hi Everyone, I am having a problem with a class and hope you can help. When I try to use the class listed below, I get the statement that self is not defined. test=TriggerMessage(data) var...
24
by: Peter Maas | last post by:
The Python FAQ 1.4.5 gives 3 reasons for explicit self (condensed version): 1. Instance variables can be easily distinguished from local variables. 2. A method from a particular class can be...
84
by: braver | last post by:
Is there any trick to get rid of having to type the annoying, character-eating "self." prefix everywhere in a class? Sometimes I avoid OO just not to deal with its verbosity. In fact, I try to...
13
by: Kurda Yon | last post by:
Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = for j in range(len(self.data)):...
6
by: Bart Kastermans | last post by:
I am playing with some trees. In one of the procedures I wrote for this I am trying to change self to a different tree. A tree here has four members (val/type/left/right). I found that self = SS...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.