Topalian JavaScript True AI by Christopher Topalian
Topalian JavaScript True AI by Christopher Topalian
JavaScript
True AI
by
Christopher Andrew Topalian
All Rights Reserved
Copyright 2000-2024
Dedicated
to
God the Father
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// HowToCombineJSFiles.js
TUTORIAL:
How to Combine all .js files in all folders that
are in our js folder.
<!-- https://github.com/ChristopherTopalian --
>
<!--
https://github.com/ChristopherAndrewTopalia
n -->
<html>
<head>
<title> Topalian JavaScript True AI </title>
<script src =
'js/1shortcuts/shortcuts.js'></script>
<script src =
'js/2worldVariables/worldVariables.js'></scrip
t>
<script src =
'js/dataFunctions/findIndexByName.js'></scri
pt>
<script src =
'js/logicGates/logicGates.js'></script>
<script src =
'js/make/makeLogicGateButtons.js'></script>
<script src =
'js/make/makeLogicCalculator.js'></script>
<script src =
'js/make/makeTrueAiDiagram.js'></script>
<script src =
'js/make/makeCredits.js'></script>
<script src =
'js/sound/loadSounds.js'></script>
<script src =
'js/whenLoaded/whenLoaded.js'></script>
</head>
</body>
</html>
/* Dedicated to God the Father */
/* https://github.com/ChristopherTopalian */
/*
https://github.com/ChristopherAndrewTopalia
n */
/* style001.css */
body
{
background-color: rgb(40, 40, 40);
font-family: Arial;
font-size: 20px;
font-weight: bold;
color: rgb(255, 255, 255);
}
a
{
color: rgb(100, 100, 100);
text-decoration: none;
}
a:hover
{
text-decoration: underline;
}
input
{
padding: 10px;
background-color: rgb(0, 0, 0);
border: solid 1px rgb(100, 100, 100);
border-radius: 8px;
font-size: 20px;
font-weight: bold;
color: rgb(255, 255, 255);
text-align: center;
}
textarea
{
padding: 10px;
background-color: rgb(0, 0, 0);
border: solid 1px rgb(100, 100, 100);
border-radius: 8px;
font-family: Arial;
font-size: 20px;
font-weight: bold;
color: rgb(255, 255, 255);
}
.logicButtonsDiv
{
display: grid;
grid-template-columns: auto auto;
}
.logicGateButton
{
margin: 1px;
padding-left: 7px;
padding-right: 7px;
padding-top: 5px;
padding-bottom: 5px;
border: solid 1px rgb(100, 100, 100);
border-radius: 8px;
background-color: rgb(0, 0, 0);
font-size: 14px;
font-weight: bold;
color: rgb(100, 100, 100);
line-height: 12px;
}
.logicGateButton:hover
{
border-color: rgb(0, 255, 255);
color: rgb(255, 255, 255);
}
.logicGateButton:active
{
position: relative;
top: 1px;
border-color: rgb(100, 100, 255);
color: rgb(100, 100, 255);
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// shortcuts.js
function ge(whichId)
{
let result =
document.getElementById(whichId);
return result;
}
function ce(whichType)
{
let result =
document.createElement(whichType);
return result;
}
function ba(whichElement)
{
let result =
document.body.append(whichElement);
return result;
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// worldVariables.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// logic.js
let logic =
[
{
name: "And",
imgSrcOffline:
'media/textures/topalianDiagrams/and.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/and_orig.png',
function: "gateAnd(a, b)",
formula: "if (a == 1 && b == 1)",
opposite: "Nand",
truthTable: "0001",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 0
1 0 = 0
1 1 = 1
`
},
{
name: "Nand",
imgSrcOffline:
'media/textures/topalianDiagrams/nand.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/nand_orig.png',
function: "gateNand(a, b)",
formula: "if (a == 0 || b == 0)",
opposite: "And",
truthTable: "1110",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 1
1 0 = 1
1 1 = 0
`
},
{
name: "Or",
imgSrcOffline:
'media/textures/topalianDiagrams/or.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/or_orig.png',
function: "gateOr(a, b)",
formula: "if (a == 1 || b == 1)",
opposite: "Nor",
truthTable: "0111",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 1
1 0 = 1
1 1 = 1
`
},
{
name: "Nor",
imgSrcOffline:
'media/textures/topalianDiagrams/nor.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/nor_orig.png',
function: "gateNor(a, b)",
formula: "if (a == 0 && b == 0)",
opposite: "Or",
truthTable: "1000",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 0
1 0 = 0
1 1 = 0
`
},
{
name: "Xor",
imgSrcOffline:
'media/textures/topalianDiagrams/xor.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/xor_orig.png',
function: "gateXor(a, b)",
formula: "if ((a == 1 && b == 0) || (a == 0
&& b == 1))",
opposite: "Xnor",
truthTable: "0110",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 1
1 0 = 1
1 1 = 0
`
},
{
name: "Xnor",
imgSrcOffline:
'media/textures/topalianDiagrams/xnor.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/xnor_orig.png',
function: "gateXnor(a, b)",
formula: "if ((a == 0 && b == 0) || (a == 1
&& b == 1))",
opposite: "Xor",
truthTable: "1001",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 0
1 0 = 0
1 1 = 1
`
},
{
name: "Converse Implication",
imgSrcOffline:
'media/textures/topalianDiagrams/converse_i
mplication.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/converse-
implication_orig.png',
function: "gateCi(a, b)",
formula: "if (a == 1 || b == 0)",
opposite: "Converse NonImplication",
truthTable: "1011",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 0
1 0 = 1
1 1 = 1
`
},
{
name: "Converse NonImplication",
imgSrcOffline:
'media/textures/topalianDiagrams/converse_n
on_implication.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/converse-non-
implication_orig.png',
function: "gateCni(a, b)",
formula: "if (a == 0 && b == 1)",
opposite: "Converse Implication",
truthTable: "0100",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 1
1 0 = 0
1 1 = 0
`
},
{
name: "Material Implication",
imgSrcOffline:
'media/textures/topalianDiagrams/material_im
plication.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/material-
implication_orig.png',
function: "gateMi(a, b)",
formula: "if (a == 0 || b == 1)",
opposite: "Material NonImplication",
truthTable: "1101",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 1
1 0 = 0
1 1 = 1
`
},
{
name: "Material NonImplication",
imgSrcOffline:
'media/textures/topalianDiagrams/material_n
on_implication.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/material-non-
implication_orig.png',
function: "gateMni(a, b)",
formula: "if (a == 1 && b == 0)",
opposite: "Material Implication",
truthTable: "0010",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 0
1 0 = 1
1 1 = 0
`
},
{
name: "Right Projection",
imgSrcOffline:
'media/textures/topalianDiagrams/right_proje
ction.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/right-projection_orig.png',
function: "gateRp(a, b)",
formula: "if ((a == 0 && b == 1) || (a == 1
&& b == 1))",
opposite: "Right Complementation",
truthTable: "0101",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 1
1 0 = 0
1 1 = 1
`
},
{
name: "Right Complementation",
imgSrcOffline:
'media/textures/topalianDiagrams/right_comp
lementation.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/right-
complementation_orig.png',
function: "gateRc(a, b)",
formula: "if ((a == 0 && b == 0) || (a == 1
&& b == 0))",
opposite: "Right Projection",
truthTable: "1010",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 0
1 0 = 1
1 1 = 0
`
},
{
name: "Left Projection",
imgSrcOffline:
'media/textures/topalianDiagrams/left_project
ion.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/left-projection_orig.png',
function: "gateLp(a, b)",
formula: "if (a == 1)",
opposite: "Left Complementation",
truthTable: "0011",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 0
1 0 = 1
1 1 = 1
`
},
{
name: "Left Complementation",
imgSrcOffline:
'media/textures/topalianDiagrams/left_comple
mentation.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/left-
complementation_orig.png',
function: "gateLc(a, b)",
formula: "if (a == 0)",
opposite: "Left Projection",
truthTable: "1100",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 1
1 0 = 0
1 1 = 0
`
},
{
name: "Tautology",
imgSrcOffline:
'media/textures/topalianDiagrams/tautology.p
ng',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/tautology_orig.png',
function: "gateTautology(a, b)",
formula: "if ((a == 0 && b == 0) || (a == 0
&& b == 1) || (a == 1 && b == 0) || (a == 1 && b
== 1))",
opposite: "Contradiction",
truthTable: "1111",
truthTableFormatted: `
A B
0 0 = 1
0 1 = 1
1 0 = 1
1 1 = 1
`
},
{
name: "Contradiction",
imgSrcOffline:
'media/textures/topalianDiagrams/contradicti
on.png',
imgSrcOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/contradiction_orig.png',
function: "gateContradiction(a, b)",
formula: "if ((a == 0 && b == 0) || (a == 0
&& b == 1) || (a == 1 && b == 0) || (a == 1 && b
== 1))",
opposite: "Tautology",
truthTable: "0000",
truthTableFormatted: `
A B
0 0 = 0
0 1 = 0
1 0 = 0
1 1 = 0
`
}
];
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// logicGates.js
function gateAnd(a, b)
{
if (a == 1 && b == 1)
{
return "Both True";
}
else
{
return 0;
}
}
function gateNand(a, b)
{
/*
if ((a == 0 && b == 0) ||
(a == 1 && b == 0) ||
(a == 0 && b == 1))
*/
if (a == 0 || b == 0)
{
return "Both False or A True or B True"
}
else
{
return 0;
}
}
function gateOr(a, b)
{
/*
if ((a == 1 && b == 0) ||
(a == 0 && b == 1) ||
(a == 1 && b == 1))
*/
if (a == 1 || b == 1)
{
return "One or Both True";
}
else
{
return 0;
}
}
function gateNor(a, b)
{
if (a == 0 && b == 0)
{
return "Both False";
}
else
{
return 0;
}
}
function gateXor(a, b)
{
if ((a == 1 && b == 0) ||
(a == 0 && b == 1))
{
return "A True or B True";
}
else
{
return 0;
}
}
function gateXnor(a, b)
{
if ((a == 0 && b == 0) ||
(a == 1 && b == 1))
{
return "Both False or Both True";
}
else
{
return 0;
}
}
function gateCi(a, b)
{
/*
if ((a == 0 && b == 0) ||
(a == 1 && b == 0) ||
(a == 1 && b == 1))
*/
if (a == 1 || b == 0)
{
return "Both False or A True or Both
True";
}
else
{
return 0;
}
}
function gateCni(a, b)
{
if (a == 0 && b == 1)
{
return "B True";
}
else
{
return 0;
}
}
function gateMi(a, b)
{
/*
if ((a == 0 && b == 0) ||
(a == 0 && b == 1) ||
(a == 1 && b == 1))
*/
if (a == 0 || b == 1)
{
return "Both False or B True or Both
True";
}
else
{
return 0;
}
}
function gateMni(a, b)
{
if (a == 1 && b == 0)
{
return "A True";
}
else
{
return 0;
}
}
function gateRp(a, b)
{
if ((a == 0 && b == 1) ||
(a == 1 && b == 1))
{
return "B True or Both True";
}
else
{
return 0;
}
}
function gateRc(a, b)
{
if ((a == 0 && b == 0) ||
(a == 1 && b == 0))
{
return "Both False or A True";
}
else
{
return 0;
}
}
function gateLp(a, b)
{
/*
if ((a == 1 && b == 0) ||
(a == 1 && b == 1))
*/
if (a == 1)
{
return "A True or Both True";
}
else
{
return 0;
}
}
function gateLc(a, b)
{
/*
if ((a == 0 && b == 0) ||
(a == 0 && b == 1))
*/
if (a == 0)
{
return "Both False or B True";
}
else
{
return 0;
}
}
function gateTautology(a, b)
{
if ((a == 0 && b == 0) ||
(a == 0 && b == 1) ||
(a == 1 && b == 0) ||
(a == 1 && b == 1))
{
return "One or Both False or True";
}
else
{
return 0;
}
}
function gateContradiction(a, b)
{
if ((a == 0 && b == 0) ||
(a == 0 && b == 1) ||
(a == 1 && b == 0) ||
(a == 1 && b == 1))
{
return "One or Both False or True.
Negative Message is placed here, or we can
leave it blank";
}
else
{
return 0;
}
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// findIndexByName.js
function findIndexByName(whichArray,
whichName)
{
let index =
whichArray.findIndex(function(a)
{
return a.name === whichName
});
return index;
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// makeCredits.js
function makeCredits()
{
let creditsDiv =
document.createElement('div');
creditsDiv.style.position = 'absolute';
creditsDiv.style.right = '10px';
creditsDiv.style.top = '5px';
creditsDiv.style.zIndex = 1;
ba(creditsDiv);
//-//
let titleDiv =
document.createElement('div');
titleDiv.innerHTML =
`<a href =
'https://github.com/christophertopalian'
target = '_blank'>Topalian JavaScript True
AI</a>`;
titleDiv.style.fontSize = '15px';
titleDiv.style.color = 'rgb(120, 120, 120)';
creditsDiv.append(titleDiv);
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// makeLogicCalculator.js
function makeLogicCalculator(whichItem)
{
if (ge("logicCalcDiv"))
{
ge("logicCalcDiv").remove();
}
//-//
//-//
//-//
if (b != '')
{
ge("textBoxResult").value =
eval(logic[findIndexByName(logic,
whichItem)].function);
}
};
textboxDiv.append(textBox001);
//-//
//-//
//-//
let truthTableAbbreviated = ce('div');
truthTableAbbreviated.innerHTML =
logic[findIndexByName(logic,
whichItem)].truthTable;
truthTableAbbreviated.id =
'truthTableAbbreviated';
truthTableAbbreviated.style.position =
'absolute';
truthTableAbbreviated.style.left = '140px'
truthTableAbbreviated.style.top = '40px';
truthTableAbbreviated.style.color =
'rgb(150, 150, 150)';
if (ge('truthTableAbbreviated'))
{
ge('truthTableAbbreviated').remove();
}
ba(truthTableAbbreviated);
//-//
//-//
//-//
//-//
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// makeLogicGateButtons.js
function makeLogicGateButtons()
{
let logicButtonsDiv = ce("div");
logicButtonsDiv.id = "logicButtonsDiv";
logicButtonsDiv.className =
"logicButtonsDiv";
logicButtonsDiv.style.position = 'absolute';
logicButtonsDiv.style.left = '217px';
logicButtonsDiv.style.top = '40px';
logicButtonsDiv.style.width = '375px';
ba(logicButtonsDiv);
//-//
logicGateButton.onclick = function()
{
ge('sfx_blip_001').play();
makeLogicCalculator(logic[x].name);
};
logicGateButton.onmouseover =
function()
{
ge('sfx_warp_001').play();
};
logicButtonsDiv.append(logicGateButton);
}
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// makeTrueAiDiagram.js
function makeTrueAiDiagram()
{
let trueAiDiagram = ce('img');
trueAiDiagram.id = 'trueAiDiagram';
if (online == false)
{
trueAiDiagram.src =
'media/textures/true_ai_by_christopher_topal
ian.png';
}
else
{
trueAiDiagram.src =
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/true-ai-by-christopher-
topalian_orig.png';
}
trueAiDiagram.style.position = 'absolute';
trueAiDiagram.style.left = '598px';
trueAiDiagram.style.top = '40px';
trueAiDiagram.style.width = '400px';
ba(trueAiDiagram);
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// loadSounds.js
function loadSounds()
{
let sounds =
[
{
name: 'sfx_blip_001',
soundFileOffline:
'media/sounds/sfx_blip_001.mp4',
soundFileOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/sfx_blip_001.mp4'
},
{
name: 'sfx_warp_001',
soundFileOffline:
'media/sounds/sfx_warp_001.mp4',
soundFileOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/sfx_warp_001.mp4'
}
];
for (let x = 0; x < sounds.length; x++)
{
let theSound = ce('audio');
if (online == false)
{
theSound.src =
sounds[x].soundFileOffline;
}
else
{
theSound.src =
sounds[x].soundFileOnline;
}
theSound.id = sounds[x].name;
theSound.loop = false;
theSound.volume = 1.0;
ba(theSound);
}
}
// Dedicated to God the Father
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// whenLoaded.js
function whenLoaded()
{
loadSounds();
makeLogicCalculator("And");
makeLogicGateButtons();
makeTrueAiDiagram();
makeCredits();
}
True Artificial Intelligence System
16-Gon
Tautology
MI 1111 CI
1101 1011
AND XNOR
0001 1001
LP RP
0011 0101
OR NOR
0111 1000
RC LC
1010 1100
XOR NAND
0110 1110
CNI MNI
Contra-
0100 0010
-diction
0000
For More Tutorials:
CollegeOfScripting.weebly.com
CollegeOfScripting.wordpress.com
Youtube.com/ScriptingCollege
Twitter.com/CollegeOfScript
GitHub.com/ChristopherTopalian
GitHub.com/ChristopherAndrewTopalian
Sites.google.com/view/CollegeOfScripting
Dedicated to God the Father
This book is created by the
College of Scripting Music & Science.
Always remember, that each time you write a script
with a pencil and paper, it becomes imprinted so
deeply in memory that the material and methods are
learned extremely well.
When you Type the scripts, the same is true. The
more you type and write out the scripts by keyboard
or pencil and paper, the more you will learn
programming!
Write and Type every example that you find.
Keep all of your scripts organized.
Every script that you create increases your
programming abilities.
SEEING CODE, is one thing,
but WRITING CODE is another.
Write it, Type it, Speak It, See It, Dream It.
CollegeOfScripting.weebly.com