Friday, 13 January 2012

My Perforce init.d script

-------------
#!/bin/sh -e
export P4JOURNAL=/var/log/perforce/journal
export P4LOG=/var/log/perforce/p4err
export P4ROOT=/var/perforce_depot
export P4PORT=1666

PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
. /lib/lsb/init-functions

p4start="p4d -d"
p4stop="p4 admin stop"
p4user=perforce

case "$1" in
start)
log_action_begin_msg "Starting Perforce Server"
daemon -u $p4user $p4start;
;;
stop)
log_action_begin_msg "Stopping Perforce Server"
p4Pid=$(pidof /usr/local/bin/p4d);
kill -9 $p4Pid;
;;

restart)
stop
start
;;

*)
echo "Usage: /etc/init.d/perforce (start|stop|restart)"
exit 1
;;

esac
exit 0
--------------

Sunday, 6 November 2011

Cooperation and Engagement

Extremely insightful lecture by Matt Leacock, game designer of the co-op board game, Pandemic.

I especially found interesting how he approaches iteration and he seems very well read in game design theory.
Also, his visualisation of Mihaly Csikszentmihlyi's Flow principal is very well presented.

Monday, 3 October 2011

Learn The Trigonometry Functions

Sunday, 2 October 2011

Beyond the Game

I've recently watched Beyond the Game, a documentary about the competitive Warcraft III: Reign of Chaos scene in Asia.
It's very interesting, especially the fact that they compete at a high level and train like professional chess players.

But the difference is that chess is an open game system, the "algorithms" & mechanics of the game are exposed and played in a physical space.
But Warcraft runs in a total virtual plane were the game mechanics are somewhat hidden, I know, as a player, that there's a certain randomization on almost every damage hit but I don't see it being run, I only see the result exposed by the visual feedback layer.

A dice roll in a video game compared to one done with a real dice and thrown by an human hand will always have a certain degree of suspicious development because we don't see the actual process but only the result.

That's why I find it very fascinating that some will want to develop mastery of a video game when at the end, complete understanding of the system & control over it can be subtly manipulated by the makers of the system, especially in the context a lot of competitive gaming do not actually freeze to a specific build of the game but do take into account the developer's patches.

Simple Solution: Reading Twitter Feeds

I was working on a way to feed Twitter messages into an indie game prototype last March. Basically, certain events and unlocks could be triggered by specific commands embedded in subtle Twitter messages.

I was slamming my head against Twitter API and JSON, when it clicked, I could simply read the generated RSS feed and parse out what I need.

In other words, I find that most of the time, it's easier to bypass the official API of the service provider and always check for simple alternatives.

Links:
iPhone SDK: First Steps With JSON Data Using the Twitter API
With Just 3 Lines Of Code Add Twitter/Facebook Into Your iOS App

Use self()

I’m building a database abstract layer in PHP using a Singleton pattern, I based my code the following article.


In the comments, I found that you can self-instantiate a class with “self” instead of calling it by name, very useful if you plan to change the class name over time.


Must re-write code if you change the class name:


self::$m_pInstance = new Database();

No worries with self():


self::$m_pInstance = new self();

PHP & Enums

Enums are not native to PHP, at least not for the moment but I found a way to simulate with the help of this post on stackoverflow.

<?php

class DiceEnum
{
        const d4 = 4;
        const d6 = 6;
        const d8 = 8;
        const d10 = 10;
        const d12 = 12;
        const d20 = 20;
}
?>

But if I base myself on the SPL documentation, it’s seems we are going to have a supported native integration very soon.