19 March 2012

Converting MP4 to MP3

Problem

On Ubuntu 11.10, this error gets printed when using ffmpeg:

Encoder (codec id 86017) not found for output stream #0.0
It means that the codecs in charge of converting into mp3 are missing.

Solution

A quick and dirty solution:

sudo apt-get install libavcodec-extra-53
Note that the number at the end (53) may change over time. Compiling ffmpeg by hand from the source and installing the eventually missing codecs may be cleaner.

To check that mp3 codecs are now present:

ffmpeg -codecs | grep mp3
This returns:
  EA    libmp3lame      libmp3lame MP3 (MPEG audio layer 3)
 D A    mp3             MP3 (MPEG audio layer 3)
 D A    mp3adu          ADU (Application Data Unit) MP3 (MPEG audio layer 3)
 D A    mp3adufloat     ADU (Application Data Unit) MP3 (MPEG audio layer 3)
 D A    mp3float        MP3 (MPEG audio layer 3)
 D A    mp3on4          MP3onMP4
 D A    mp3on4float     MP3onMP4

Converting

To convert one mp4 to mp3, use:

ffmpeg -i a.mp4 -f mp3 -ab 320000 -vn a.mp3
-i to specify the input, -f the output format, -ab for the bitrate, -vn for no video.

Below, a script that converts all the mp4 in the current folder into mp3 of the same name.

#!/bin/sh
for f in *.mp4
do
    name=`echo "$f" | sed -e "s/.mp4$//g"`
    ffmpeg -i "$f" -f mp3 -ab 320000 -vn "$name.mp3"
done

Links

14 March 2012

Rcmdr on Ubuntu

On Windows, R comes with its own GUI, but on Ubuntu, GUIs such as Rcmdr have to be installed manually.

Software sources

Add a local CRAN mirror to Ubuntu, e.g. http://cran.stat.ucla.edu/, which corresponds to USA-California 2. Remember the mirror you add, because it will be the only one that will be allowed by Ubuntu to fetch software packages. Anyway, add /bin/linux/ubuntu/oneiric at the end of the URL (change oneiric for your ubuntu version). This should give the screenshot below:

Then execute:

sudo apt-get update
sudo apt-get install r-base r-base-dev

Installing Rcmdr in R

sudo R

Then in the R command line:

install.packages("Rcmdr")

Then, finish the installation of Rcmdr by installing the missing dependencies:

library(Rcmdr)

A popup appears, select "CRAN mirror" (not "local folder"), click OK, and the console should start printing lines like below:

Loading required package: tcltk
Loading required package: car
Loading required package: MASS
Loading required package: nnet
Loading required package: survival
Loading required package: splines
also installing the dependency 'matrixcalc'

trying URL 'http://cran.stat.ucla.edu/src/contrib/matrixcalc_1.0-1.tar.gz'
Content type 'application/x-tar' length 8436 bytes
opened URL

...

The downloaded packages are in
 '/tmp/Rtmp6X20rs/downloaded_packages'

And the Rcmdr window should appear. To run Rcmdr in the future, type library(Rcmdr) in the R command prompt. Ctrl-A then Ctrl-R to run everything.

Encountered errors

'Rcmdr' is not available: An error like package 'Rcmdr' is not available (for r version 2.13.1) pops up if R was installed from the Ubuntu repository. The current version (as of March 2012) is 2.14.2. sudo apt-get update, then sudo apt-get install r-base r-base-dev should fix this. If you have the same error with not available (for r version 2.14.1), it may be that no CRAN mirror was added in the software sources to download Rcmdr from.

GPG error: The software center notifies you about new R updates from whichever mirror you picked. When sudo apt-get update, you get the following error:

W: GPG error: http://cran.stat.ucla.edu oneiric/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9

This article provides the solution:

gpg --keyserver keyserver.ubuntu.com --recv 51716619E084DAB9
gpg --export --armor 51716619E084DAB9 | sudo apt-key add -

Sources

04 March 2012

The Beautiful Road: A Writer’s Guide to Putting Gameplay First

Notes from a CGVW talk by Dave Kosak, a Blizzard quest designer, at UC Irvine on February 22nd 2012. Original talk called "The Beautiful Road: A Writer’s Guide to Putting Gameplay First" delivered at GDC Online 2011.
TLDR: When gameplay comes first, story-telling must make it beautiful, not suffocate it. There are different ways than text to convey story and characters.

The problem

Games can be story-driven (RPG or interactive fiction), gameplay-driven (Blizzard's "gameplay first"), technology-driven (early games on Kinect, or to show off a 3D engine like Crysis), or money-driven (Zynga). How can stories be included in gameplay-driven games?

Looking at other media, telling a story requires different amounts of time: books take 10 hours, movies 2 hours, sitcom episodes 20 min. Books are walls of text, movies have long scripts, and sitcon episodes have at most 3-page scripts.
In MMOs, it's hard to display walls of text: there's a limited amount of screen and UI real-estate, and players have a limited amount of attention. Players can pay attention to the story most in calm solo exploration, slightly less in group quests, even less in dungeon raids, and nearly not at all in intense PvP.

In Diablo, the core gameplay activity is kill -> loot -> sell -> repeat. Content designers should not obstruct the core activity, e.g. with cutscenes during game action. Instead, content designers should enhance the core gameplay activity. If gameplay is a road, content should be beautiful flowers on the side of the road.

Brevity is key. Example: the Red Dead Redemption mission called free the captured sheriff. When the player sees this line popping on the screen, and the minimap showing markers for sheriff, outlaws, and nearby weapons, she figures out herself what to do first: she could go save the sheriff, kill outlaws, or look for a powerful weapon. Moreover, the quest becomes an answer to the situation presented to the player: why has the sheriff been captured? Which kind of person is the sheriff?

Telling a story without a wall of text is possible through:

  • dynamic level design
  • dynamic environment aesthetics (changing to reflect quest progression/completion)
  • events triggered when player arrives
  • hints in NPC or enemy dialogues

Characters

Character geometry: balance between too few traits = cliche, and too many traits = too complicated + boring + harder to understand. Example: Sylvanas Windrunner is persistent, protective, and hard-hearted. When she becomes undead, all her traits are even more accentuated. Other example: Han Solo is cocky, scoundrel, and egocentric.

Interactions with other characters and the background of the character let us know, without the need for a wall of text, a character's traits. Ex: Han Solo leaves his friends when they need him, Luke meets him in a shady place, he owes money to Jabba.

Quirks are not traits: quirks are minor and only serve to further individualise a character. You can find a list of traits there.

  • 1-dim characters: enemies or minor allies. Ex: Hungry ogre.
  • 2-dim, with 1 expected and 1 unexpected = interesting: quest givers and companions. Ex: elf druid who is protective (expected) + violent (unexpected).
  • 3-dim: franchise characters such as Arthas = cocky + practical + naive. Only and exactly those 3 traits make him pick Frostmourne. When he turns undead, naive becomes power-hungry.
  • 4-dim: Freeman's character diamond. Often leads to contradictions between traits, also called masks, which can either be total pretense (clown pretends he's happy but is actually depressed), partially revealing, or representing a character's aspirations. Used in marketing personas and novels.

How to compel people to a character: Cf Writing screenplays that sell:

  • sympathy
  • jeopardy (we want Indiana Jones to survive)
  • talent/good at what they're doing
  • funny
  • heroic/noble
  • independent/do their own thing/own quirks
  • artistic/admires beauty (ex: Sherlock Holmes plays the violin)

Cliches can be used as a shortcut to establish a character. When established, take the cliche, and throw it away: Her eyes were as blue as the sky can become Her eyes sparkled like saphires on black velvet (jewels give a refined connotation) or Her eyes were the same milky blue as my mother's eyes were before I killed her (surprise and suspense!).

Social status shows differences between high-class people (smooth movement, complete sentences, slow speech, direct eye contact) and lower-class people. Body language also works. Cf the movie 300. Changing status generates interesting dramatic situations. Ex: the boss has high status at work, but when he's back home, he's low status obeying his wife.

01 March 2012

Netgames 2005

Summary of selected papers from the NetGames 2005 conference.

Traffic Characteristics of a Massively Multi-player Online Role Playing Game, by Kim et al.

  • Port mirroring through 1Gbps hub and tcpdump of 92 hours of a Lineage 2 server in December 2004. TCP packets.
  • Both upstream and downstream increase linearly with number of concurrent users.
  • Play session duration: 3 hours average, 26 min median, 40+ hours 99%
Stream Number of packets Ratio of data packets Payload (avg, median, and 99%) Bandwidth Bandwidth per user
Upstream (clients to server) 6.28 billions 23% (the rest are ACKs, SYNs, or FINs) 19, 20, 50 bytes max 9 Mbps 1.6 kbps
Downstream (server to clients) 6.43 billions 98% 318, 161, 1459 (= MTU) bytes max 140 Mbps 20 kbps

Dynamic Microcell Assignment for Massively Multiplayer Online Gaming, by De Vleeschauwer et al.

  • Divide the world in atomic square microcells. Compute each microcell's load induced by processing player actions (weight=1), forwarding player actions to neighbouring cells (w=0.05 if cells on same machine, w=0.1 if cells on different machines), receiving forwarded actions from neighbouring cells (w=0.2, w=0.4), and moving players to and from neighbouring cells (w=3, w=15). Then, assign cells to servers so that no server has a higher load than another server.
  • Algorithms to assign cells to servers:
    • Greedy: processes cells in descending order of their load, and assigns them to the server currently with the lowest load. Pro: fast. Con: does not take locality into account.
    • Clustering: start with each cell is a cluster. Merge two clusters that have the lowest load until there are as many clusters as servers. Con: in the last few steps, some heavy-load clusters are merged and may be assigned to servers that can't handle them.
    • Simulated annealing: start by randomly assigning cells to servers, then randomly swap or move cells around to find a better solution, and keep iterating to refine the solution. Able to find very good solutions if the initial solution comes from another algorithm.
    • Integer linear programming for the optimal deployment. Pro: optimal. Con: takes days to compute, but a timeout can be specified to get a suboptimal solution. (But then, other algorithms give better results faster).
  • Evaluation: If player hotspots are spread randomly, the maximum server load can be reduced by 30% compared to the baseline with one large cell of constant size per server. But if hotspots are regularly spread, and there's as many hotspots as available servers, then the microcell algorithms are at least 10% worse than the baseline. In general, simulated annealing starting from a greedy solution was the most efficient of the algorithms.