Monday, January 28, 2013

Visualizing Fitness Function Landscapes

I'm currently preparing a project about game animation tools and technology. The project is exploring and leveraging technologies like physics simulation, optimization and machine learning. If you are interested, the recent review by Geijtenbeek and Pronost is a good starting point.

Related to the optimization of the control parameters of physics simulation, I'm trying to form an intuition about the properties of the related fitness function landscapes. It's impossible to accurately visualize the landscapes of high-dimensional biped motor control and planning problems, but here's a simple 2d physics example: throwing a ball in 2d with the angle and speed as the optimized variables, and allowing damped rebounds from the ground so that the ball trajectory is not just a simple parabola. This isn't exactly rocket science, but I wrote the code to as an exercise in interactive visualization in Matlab, which I stopped using while working outside Aalto.


It was my first time I tried to do implement the "up and down the ladder of abstraction", that is, letting the user explore a summary view (the fitness landscape) to browse concrete examples (the ball trajectories). There was some non-intuitive searching for the right places to put the getCursorInfo(), pause() and subplot() commands to prevent the display from freezing - hope this helps if anyone wants to do the same. I also tried to implement the UI using Matlab's linked data, but couldn't get the display refreshed.

Edit 29.1.2013: I was asked why there's peaks where there should be a continuous ridge. It's apparently because of the large timestep that causes a simulation error that varies as a function of how the floor contacts align with the timestep grid. It also depends on how the contact handling is implemented. The Matlab code below uses a smaller timestep and produces a more continuous ridge.

Here's the Matlab code:


minVel=1;
maxVel=5.0;
minAngle=-0.5*pi;
maxAngle=0.5*pi;
timeStep=0.02;
nSteps=100;
startPos=[0,1.5];
velSteps=64;
angleSteps=64;
E=zeros(velSteps,angleSteps);
target=[2, 0.5];
curve=zeros(nSteps,2);
curves=zeros(nSteps,2,velSteps,angleSteps);

%step over all ball launch speed and angle combinations
for velStep=0:velSteps,
    speed=minVel+(maxVel-minVel)*velStep/velSteps;
    for angleStep=0:angleSteps,
        angle=minAngle+(maxAngle-minAngle)*angleStep/angleSteps;
        pos=startPos;
        vel=[speed*cos(angle), speed*sin(angle)];
        closestDist=10000;
        closest=[0; 0];
        closestTime=0;
        
        %simulate the ball trajectory for this launch velocity
        for n=1:nSteps,
            %save this trajectory point
            curve(n,:)=pos;
            
            %update closest to target
            dist=norm(pos-target,2);
            if (dist<closestDist)
                closestDist=dist;
                closest=pos;
                closestTime=n*timeStep;
            end
            
            %physics update
            pos=pos+vel*timeStep;
            vel(2)=vel(2)-9.81*timeStep;
            
            %bounce from floor
            if (pos(2)<0 && vel(2)<0)
                timeInsideGround=pos(2)/vel(2);
                vel(2)=-0.7*vel(2);
                timeAfterBounce=max(0,timeStep-timeInsideGround);
                pos(2)=timeAfterBounce*vel(2);
            end
            
        end    
        %store the whole trajectory
        curves(:,:,velStep+1,angleStep+1)=curve;

        %update fitness
distanceThreshold=0.1;
        fitness=0.5+0.5*tanh(-(closestDist-distanceThreshold)/0.05);

        %soft threshold for hitting time
        timeThreshold=1;
        fitness=fitness*(0.5+0.5*tanh(-(closestTime-timeThreshold)/0.05));
        
        %store fitness function value for these params
        E(velStep+1,angleStep+1)=fitness;
    end
end
%plot the fitness surface
subplot(1,2,1);
surf(E);

%get the handle for querying data cursor info about the fitness
h=gcf;
dcm_obj = datacursormode(h)

%plot a trajectory of the ball
subplot(1,2,2);
curve=curves(:,:,1,1);
plot(curve(:,1),curve(:,2));

%in a loop, keep plotting the ball trajectories
pause on;
while 1
    info_struct = getCursorInfo(dcm_obj);
    if size(info_struct)~=0    
        curve=curves(:,:,floor(info_struct.Position(2)),floor(info_struct.Position(1)));
        subplot(1,2,2);
        plot(curve(:,1),curve(:,2));
        axis([0 4.5 0 3])
        hold on;
        plot(target(1),target(2),'c+:')
        hold off;
    end
    %have to pause to let the display refresh
    pause(0.01);
end

Thursday, January 24, 2013

