?? javascript
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>JavaScript版本人工智能 編程無限整理</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><!-- 24feb01A.html developmental version --><!-- There is no warranty for what this software does. --><!-- This software is in the public domain and may be --><!-- adapted for any legitimate purpose on any Web site. -->
<META content="AI in JavaScript for MSIE 4.01+" name=description>
<SCRIPT language=JavaScript>
var act = 0; // act(ivation) for STM() and stringEffect().
var attn = 1; // "attention" as opposed to reentrant thinking.
var auddata = "pho act pov beg ctu utg"; // for use in audShow().
var beg = 0; // beg(inning) of a word? (1 = "yes").
var blankt = 0; // a "blank-time" of no input.
var bulge = 0; // for Activate() and spreadAct().
var c = ""; // used in Audition()
var clue = "Tutorial is the default mode of the AI.";
// DIY AI: You may CAREFULLY modify the CNS value:
var cns = 1024; // Central Nervous System array size limit
var conversing = false; // flag for Audition(); CR(); cutOut();
var ctu = 1; // continuation? (1 = "yes").
var death = false; // for use in halting the AI.
var dialog = ""; // for use in Transcript()
var endata = "nen act fin g fex rv"; // for use in enShow().
var enx = 0; // for transfers from psi to En(glish) lexical array.
var en4 = 0; // declare en4 here to make it a global variable.
var eot = 0; // end-of-transmission for use in CR() and Audition().
var etc = 0; // for use in Activate() etc.
var f = 0; // concept fiber in oldConcept, etc.
var fex = 0; // f(iber)-ex or fiber-out (from psi to English).
var fin = 0; // f(iber)-in or fiber-in (from English into psi).
var g = 0; // grammar category for newConcept().
var gram1 = ""; // first of six variables in "audRecall()" function
var html = ""; // Hyper Text Markup Language
var i = 0; // i(ndex) of loops.
var inbuffer = ""; // build-up of user input in Audition()
var j = 0; // index for a loop nested inside an i-loop.
var len = 0; // word-length for Audition() and Retro().
var meme = 0; // for use in psiDamp, etc.
var message = "Message from the Artificial Mind"; // for Say()
var midway = 0; // for use in Comparator().
var motjuste = ""; // best word for selection as component of thought
var msg = 0; // for counting in tutorial PhD() mode.
var mt = 0; // "move-tag" for Comparator().
var nen = 0; // n(umber of) En(glish) lexical concept after Bootstrap().
var nlt = 5; // "not-later-than" for Audition() and CR().
var nonce = 1; // time "for the nonce" in Troubleshoot mode
var onset = 0; // for Retro() etc.
var output = ""; // for use with Speech() and Say().
var par = 1; // par(se) flag for newConcept().
var pho = ""; // pho(neme) for use in STM().
var pov = "*"; // point-of-view default "internal" value.
var pre = 0; // previous associand for Instantiate().
var prevg = 0; // previous-grammar-category for newConcept().
var psi1 = 0; // first of six elements in a Psi concept panel.
var psidata = "f/mt act pre pos seq enx"; // for use in psiShow().
var rv = 0; // recall-vector for Retro() etc.
var t = 0; // time "t" incremented in Audition() and CR().
var talk = false; // flag for toggling eventual "Speech" mode.
var tdec = 0; // "time-decrement" for Comparator().
var tov = 1; // time-of-voice for use in CR().
var trouble = true; // for use in Security().
var tse = 0; // time-(in)-stringEffect.
var tsml = ""; // troubleshoot-ml for use in audShow().
var tutor = true; // flag for Tutorial mode.
var unk = ""; // general variable for "unknown" items
var userline = "" // from CR() for Transcribe()
var utg = 0; // ultimate-tag of a word for STM().
var zone = 0; // time-zone for Activate() and spreadAct()
// Initialize the mindcore Psi I.A.W. AI Standards:
Psi = new Array(cns);
for (i = 0; i < cns; i++) {
Psi[i] = new psiNode(" ",0," "," "," "," ");
}
// Initialize the English Lexicon I.A.W. AI Standards, e.g.,
// could also include French frLexicon or Japanese jpLexicon
// for purposes of polyglot robot and/or machine translation:
enLexicon = new Array(cns);
for (i = 0; i < cns; i++) {
enLexicon[i] = new enNode(" ",0," "," "," "," ");
}
// Initialize the Auditory Memory Channel:
audMemChan = new Array(cns);
for (i = 0; i < cns; i++) {
audMemChan[i] = new audEngram(" ",0," "," "," "," ");
}
// Bootstrap() is called by BODY onLoad
// and should run only once in each session.
// It should therefore be outside of the main loop.
// Here any given expert knowledge can be loaded --
// chessplayer, physicist, programmer -- whatever.
function Bootstrap() {
HCI(); // run HCI so that only CHECKED items appear.
// The next line sets up the concept fiber for "I":
t=1; mt=50; act=0; pre=0; pos=5; seq=61; enx=50; Instantiate();
// We establish the mindcore fiber of "know":
t=6; mt=61; act=0; pre=50; pos=8; seq=56; enx=61; Instantiate();
// We establish the mindcore fiber of "you" ("other"):
t=10; mt=56; act=0; pre=61; pos=5; seq=0; enx=56; Instantiate();
// "I" ("self") is mindcore octave seven, overall concept #50:
t=1; mt=50; act=0; fin=56; g=5; fex=50; rv=1; Attach();
// "know" is mindcore octave eight, concept #61:
t=6; mt=61; act=0; fin=61; g=8; fex=61; rv=3; Attach();
// "you" ("other") is mindcore octave seven, concept #56:
t=10; mt=56; act=0; fin=50; g=5; fex=56; rv=8; Attach();
t=1; pho="I"; act=0; pov="*"; beg=1; ctu=0; utg=50; STM(); // "I"
t=3; pho="K"; act=0; pov="*"; beg=1; ctu=1; utg=0; STM(); // "K"
t=4; pho="N"; act=0; pov="*"; beg=0; ctu=1; utg=0; STM(); // "N"
t=5; pho="O"; act=0; pov="*"; beg=0; ctu=1; utg=0; STM(); // "O"
t=6; pho="W"; act=0; pov="*"; beg=0; ctu=0; utg=61; STM(); // "W"
t=8; pho="Y"; act=0; pov="*"; beg=1; ctu=1; utg=0; STM(); // "Y"
t=9; pho="O"; act=0; pov="*"; beg=0; ctu=1; utg=0; STM(); // "O"
t=10; pho="U"; act=0; pov="*"; beg=0; ctu=0; utg=56; STM(); // "U"
// you ... ... [ creation of the deep mindcore Psi nodes ]
t=14; mt=56; act=0; pre=0; pos=5; seq=62; enx=56; Instantiate();
// ... see ...
t=18; mt=62; act=0; pre=56; pos=8; seq=65; enx=62; Instantiate();
// ... ... me.
t=21; mt=50; act=0; pre=62; pos=5; seq=0; enx=65; Instantiate();
// you ... ... [ creation of the mid-level English lexical nodes ]
t=14; mt=56; act=0; fin=50; g=5; fex=56; rv=12; Attach();
// ... see ...
t=18; mt=62; act=0; fin=62; g=8; fex=62; rv=16; Attach();
// ... ... me
t=21; mt=65; act=0; fin=56; g=5; fex=50; rv=20; Attach();
t=12; pho="Y"; act=0; pov="*"; beg=1; ctu=1; utg=0; STM(); // "Y"
t=13; pho="O"; act=0; pov="*"; beg=0; ctu=1; utg=0; STM(); // "O"
t=14; pho="U"; act=0; pov="*"; beg=0; ctu=0; utg=56; STM(); // "U"
t=16; pho="S"; act=0; pov="*"; beg=1; ctu=1; utg=0; STM(); // "S"
t=17; pho="E"; act=0; pov="*"; beg=0; ctu=1; utg=0; STM(); // "E"
t=18; pho="E"; act=0; pov="*"; beg=0; ctu=0; utg=62; STM(); // "E"
t=20; pho="M"; act=0; pov="*"; beg=1; ctu=1; utg=0; STM(); // "M"
t=21; pho="E"; act=0; pov="*"; beg=0; ctu=0; utg=65; STM(); // "E"
mt = 0; // reset for safety.
pre = 0; // reset for safety.
utg=0; // reset for safety.
t = (t+1); // create a gap of time.
blankt = t; // henceforward to be calculated
nlt = t;
pho=" "; // reset to prevent reduplication.
nen = 65; // or higher if any irregular forms intervene.
output = "Bootstrap has loaded.";
Voice();
// 24feb2001: loop for sake of Tutorial display.
TID=window.setTimeout("Security();",59000);
} // end of Bootstrap() sequence with supernumerary "me" (65).
// HCI() is the Human-Computer Interface
// between the user and the AI as a program.
// HCI() is called from buttons and checkboxes.
function HCI() {
if (document.all["cb3"].checked == true) {
document.all["cb2"].checked = false; // turn off Transcript
trouble = true;
msg = 9; // for a cluster of Troubleshoot messages in PhD().
} // end of if-clause to see if "Troubleshoot" is checked.
if (document.all["cb3"].checked == false) {
trouble = false;
} // end of if-clause to see if Troubleshoot is NOT checked.
if (document.all["cb2"].checked == true) {
document.all["cb3"].checked = false; // turn off Troubleshoot
hardcopy = true;
msg = 4; // for cluster of Transcript messages in PhD().
now = new Date();
adcopy=
("<font size='+2'>Transcript of " + now + "<\/b><\/font>");
document.all.souvenir.innerHTML = adcopy;
} // end of if-clause to see if "Transcript" is checked.
if (document.all["cb2"].checked == false) {
hardcopy = false;
} // end of if-clause to see if Transcript is NOT checked.
// DIY AI: Always return control to user:
document.forms[0].ear.focus(); // await user input.
} // end of HCI() function
// PhD() ("Philosophiae Doctor") is called by the Tutorial
// checkbox and stands in isolation from HCI() so that
// unique events may happen in the Tutorial mode.
function PhD() {
if (document.all["cb4"].checked == true) {
tutor = true; // a flag for Homunculus(), etc.
document.all["teacher"].style.visibility='visible';
msg++;
if (msg==1) clue="Tutorial mode will cycle through its messages.";
if (msg==2) clue="Special messages may appear for special modes.";
if (msg==3) clue="Entry of user input will stall Tutorial messages.";
if (msg==4) clue="Please use no punctuation or case-shifting.";
if (msg==5) clue="Transcript: Aim for a dialog that shows reasoning.";
if (msg==6) clue="As the Mind advances, test it psychologically.";
if (msg==7) clue="With transcripts we may measure the IQ of the AI.";
if (msg==8) clue="You may give away transcripts as demo souvenirs.";
if (msg==9) clue="Transcript paper may carry advertisements.";
if (msg==10) clue="(Troubleshoot): Three columns show three arrays.";
if (msg==11) clue="The left column shows fibers in the Psi mindcore.";
if (msg==12) clue="There can be only one mindcore of Psi concepts.";
if (msg==13) clue="A list is in Standards in Artificial Intelligence.";
if (msg==14) clue="Note the residual Psi activations during reentry.";
if (msg==15) clue="Residual activation maintains the chain of thought.";
if (msg==16) clue="The ego-concept may need increments of activation.";
if (msg==17) clue="Incrementing ego may restart a chain of thought.";
if (msg==18) clue="The middle column shows the English lexicon.";
if (msg==19) clue="Lexical nodes do not contain the actual words.";
if (msg==20) clue="Lexical nodes control words in auditory memory.";
if (msg==21) clue="The lexical array may contain multiple languages.";
if (msg==22) clue="For each language there must be its own syntax.";
if (msg==23) clue="Syntax is hand-coded into the early AI minds.";
if (msg==24) clue="The AI may learn new syntax in a looping spiral.";
if (msg==25) clue="The right column shows auditory memory engrams.";
if (msg==26) clue="The lexical rv number localizes the audEngram.";
if (msg==27) clue="User input is shown in red for maximum effect.";
if (msg==28) clue="Reentry is the output of the AI reentering the AI.";
if (msg==29) clue="You may handcode bootstraps based on Troubleshoot.";
if (msg==30) clue="To click Transcript, first unclick Troubleshoot.";
clueplus = ("<font size='+3' color='navy'>" + clue + "<\/b><\/font>");
document.all.teacher.innerHTML = clueplus;
if (msg>29) msg = 0; // loop back through the Tutorial messages.
} // end of if-clause to see if Tutorial is checked.
if (document.all["cb4"].checked == false) {
document.all["teacher"].style.visibility='hidden';
tutor = false;
} // end of if-clause to see if Tutorial is NOT checked.
} // end of PhD() function
// psiDamp() is called from nounPhrase() or Predicate()
// to de-activate a concept that was briefly activated.
function psiDamp() {
// 7feb2001 -- we use tov to avoid damping reentered thoughts.
for (i = tov; i>midway; --i) {
Psi[i].psiExam(); // cycle through recent Psi nodes
if (psi1 == meme) Psi[i] = new psiNode(psi1,0,psi3,psi4,psi5,psi6);
} // end of backwards loop
} // psiDamp returns to nounPhrase, Predicate, etc.
// enDamp() is called from nounPhrase() or Predicate()
// to de-activate all concepts in the English lexicon.
function enDamp() {
for (i = (t + 1); i>midway; --i) {
enLexicon[i].enExam(); // gain access to each node
enLexicon[i] = new enNode(en1,0,en3,en4,en5,en6);
} // end of backwards loop
} // enDamp returns to nounPhrase and Predicate.
// audDamp() is called from Retro() upon recognition of
// a known word, and resets auditory engram activations
// to zero so that additional words can be recognized.
function audDamp() {
for (i = t; i > midway; --i) { // loop backwards through time
audMemChan[i].audRecall(); // activate the audEngrams
audMemChan[i] = new audEngram(gram1,0,gram3,gram4,gram5,gram6);
}
return;
} // end of audDamp()
// Shutdown() is called by clicking the "Halt"
// button or by pressing the [ESCAPE] key,
// and is supposed to stop the AI program.
function Shutdown() {
if (document.all["cb5"].checked == true) {
death = true; // a flag to halt the alife
message = "AI halted by user.";
Voice();
} // end of if-clause to see if HALT is checked.
if (document.all["cb5"].checked == false) {
death = false; // so that unchecking revives the AI.
} // end of if-clause to see if HALT is NOT checked.
Security();
} // end of Shutdown()
// Destroy() is called from the Control Panel
// and is meant to provide extreme security
// at all stages of the creation of the AI.
function Destroy() {
death = true;
output = "Closing the window will destroy the AI.";
Voice();
TID=window.setTimeout("window.close();",500);
} // end of Destroy()
// Transcribe() is called from Transcript()
// and serves the purpose of holding the "dialog".
function Transcribe() {
if (hardcopy == true) {
dialog += ("<P>Human: <b>" + userline + '<\/b>');
dialog += ("<BR>Robot: " + output); // from the AI
} // end of if-clause
} // end of Transcribe()
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -