• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

PHP Artificial Intelligence Program (PAIP)

Newbie Spellweaver
Joined
May 28, 2011
Messages
42
Reaction score
4
Hi there, Just 10 day's ago, i got this crazy idea to make an artificial intelligence program in php. I called it PHP Artificial Intelligence Program or for short P.A.I.P . Currently planning
  • Talk to us as any other human would (random words like "how are you")
  • GUI
Currently done
  • The database
  • The actual site
  • Learning new words as it communicates with us
  • Answer questions


Some preview codes (v1)
PHP:
<?php
error_reporting(0);
$con = mysql_connect("localhost","root","haikal00");
if (!$con)
  {
  echo "<script>alert('Could not connect to database')</script>";
  }
$db_selected = mysql_select_db("paip", $con);

if (!$db_selected)
  {
  echo "<script>alert('Couldn't select database')</script>";
  }
?>
<html>
<head>
<title>PHP Artificial Intelligence Program</title>
<style>
#output
{
    background-color: rgb(237, 239, 244);
    margin-top: 1px;
    font-family: 'lucida grande',tahoma,verdana,arial,sans-serif;
    font-size: 11px;
    line-height: 1.28;
    width:300px;
    height:50px;
    border-radius:10px;
    padding:6px;
}
</style>
<script>
function message(str)
{
if (str=="")
  {
  document.getElementById("output").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("output").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","message.php?message="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<center><h2>PHP Artificial Intelligence Program (PAIP)</h2></center>

<form>
Message: <input type="text" name="message"  id="message" onkeyup="message(this.value)">
</form>

<div id="output">
<?php
$message = $_GET['message'];
$botname = "Test";
$sanitized_message = mysql_escape_string(stripslashes($message));
$search_phrase = mysql_query("SELECT answer FROM phrases WHERE phrase = '$sanitized_message'");
$search = mysql_fetch_assoc($search_phrase);
$search_rows = mysql_num_rows($search_phrase);
if ($search_rows > 0)
  {
  echo $botname ." : ". $search['answer'];
  }
else
  {
  $insert_phrase = mysql_query("INSERT INTO phrases VALUES ('$sanitized_message')");
  echo $botname ." : ". $sanitized_message;
  }
?>
</div>
 
Last edited:
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
Sounds like fun.. So are you going to make the program put words into sentences in reaction to humans or concentrate on phrases? Also you may try to think about making the bot hold a thought- as conversations often reference topics from past conversations or use the current topic to remember a new one.


Programming a human-like AI is truly an art.

A good resource on behavior and how the brain is designed to handle that behavior may be of interest to you:
 
Skilled Illusionist
Joined
Sep 22, 2012
Messages
300
Reaction score
65
Oh, so you mean something like, ?
 
Master Summoner
Joined
Jan 20, 2011
Messages
512
Reaction score
163
When i read the title i was like XD because i thought you would create a artificial intelligence program that could program php but still you're idea is cool :)
 
Newbie Spellweaver
Joined
May 28, 2011
Messages
42
Reaction score
4
i tried doing this in c++ but i am still new to that language
 
Pee Aitch Pee
Joined
Mar 30, 2011
Messages
630
Reaction score
422
Looking forward to the code.
 
Newbie Spellweaver
Joined
May 28, 2011
Messages
42
Reaction score
4
I am just using mysql database for all the phrases,questions,words
 
Newbie Spellweaver
Joined
Apr 21, 2009
Messages
85
Reaction score
0
just what government would donate money to auto killing robot computers ==
 
Back
Top