Rock-Paper-Scissors
Don’t you just love capitalized titles? Anyway, I red the following a few days ago:
Rock Paper Scissors – A Method for Competitive Game Play Design
I strongly recommend its reading to anyone interested in game-design. It explains the RPS technique for multiplayer game design, and shows this model at work in videogames, sports and other types of competitive games.
Just to explain a bit:
A game applying the RPS model must have a set of different attack and defend moves which cancel each other in a way that no move has an advantege over the others.
This should allow the player to identify quickly and through experimentation which are the options available to him and how to counter them.
A player may choose to act randomly and quickly as an strategy which prevents the oponent from distinguishing an attack pattern, which would be easily countered. But this takes the point of the game, which becomes not one of strategy but one of simple luck. To stop this from happening “signals” are introduced to the model.
Signals announce an attack just before its occurence. They must be identifiable under normal conditions, that means not faster than the normal reaction of a human and neither as slow as to allow anyone to counter it without effort.
On these conditions the game may stall as players choose not to begin a strike, since skilled players develop conditioned reflexes to the signals. This kind of strategy (“turtling”) is not desirable, therefore separation between signal and attack is introduced.
Separation between signal and attack allows “fakes” to be thrown, that means signals which are not followed by its corresponding attack. “Faking” ruins the turtling strategy since one could fall to a fake leaving oneself open. The player has to read more into the game and into the opponents, and the game becomes more about the players and less about the game mechanichs. This is the scenario that RPS wants to achieve.
What I didn’t found explained in the article is how to apply RPS in competitive team play game design. The model should be appliable very simply just by using the RPS on one-on-one confrontations, but the team play conditions allows for richer strategies that aren’t considered in the article. It’s a doubt I have worthy of more research…
PHP Wizardry Lessons: Parsing CSV
The young apprentice asked fearfully the old and wise wizard how to parse a CSV file (plain text format used mostly in spreadsheet apps like MS Excel), because he knew how to use
but this only worked with files, not with variables already in memory. The old wizard looked him seriously and answered with a reproval – “no wizard that is proud of being such would fear such a trivial thing as parsing a plain text file”. Then he took from his magic hat his old book “the one thousand and one most powerful and dangerous regular expressions”. He went through the pages slowly and ceremonially. Lastly he closed the book and took a deep breath. Holding his breath he wrote the following on the floor (reciting aloud a regular expression would look stupid, wouldn’t it?):
/(?<=^|,)(“(.|\n)*(?<!”)”|.*)(,|$)/Um
The old wizard explain no more, that’s why we’ll look a little more into the mystics behind the power of this regexp.
On execution, this regexp applied sequentially to a string the way
does, the result will be each one the fields of the CSV. The content of each will be captured by the first parenthesis, but this must be processed first, because the CSV format allows fields to be enclosed by double quotes which can have double quotes enconded by duplicating them (“….”"…”).
To know when a row ends we must check the third parenthesis, which captures the end of the field (,|$). If the captured content is empty, a row end was found (the new line). Note that it is not safe to split first in lines and then parse each line, because there can be fields which hold a line break, using the double quotes to hold this character.
Each part of the expression has an specific purpose:
(?<=^|,) is a back assertion which assures that each regexp run starts where the one before ended, that is a comma or a line break, or the beginning of the string (for the first run).
“(.|\n)*(?<!”)” is the expression that looks for fields that use the double quotes. The can hold line breaks (look at .|\n), and it has a back assertion to prevent that a double quote followed by another double quote is interpreted as the end of the field.
|.* is the expression that capture fields that don’t follow the double quotes format, in case that fails.
(,|$) is the expression that captures the field end, which can be a comma or a line end.
U (ungreedy) and m (multiline) modifiers are necessary to prevent expressions to keep capturing beyond the intented end of it (ungreedy), and so that ^ and $ also match line breaks.
The full content of the spell, that builds the array using the results of preg_match_all can be found at:
http://www.martinalterisio.com.ar/php-spell-book/parse-csv.php
—-
But the old wizard left other less cryptic solutions untold, maybe because of his senililty, maybe because he couldn’t keep up with the latest spells. All those who have reached level 5 of PHP wizardry (PHP version 5.x) have new options in their skills menu. Just copy&paste (skill you should have probably acquired while being an apprentice) the example code for the custom stream wrappers in the PHP manual:
http://www.php.net/stream_wrapper_register
Once the summon of the new stream wrapper has been completed, we can use global variables as files:
$csv = “….”;
$fp = fopen(“var://csv”, “r”);
while ($data = fgetcsv($fp)) {
…etc…
}
For those who lack the copy&paste skill (shame on you) here you can look the stream wrapper code:
http://www.martinalterisio.com.ar/php-spell-book/VariableStream.phps
“Professional SEO With PHP” Free (as in “you-only-got-a-taste-of-it”) Chapter
In another most evident marketing tactic, we get a free chapter, which says a little but promises much more for those who buy the rest of the book, from “Professional SEO With PHP”. This book explains common SEO techniques applied using the PHP programming language. The chapter can be downloaded in:
http://www.seoegghead.com/attachments/00929c01.p1.pdf
This blog post talks about this:
http://www.seoegghead.com/blog/seo/f…-php-p196.html
The chapter begins with a nice, yet incomplete, introduction to the topic. It explains clearly what the problem is (what are we trying to achieve) and who are involved in the process of solving it. Likewise it explains what are our objectives and position as the ones in charge of SEO. Still, it doesn’t say much about HOW we can solve this problem.
I strongly suggest reading page 5, which establishes the most important thing about SEO: we’re not designing a communication only with humans, there are other readers in the web business that have a differente perception of the content we pusblish. Those are the one we less understand, since they are the algorithms that crawl our site compiling information for a search engine. The SEO must be involved since the early stages of the site conception, where communication decisions are taken that will decide which is the best course of action for developing the site. In this page, there is algo a link to an onlice tool that caught my eye:
http://www.seochat.com/seo-tools/spider-simulator/
… which presents us with what would look like the “view” a search engine robot would have of a specific url.
Following pages aren’t even worth reading. They are only technical instructions to setup the development enviroment required to do the exercises in the book, which we will have to buy if we want to do them.