By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,787 Members | 1,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,787 IT Pros & Developers. It's quick & easy.

Self-Rejuvenating Immortal Artificial Intelligence

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.