triptico.com

Un naufragio personal

Documents

A simple pseudorandom number generator

Recently, a member of a game development mailing list asked me what random number algorithm I used in the Space Plumber game. This small document describes it.

First, I want to remember everyone that real random numbers are impossible to create on a computer because computing is deterministic BLAH BLAH BLAH I JUST WANT THE FUCKING CODE.

Ok, here it is:

 unsigned int sp_random(unsigned int *seed, unsigned int range)
 /* Space Plumber's random */
 {
     *seed = (*seed * 58321) + 11113;
     return (*seed >> 16) % range;
 }

It accepts two arguments:

seed
a pointer to an integer containing the random seed. If you only need one, you can use a global value. As a start fill it with the output of time() or something like that.
range
The maximum value to return, plus 1. The maximum range is 65535.

The sp_ in the name, unsurprisingly, comes from Space Plumber. It's not written exactly this way there, though.

The output value will be an integer from 0 to range-1, sufficiently unexpected to be used as a random number in games and such (don't make me laugh about cryptographically-secure values).

It's based on the wrapping of the 32 bit multiplying operation, so it won't work with floating point arithmetic.

From C to C++: A quick reference for aging programmers

So you were a great system programmer, back in the old days; your low level programs were celebrated by clever people, you loved C pointers and some days even considered Assembler as an option. You were happy and self-confident. But somehow you screwed something, got trapped in a time vortex and you ended today, trying to maintain or develop a program using that pesky Object Oriented Programming model in something called C++. I understand you; follow this guide and learn a bunch of things that will put you out of your misery and understand this brave new world.

More...

Artemus 5 Templating Language Overview

Artemus is a template toolkit. It filters text files, parsing, compiling and executing code surrounded by special marks (leaving the rest untouched) and concatenating everything as output. Its main purpose is to filter HTML files, but it can be used for any scripting need related to text filtering and substitution.

More...

MPSL Function Library Reference

This reference documents version 2.2.0 of the MPSL Function Library.

More...

MPSL Overview

MPSL (Minimum Profit Scripting Language) is a programming language concieved as a scripting engine for the Minimum Profit Text Editor, though it can also be used as a general-purpose programming tool.

More...

Minimum Profit character encoding support

This document describes the character encodings supported by the Minimum Profit text editor and the performed autodetection tests.

More...

Minimum Profit Keycodes

Table with Minimum Profit's keycodes and their default assigned actions.

More...

Una amistosa introdución a la codificación de vídeo, parte 3: sonido con pérdida

Por Mark Pilgrim, traducción de Ángel Ortega. Artículo original: http://diveintomark.org/archives/2008/12/30/give-part-3-lossy-audio-codecs

More...

LWN: Btrfs apunta a su inclusión

Por Jonathan Corbet, traducción de Ángel Ortega. Artículo original: http://lwn.net/Articles/313682/

More...

Una amistosa introdución a la codificación de vídeo, parte 2: vídeo con pérdida

Por Mark Pilgrim, traducción de Ángel Ortega. Artículo original: http://diveintomark.org/archives/2008/12/19/give-part-2-lossy-video-codecs

More...

LWN: Btrfs, ¿incorporarlo al núcleo principal?

Por Jake Edge, traducción de Ángel Ortega. Artículo original: http://lwn.net/Articles/302251/

More...

Una amistosa introdución a la codificación de vídeo, parte 1: contenedores

Por Mark Pilgrim, traducción de Ángel Ortega. Artículo original: http://diveintomark.org/archives/2008/12/18/give-part-1-container-formats

More...

El algoritmo Diffie-Hellman

El algoritmo Diffie-Hellman permite que dos partes, comunicándose mediante un canal no cifrado, se pongan de acuerdo en un valor numérico sin que un tercero, que tiene acceso completo a la conversación, pueda conocerlo o calcularlo, al menos en un tiempo práctico.

More...

Gruta FAQ

This is a list of Frequently Asked Questions about the Gruta web content management system.

More...

Gruta Installation Guide

This document contains a brief guide for the installation of Gruta, the web content management system.

More...

Gruta - command line tool

Manipulates Gruta sources directly.

More...

Minimum Profit Action Reference

Minimum Profit actions are editor commands that can be directly bound to the menu or a key.

More...

MPSL internals

This document describes some internal details of this MPSL implementation.

More...

MPSL C API

This reference documents version 2.2.0 of the C API.

More...

MPDM overview

MPDM (Minimum Profit Data Manager) is a lightweight library that provides C programs with a rich set of useful data types as scalars, dynamic arrays or hashes, similar to those of the Perl language. Also, it contains a rudimentary garbage collector that alleviates the need to keep track of data no longer useful, as well as help for operating system abstraction and portability, regular expressions, string manipulation, character set conversions, localization and file I/O access.

More...

MPDM C API

This reference documents version 2.1.1 of the C API.

More...

Minimum Profit Data Model

This document describes all the MPSL data structures that build the Minimum Profit Text Editor, with examples showing how to change or update its behaviour.

More...

Minimum Profit Configuration Directives

The following configuration values can be set in the configuration files, executed from the command line or from the Execute MPSL code... option in the Edit menu. So, for example, if you always want automatic indentation, word wrapping at column 75 and a special ispell command, you can add the following MPSL code to ~/.mp.mpsl or /etc/mp.mpsl:

More...

Minimum Profit cookbook

This document includes some recipes for the Minimum Profit text editor.

More...

Minimum Profit: Creating interactive dialog boxes

This document is a reference to the mp.form() function and associated tools that ease interaction with the user from inside the Minimum Profit Text Editor.

More...

Cómo conectar a Internet con Movistar usando Linux, Bluetooth y un Nokia 6630

Este documento describe los pasos para una distribución Debian, pero en otras debería ser más o menos lo mismo. Para usar esto es necesario tener el soporte Bluetooth funcionando (mi documento Building a Bluetooth network with Linux puede servir de ayuda). Esta configuración debería servir igual para GPRS ó UMTS: mi teléfono móvil conmuta de uno a otro automáticamente según la cobertura.

More...

Unicode, UTF-8 and all that: An intentionally incomplete character set introduction for hasty C programmers

Character set usage is something almost always taken as an afterthought in many C projects, and char * strings seem sufficient. They aren't, at least in many cases. Take Unicode into account. Read this brief guide and make the decision to implement textual data to support something more than english before you start coding.

More...

The Bky Manual

This document is a brief manual for the Bky Version Control System.

More...

Ann Hell Scripting - I: Basic Commands

This document describes the basic commands for the Ann Hell Scripting language. These commands are those directly related with the music being generated, as notes and their appropriate properties and global song information as tempo and measure. Also, a global description of the AHS syntax is included here.

More...

Ann Hell Scripting - II: Extended Commands

This document describes the extended commands for the Ann Hell Scripting language. These directives are not pure music instructions or are specific to a given output mode.

More...