Game marketing resources


To help our students in promoting their games, I did about an hour's worth of searching, both using Google and digging up old stuff from my brain. Dumping the results here for future reference, roughly in the order of importance.

About creating press releases etc.

http://gdcvault.com/play/1014971/Indie-s-Got-PR-Talent

http://arstechnica.com/gaming/2011/12/how-to-market-your-indie-games-ben-kucheras-lecture-at-run-jump-dev//

http://gamasutra.com/view/news/167706/Ask_Gamasutra_How_to_annoy_a_games_journalist_with_a_press_release.php#.UQE7syfZZ8E

http://www.gamestyleguide.com/VideoGameStyleGuideeBook.pdf (Talk to the journalists using their own language)

http://dopresskit.com/  Presskit making tool. Note: I haven't tried it personally.

How to make good trailers

http://indiegames.com/2012/04/ask_indiegames_what_makes_an_e.html

http://blog.kertgartner.com/2012/03/making-entertaining-and-engaging-video-game-trailers/

http://www.indiegamegirl.com/how-to-make-a-video-game-trailer-kick-ass/

http://www.ign.com/articles/2012/05/01/five-sure-signs-of-an-awesome-game-trailer

http://www.reddit.com/r/Games/comments/16g1x7/that_great_cyberpunk_2077_teaser_got_me_thinking/

http://www.reddit.com/r/Games/comments/zd84h/what_have_been_the_best_game_trailers_you_have/

http://gametheoryonline.com/2011/05/06/video-game-marketing-creating-game-tr

Stats to inform your decisions: http://engage.tmgcustommedia.com/2011/04/101-online-video-stats-to-make-your-eyes-glaze-over/

Tuesday, January 22, 2013

A note on backstory and child's play

The backstory is perhaps the most common literary device used in games. Understanding its importance is easy if one has followed the mobile game space, where many hugely successful games have a story-based motivation that can be expressed in a single sentence, such as "The frog wants the candy" or "The birds are angry because the pigs stole their eggs".

What wasn't obvious to me until I became a dad was that the backstory works perfectly similarly in child's play. It's been amazing to see firsthand how big a difference it can make in motivating play. For example, when its -10 centigrades outside, a common temperature this winter, my son hates to go out because putting on all the layers of clothes is such a tedious process. However, he immediately jumps up from the sofa if I throw in a backstory.

Me: "Let's go outside sled riding"
Son: "I don't want to go outside. It's boring. I don't want to wear the overalls."
Me: "But we can pretend to be Angry Birds. You can be the laser bird and have a snowball as a laser."
Son: "Cool! Let's go right away! Come on, dad!"

Malone's and Lepper's taxonomy of intrinsic motivation comprises four main motivating factors: challenge, curiosity, control, fantasy. Having a backstory provides a fantasy setting, and also provides material for curiosity, because one can explore how far the fantasy can be extended by using the play space, e.g., the snowballs. It can also inspire the child to come up with challenges. Many times, if I'm too tired to play cops and robbers, my son is happy to do all the running around by himself while I just sit on the couch and press imaginary buttons to control him on an imaginary iPad.

"Now I'm in level 13, and this is really hard. There's dynamite and I must not fall into the water (floor). Now press the button that makes me run to the door."

"You are the laser piggy. I must not hit the lasers."

Pretty contradictory considering that digital games are supposed to promote a sedentary lifestyle. Of course my son would never let go of the iPad voluntarily, but allowing him a controlled amount of daily gameplay seems to only boost his physical play by providing new backstories, similar to the books we read.





Saturday, January 19, 2013

Quick time events vs. timeline-based rhythm games


Using quick time events (QTE:s) is a form of trying to have a cake and eat it too. The game designer wants to control the pacing and drama, but also let the player control the game. The two are difficult to combine, and often the player's control over events is illusory, with the branching storyline soon converging back into one or few options to save production costs. But do we always have to create the illusion of control? As it happens, there's a genre where the players are perfectly happy to play along with completely choreographed action: dancing and rhythm games. Can we combine rhythm and action adventure genres in new and fruitful ways?


Yesterday, I finally got to use my PS3 at work for playing. I spent some time on Dark Souls, Uncharted 3 and Heavy Rain, which got me again thinking about quick time events. At some point, I was wondering that there's not really an analogous mechanic for Kinect games, but actually Kinect Star Wars does have them in the form of "anim GIF" prompts that appear contextually, indicating that one has to kick, jump etc. to proceed.

