Memory Span

3 11 2008

We have come up with a new idea for the self feeding function. Originally we were going to have it store emails in an array but we found out even if you fed it just one email it would munch on that forever. Ideally this would be a really cool idea, if Annie got a return email it would make Annie happier, if it didnt it would become unhappy (neglection). Given the time left we will be lucky to achieve this but its an idea.

We have decided to give our organism a short memory span of 10mins, the same as its feeding habits, this means that it can only feed off a correct email once before it forgets it. So the result would be, you enter your email and it feeds Annie, Annie will feed off that email once more if not fed for 10mins, then Annie forgets that email. 

We have found that this method enables Annie to have a more realistic lifespan and exhibits features of dependancy and infancy towards the user who we regard as its parental guardian. The user is part of the organisms life span and hopefully this will emphasize how life like our organism is, it demonstrates self sufficient abilities but not enough to fully sustain itself.





Storing Flash variables in PHP

29 10 2008

extract take from Dan Netherton http://dnetherton.wordpress.com/2008/10/29/linking-between-php-and-as2/

This morning I was looking through countless tutorials to get a php page to extract variables from Actionscript, finally i have found a working example which will be extremely simple to manipulate for our organism and also make it a little bit better once we have introduced an array or database of some kind.

The example code:

ActionScript:

Btn.onPress = function ()
{
 mail_lv = new LoadVars();
 mail_lv.dummy1 = “”;
 mail_lv.subject = “SSEN CLAN Membership”;
 mail_lv.message = “email_addy”;
 mail_lv.skin = “skin_result”;
 mail_lv.pw = “password”;
 mail_lv.fname = “first_name”;
 mail_lv.lname = “last_name”;
 mail_lv.dummy2 = “”;
 mail_lv.onLoad = function ()
 {
  trace(”Sent successfully…”);
  trace(”mail_lv.subject = ” + mail_lv.subject);
  trace(”mail_lv.message = ” + mail_lv.message);
 }
 mail_lv.send(”
http://localhost/PHP/mail3.php“, “_blank”);
// mail_lv.send(”
http://localhost/PHP/mail3.php“, mail_lv, “POST”);
// loadVariables (”mail.php3″,0,”POST”);
// gotoAndStop (”pg3″)
}

 

and the PHP:

<?php
 if (isset($_POST['subject']))
     $subject = $_POST['subject'];
 
 if (isset($_POST['message']))
     $message = $_POST['message'];
 
 echo(”subject = $subject<BR>”);
 echo(”message = $message<BR>”);
 mail(”
dan.netherton@students.plymouth.ac.uk“, $subject, $message);
?>

 

Next thing to do will be to look at linking Databases (MS Access ones) with the PHP pages to retrieve and update records hopefully…..





Countdown to dinner

29 10 2008

Today we added a timer function, the aim with this is that after 10 minutes of not being fed, the organism will go look for food on its own but also become a bit unhappier. The code below demonstrates a simple countdown function with an embedded if statement.

 countdown = function(){
    timer –; 
 if(timer==0){
       timer = 300;
    happiness = happiness – 10;
 }
 trace(timer);
 trace (happiness);
}





Emailing

23 10 2008

As part of the feeding process, as it feeds off emails we also wanted it to email the people who feed it. For this we need to use the mailto function but it has to be automated so we’re going to look at spam emails, to an extent it has to be legal and ok with our web server host but this is one of the last things we will look at when we’ve got the database and PHP code sorted.





var clockH = timedate.getHours();

23 10 2008

We’ve got this working now but are yet to fully combine it with other behaviour states. So far we have made it so that between the hours of 19:00 and 0:00 Annie will be asleep and therefore will not be able to be fed, Annie will also become more transparent in its sleeping form.

timedate = new Date();
var clockH = timedate.getHours();
var clockM = timedate.getMinutes();

trace(clockH);

if (clockH >= 19 and clockH <= 23){
speed = 0;
happiness = 50;
_root.cell._alpha=20;
}

Above you can see how little code it is to implement the system clock time. The if statement is just a simple one that stops Annie moving and makes here more transparent between those times. When Annie wakes up its happiness level will be reset back to 50… just like when you wake up and feel normal! Annie doesnt hold daily grudges.

We’ve got the get time function working with both the hours and minutes but are currently only using the hour to influence behaviour. The minutes will be implemented later as part of the “self-feeding” function. The plan is every 10 minutes if Annie hasnt been fed it will go and look at its past food eaten and eat that again, although it wont gain any happiness it will be enough to stay alive for a short while.

Next session we are spending on this we need to get the PHP end and SQL database up and working to get the variables passing through flash to the backend. Yes this will be hard!





More success today

23 10 2008

We managed to get a huge chunk of code (only AS2) out of the way today, funny thing is all the concepts are coming back and this is getting so much easier to do! Anyways we’ve started changing Annie’s happiness levels now so dont annoy her.

Below is a look at the code we have used:

else if (happiness >= 1 and happiness <= 10){
speed = 2;
_root.cell._alpha=10;
myColor.setRGB(0×333333);
}

else if (happiness >= 11 and happiness <= 20){
speed = 4
_root.cell._alpha=20;
myColor.setRGB(0×000033);
}

else if (happiness >= 21 and happiness <= 30){
speed = 6
_root.cell._alpha=30;
myColor.setRGB(0×003366);
}

This part of code is just a small bit, there are obviously else of statements for the rest of the happiness (goes up to a maximum of 100).

Depending on the happiness level of Annie determines:

  • how fast it moves
  • how transparent it is
  • what colour it is

We have created happiness to be affected by pretty much everything the user does, so it is a very ‘sensitive’ organism. If you lie to Annie it will become unhappy…

Next we’re going to look at getting a getsystem time function.





Next stage

22 10 2008

For the next stage of code design we are going to look at getting the user input (their email) into a variable and then passing that variable into a PHP function. From the PHP end we are going to store it in a database where it can be stored and called at a later date as a food source for the organism.





PHP code – passing variables between flash and PHP

16 10 2008

Flash

// first we make a new loadvars object to hold the variables that are being loaded from the php file
myData = new LoadVars();
//this is the part where we execute the function that handles the loaded data
myData.onLoad = function(){
 VariableLoad
();//call the function
};
//here we load in the php file, make sure you set the right path to your file
myData.load(“http://localhost/index.php”);

//this is the function that handles the data.
//the variables now sorta live in the loadVars object we set named myData
//So we can call em like myData.myVariableInthePhpPrintedString
//just look at the script and whatch carefully how its being called and it should become clear to ya. 
VariableLoad = function(){
 txtBox1.text = myData.textbData1;
 txtBox2.text = myData.textbData2;
 txtBox3.text = myData.textbData3;
};

PHP

<?php
/*Getting the variable ‘toPHP’ sent from flash using the ‘POST’ method*/
$fromFlash = $_POST['toPHP'];
/*Encrypting the $fromFlash and storing it as $encrypted*/
$encrypted = md5($fromFlash);
/*getting ready to send a variable to flash named toFlash using ‘&variableName=’*/
$toFlash = “&toFlash=”;
/*Asigning the encrypted variable to $toFlash AFTER the ‘=’*/
$toFlash .= $encrypted;
/*echoing out $toFlash so that flash can read it*/
echo $toFlash;
?>





New behaviours

15 10 2008

1. When happy:

  • Moves around at a faster speed
  • if it becomes happy it can duplicate

2. When unhappy:

  • Doesnt sleep
  • Moves around slower
  • Eats other cells?
  • Wont duplicate

These are additional behaviour patterns to the ones from my previous post (if your lazy click here to go to the post im talking about)

Sleeping has now been achieved!!!





We love the petri dish idea

15 10 2008

So as part of our “break” from writing code for about 6 hours, we thought we would quickly do a design for the background image of our site this will all be mounted onto.

We are going for a science table theme and in the petri dish is our annie organism. Obviously we will upload the swf over the center of this image (minus the petri dish) so it will look nice and flush.

Even though we are using flash for the coding, we dont want it to look like its been done in flash…

our science desk

our science desk








Follow

Get every new post delivered to your Inbox.