Interactive Systems Class 9
Dec 18, 2015
Interactive Systems
Class 9
Creature of the week
Outline
What you should know by nowOn wagging tailsNotes on the assignmentSome big ideas – artificial lifeMoving objects in the world, timers,
collision detection
What you should be able to do by now
Rotate an objectCo-ordinate between objects to start
rotationsAnimate an avatar
Hints about wagging tails – problem!
You need to attach the tail to an anchor object which is can rotate around (like a ball and socket joint)
The problem is that once you join the tail to the body, it no longer rotates around the ball and socket
We are looking into this to find a solution and will let you know when we do.
In the mean time if you want to keep working, look into llSetLinkPrimitiveParams(tail_number, [PRIM_ROTATION, r]);
Notes on the assignment
Remember you will be peer reviewing each other's pets next week in the labs. This means two things:
1.You have to have a pet ready to be reviewed. It does NOT need to be finished, but it should be a work in progress
2.You must attend the labs in weeks 10 /11to take part in the peer review, or miss 25% of your assignment mark. 1st year: Fri 21st Nov 3.15 – 5.15pm 2nd year: Tues 25th Nov 2.15 – 4.15pm
A tip
For the assignment, you are expected to do something more than write a couple of lines of code within a function or event.
You should be working on a more complex program: putting the bits and pieces you have learned in lab class into a coherent whole
If this sounds hard, discuss it with the lab helper this week
Interactive behaviour of the pet
40 – 49%. Poor. Pet has major bugs, or is extremely derivative. Limited scripting skills demonstrated (e.g. just basic text output)
50 – 59% Adequate. Pet has at least one interactive behaviour. It demonstrates that basic scripting skills have been learned and used to respond to user input (typed text, or button clicking). Output could be text, sounds or animations.
Interactive behaviour of the pet
60 – 69% Good. Pet demonstrates a couple of interesting behaviours. It can respond to the surroundings and other creatures as well as the user.
70% + Excellent. Exhibit demonstrates a complex behaviour which requires more advanced scripting. For example, it could execute a sequence of behaviour under script control, or behave as a member of a flock.
Artificial Life
“Artificial life (commonly Alife or alife) is a field of study and an associated art form which examine systems related to life, its processes, and its evolution through simulations using computer models, robotics, and biochemistry.[1]” Wikipedia
Strong alife: "life is a process which can be abstracted away from any particular medium" John von Neumann
What do you think about this?
Artificial Life
“(the) law of ``uphill analysis and downhill synthesis'' applies... it's easier to design a mechanism from scratch to do something, than to figure out just how nature has contrived to do it; this suggests that maybe the natural way isn't really insuperably complicated.” Cosma Shalizi
Braitenburg’s Vehicles
An example of behaviour based robotics See http://www.amazon.co.uk/gp/reader/0262521121/ref=sib_dp_pt/277-
3507346-2749668#reader-page
A creature which is afraid of the light:More light produces faster movement. Less light produces slower movement. Darkness produces standstill.
Braitenburg’s Vehicles - example
“This run has three vehicles, each of a different type, and two lamps. Green is the obsessive one. She singlemindedly and frenetically searches for and attempts to ram the nearest and brightest light source, and has no regard for anything else (behaving like Braitenberg's Vehicle 2b). Blue has more self-control and more intelligence. She likes to find a cozy spot near a lamp and settle down, but she will flee if a predator comes too close. Red is the predator; Light doesn't interest her, only the movement of possible prey.”
http://people.cs.uchicago.edu/~wiseman/vehicles/animation-1.mov
Boids
An algorithm used for simulating flocking behaviour
Used in games and 3D animationshttp://www.red3d.com/cwr/boids/Complexity emerges from 3 simple rules:
Separation: steer to avoid crowding local flockmates Alignment: steer towards the average heading of
local flockmates Cohesion: steer to move toward the average position
of local flockmates
Scripting you will learn today
Cookie monster gets hungry again after a bit
Cookie monster grazes for foodCookie monster side-steps round
obstaclesCookie monster mummy and daddy make
babies
Delaying hunger pangs
How would you stop the monster getting hungry as soon as he has eaten?
Delaying hunger pangs
integer hungry = 0;
timer(){
llOwnerSay("Getting hungry again");
hungry =1;
}
eat(){
llOwnerSay("I found a cookie");
llSay(42, "eaten");
hungry = 0;
llOwnerSay("Burp. Not hungry anymore");
//set a timer so he doesn't get hungry for 30 seconds
llSetTimerEvent(15.0);
}
How would you make the cookie monster graze?Monster will sense a cookie and move
towards it. When close enough he will eat it.
Need to use sensor, llTarget and llMoveToTarget
Grazing solution part 1moveToCookie(vector cookiePos){
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
// Ask to be informed when we’re 0.5 metres from cookie
targetID = llTarget(cookiePos, 0.5 );
//start moving to cookie
llMoveToTarget(cookiePos, 0.9);
}
Grazing solution part 2sensor(integer num){
vector targetPos;
targetPos =llDetectedPos(0) + <1.0, 0.0, 0.0>;
if (hungry){
moveToCookie(targetPos);
}
else{
llOwnerSay("Quietly digesting");
}
}
Grazing solution part 3 at_target( integer number, vector targetpos, vector ourpos )
{
llOwnerSay("We've arrived!");
eat();
// Stop moving towards the destination
llStopMoveToTarget();
// Stop notifications of being there or not
llTargetRemove(targetID);
// Become non-physical
llSetStatus(STATUS_PHYSICS, FALSE);
}
Side step to avoid obstacles //we have detected that we have collided, so move out of the way
collision(integer num_detected){
llOwnerSay("Oi!");
vector pos = llGetPos() + <0.0, 2.0, 0.0>;
llSetStatus(STATUS_PHYSICS, TRUE);
llMoveToTarget(pos, 0.2);
}
Mating behaviour //we have detected that we have collided, so move out of the way collision(integer num_detected){ if (llDetectedName(0) == "CookieMonsterGreen"){ breed("green"); } else{
llOwnerSay("Oi!"); vector pos = llGetPos() + <0.0, 2.0, 0.0>; llSetStatus(STATUS_PHYSICS, TRUE); llMoveToTarget(pos, 0.2); }}
Mating behaviour //called under collision detection with another monster
breed(string name){ offset = <0.5, 0.0, 0.0>; vector velocity = <0.0, 0.0, 0.0>; llOwnerSay("Well, hey there gorgeous"); if (name == "green"){ llRezObject("babycookiemonster",
llGetPos() +offset, velocity, ZERO_ROTATION, 1);
}}
Mating behaviour (attached to baby) on_rez(integer startParam) { birth(startParam); }
birth(integer colour){ //mum was blue, dad was green, I should be cyan if (colour == 1){ llSetColor(<0.0, 1.0, 1.0>, ALL_SIDES); llSetLinkColor(LINK_SET, <0.0, 1.0, 1.0>, ALL_SIDES); } }
Homework
Work on your pet so you have something to show your reviewers next week
Finish off previous lab exercises (this will give you practice at writing the kinds of scripts you need for your pets)