When playing Heavy Rain, it struck me that it's actually pretty similar to Guitar Hero. Both have action that you play along with in an abstract, simplified manner. In an ideal case, there's an illusion of actually performing a fight choreography or playing the notes of a song, to the extent that a Guitar Hero guitarist can play pretty plausibly on stage at the Video Games Live -concerts, as shown in this video (or actually not shown very well, since the camera is behind the player. I've seen better footage but this is the best I could find right now):

In GH, there's five buttons that represent all notes that one can play. Actual melodies use more, and the meaning of the buttons changes based on the previous ones. Even with just five buttons, one can approximate a melody so that it mostly goes up and down as it should, but the actual intervals are incorrect. If I remember correctly, this actually corresponds to the first stages of the developmental continuum of singing (couldn't check because I don't have access to the full paper from where I'm writing). A video for refreshing one's memory:

In Heavy Rain, you use the right analog stick and shake the controller to approximate the movements of the characters. A video:



The differences between the two

  • Heavy Rain, like most games with QTE:s, features some level of branching action based on whether the player reacts to the events on time, whereas in Guitar Hero, the song goes on, and the feedback from misses is implemented through scoring and sound effects. Also, if you make enough mistakes, the song ends prematurely and you get booed out (if I remember correctly - later music games usually let you always finish the songs)
  • Guitar Hero and many other music games feature some form of a visual timeline, where one can see multiple approaching events and plan one's action. Action adventure QTE:s usually pop up one by one without such 'prediction horizon'.
  • Action adventure QTE:s provide the player a reaction challenge, whereas rhythm games require coordination and precision.

I'm not that fond of QTE:s in fight scenes, because the reaction time is really difficult to tune - there seems to be only a tiny sweet zone between frustrating and boring, and it's different for every player. I'm more of a precision and coordination kind of guy, which brings me to wonder if one could actually have rhythm game style QTE timeline somehow overlaid in an action adventure fighting sequence. This would allow a more rapid pace of fighting, similar to many Hong Kong kung-fu movies:


An alternative to a timeline is to use multiple symbols that appear a predetermined time before the player should act, which most QTE:s do anyway, but in rhythm games the visual display of the remaining time to the correct moment is more prominent, as in Dance Evolution:



The benefit of the approach I'm proposing is that the timing and coordination challenges could be more interesting than the reaction challenge of traditional QTE:s, and only a single choreography without branches would be needed. The obvious problem is to design feedback that makes sense if the player's performance is less than perfect - do we want the "perfect", "good" etc. notifications from dance games or something else? Is the fight over if the player misses too many events? Should there be branching after all, and do we actually need two branches per event, one for being too late and the other for acting too early.

As a Google search will tell you, there's already many games with both rhythm and fighting elements. However, fighting to the beat of music as in this Kick Beat gameplay video or in Rhythm Fighter is a bit too much for me.

I really like the choreography, music and soundscape in Uncharted 3 and Heavy Rain. I just wish I could see more than one event in advance to get into the flow of the choreography and still have a reasonable challenge, similar to reading a note sheet when playing an instrument. This is what, e.g. Dance Central and Guitar Hero do, although due to the complexity of the player's realistic movements in DC, the choreography is not fully visualized on a timeline. Instead, one sees a timeline of flashcards, which have to be memorized in the training mode.

For Uncharted 3 and Heavy Rain, I think the action abstraction level is pretty much correct, but I guess I just feel strange trying to react quickly to button symbols shown on screen instead of the opponent's actual actions. The translation of symbols to actions feels more natural when given more time and when seeing multiple symbols at a time, maybe because the relations of the symbols to each other (e.g., the intervals between musical notes) help in decoding and executing the correct the motor sequence.

If anyone reads this and knows about this kind of experiments, please let me know.

Additional thoughts: The illusion of playing a guitar or fighting with QTE:s is not there at first, but at least it happens with me once I've become accustomed to the interface, I don't have to think of the real-world actions, I can focus on the results and feedback, and I get the timing right. Principles at work: We project ourselves to the avatar, our motor system assimilates the game interface through repetition, correlation is perceived as causation, our sensory integration system perceives two events as one if they happen close to each other in time. The same assimilation of the interface etc. happens of course with all action games, but the interesting thing is that it happens despite the player not having control or initiating the actions.

About dance game timeline displays and other choreography visualizations: The visualization of full-body movement over time in a compact and intuitive manner remains a research challenge, although various notations have been developed.

Friday, January 11, 2013

Trampoline games update



Uploaded a new video to YouTube and linked it to the work-in-progress manuscript submitted for CHI 2013. My previous post explains some of the goals and rationale behind the design.