Racing 4k --> 4k Grand Prix Simulator



Version 0.0: Basic
Version 0.1: Added splines.
Version 0.2: Faked physics. Marks on the ground.
Version 0.3 (current): AI. New Circuits.
Version 1.0: 4k version. Some bugs fixed. Graphical details.

Inspired by my old Grand Prix Simulator for my Amstrad CPC 646.

Accelerate: Up arrow
Break: Down arrow
Turn right: Right arrow
Turn left: Left arrow

Click: Start/Restart

1-3: Select circuit






uCertify review

I was contacted to make a review for the software provided by uCertify to prepare many IT certifications. I've got a full version for the Sun certification CX310-065 SCJP 6.0.

First of all, you have to know that this software is a support for people who already know something about Java. If you are a complete novice, start studying the basics, and then prepare for the certification.

For me, the most helpful feature I've found have been the teorical content assoccated to the exam objectives. It wasn't easy to get to it, but when I did, I saw the light. This is perfect because you have all the notes in a printable interface and they are associated with concret exam objectives. To get to this feature, you have to click "Exam objectives", where you'll find the official list of them; there, click the top-right button "Go to objectives with notes" to expand all the notes by objective. I would add the feature of remarking important parts of the notes with a highligther.

If you don't like to study the notes because it is boring and not so practical, you can go through the tests in "Learn Mode" that allows you to make visible the question theorical note as feedbak while you are making the test. The program allows you to create custom test, feature I would add the option to create tests based on the dificulty of the questions. Perhaps this can be supplied by the adaptative tests, but I feel I would like to have a bit more control in the level of the questions I go through, to manage my study pace.

You can keep track of all your progress in the tests. I would add tracking on the time you spend studying the notes, with an estimation of the effort they needs depending on the difficulty, to evaluate my dedication to that subject.

The sofware is pretty intuitive. You will get used to it quickly. The only feature I couldn't find easily and I couldn't evaluate was the option "Discuss It". This feature must allow us to leave comments on test questions or on notes, share them with other users and read what other users had typed. I haven't found any comment from others, so I suppose this functionality is not used very much. As proposal, I would make an study of the real use of this feature; if it us widely used, I leave it as it is now, else, I would remove it and I would replace it by a standard centralized forum, instead of linking comments to specific contents. Please, if anybody finds a comment and finds it useful, please, share with us.

So, download the trial version an evaluate it by yourself. I think it could provide you with useful content and an way to auto-evaluate your progress to your certificacion. If you have interest in any specific point I could help with, don't hesitate to leave a comment.

J2ME - My student projects

These are the videos from the project that my students did. They belong to the course 08/09 of the Master in Videogames of the European University of Madrid.

Thanks all my student for the interest and the effort. The merit is theirs, I pushed them a bit :).

San Fermín


Crisis behind
  • Cipri Sanchez Herraiz



Zelda


Pacoman2
  • Daniel Hernandez Zafra


Aviones


Pulso


Arkanoid
  • Carlos Casero
  • Laura Gil Sanz


Xax
  • Diego Lizarazo

Perl: normalizador de ficheros / files normalizer

espa?ol Perl, normalizador de ficheros: Un script en Perl para normalizar el formato del contenido de ficheros de texto: saltos de línea (windows/unix), tabulaciones, espacios al final de línea y saltos de línea al final de fichero.
(más)

espa?ol Perl, files normalizer: A Perl script for normalization the format of the content of text files: new lines (windows/unix), tabulations, ending line white spaces and ending file new lines.
(read more)

Hanoi Towers 64 Gadget


Add to Google

Adaptation of Hanoi of Towers with 64 discs to gadget.

Customizable, in elements and appearance.

As a curiosity, if you set the gadtet with an interval of 989 milliseconds and 15 discs, the completion takes 9 hours, that is, the duration of a normal job day of 8 hours (plus one hour for lunch).

Hanoi Towers with 64 disks

There are several versions of the legend, but all of them say that the end of the world will be reached as soon as all the disks are moved from the source peg to the destination one. Then, the following Java implementation of the Hanoi Towers in an applet with 64 disks can be considered a count down to the end of the world, :).

The puzzle consists in moving all the disks from the source peg to the destination one. Only one disk can be moved in each movement, and a bigger disk can’t ever moved on a smaller one.

The minimum number of movements needed for n disks are 2n-1, the, with 64 disks and moving one disk each second, the puzzle solution would last 585.442 billions years (calculus fromWikipedia).

This would be the actual position of the disks if the execution would have started on 1883, when the puzzle was ivented by Édouard Lucas.










Oh Mummy gadget



Add to Google

Adaptation of Oh Mummy! to gadget.

The classic Oh Mummy in a gadget. Use the arrow keys for walking all around the blocks until finding the 2 green blocks and then pass to the next level coming back to the initial position. Add it easily to your iGoogle with the Add to Google. button.

It has been changed from the original one. The mummies AI and velocities have been addapted. The game is divided in phases, and each phase consists of 5 miniphases; any time you continue the game, you will start from the beginning of the phase you are.

Subset

Given a set S, what are their subset?, what are their k-subset?. I’ve compiled several Java methods which iterate over these subset. Due to its low efficiency, this technique only should be used in brute force algorithms.

Contents

Notation
All the subset
All the k-subset
Auxiliar methods
References

Notation

S is the set with elements {n1, n2, n3, ... nn}. The number of elements of S is |S|=n.

K is the subset of S {k1, k2, k3, ... kk}, where ki belongs to S and ki doesn’t represent the same element S that kj does, with 1<=i,j<=k. The number of elements of K is |K|=k and takes values from 0 to n.

The subset of S will be represented byt set of n elements of {0, 1}, where 1 means belonging and 0 means not belonging. The number of elements of the suset |K|=k is the number of 1's that it has.

(contents)

All the subset

All the subset of S have subset from 0 elements to n. There are 2n of subset.

All the subset.

|S|=3

K0={0,0,0}
K1={0,0,1}
K2={0,1,0}
K3={0,1,1}
K4={1,0,0}
K5={1,0,1}
K6={1,1,0}
K7={1,1,1}

allSubsetBit(int) (iterative)

/**
* Iterates over all the subset of a given set of n elements.
*
* The maximun number of elements of the given set is 63.
* Subset are represented at bit level, 1 means belonging,
* and 0 not belonging.
* @param n Number of elements of the set, 0<=n<=63.
*/
public static void allSubsetBit(int n) {
for (long i = 0, lim = 1L << n; i < lim; ++i) {
printSubset(n, i);
}
}


allSubsetArrayIterative(int) (iterative)

/**
* Iterates over all the subset of a given set of n elements.
*
* The size of the set doesn't have any restriction, but
* the memory heap size.
* The subset is represented by an array of booleans, where
* true means belonging, and false means not belonging.
* @param n Number of elements of the set, n<=0.
*/
public static void allSubsetArrayIterative(int n) {

boolean[] subset = new boolean[n];

while (true) {

printSubset(n, subset);

// Add 1
int i=0;
do {
subset[i] = !subset[i];
++i;
} while (i<n && !subset[i-1]);

if (i>=n && !subset[i-1]) break;
}
}

allSubsetArrayRecursive(int) (recursive)

/**
* Iterates over all the subset of a given set of n elements,
* recursive version.
*
* The size of the set doesn't have any restriction, but
* the memory heap size.
* The subset is represented by an array of booleans, where
* true means belonging, and false means not belonging.
* @param n Number of elements of the set, n<=0.
*/
public static void allSubsetArrayRecursive(int n) {
boolean[] subset = new boolean[n];
allSubsetArrayRecursion(n, subset, 0);
}

private static void allSubsetArrayRecursion(int n, boolean[] subset, int i) {

if (i < n) {
subset[i] = true;
allSubsetArrayRecursion(n, subset, i + 1);

subset[i] = false;
allSubsetArrayRecursion(n, subset, i + 1);
} else {
printSubset(n, subset);
}
}


(contents)


All the k-subset

All the subset of S with k elements. The number of k-subset is:



n!

|k-subset|=
(n-k)!·k!

All the k-subset.

|S|=5
k=3

K0={0,0,1,1,1}
K1={0,1,0,1,1}
K2={0,1,1,0,1}
K3={0,1,1,1,0}
K4={1,0,0,1,1}
K5={1,0,1,0,1}
K6={1,0,1,1,0}
K7={1,1,0,0,1}
K8={1,1,0,1,0}
K9={1,1,1,0,0}

The following code has been taken from the book Hacker's Delight by Henry S. Warren Jr. It is a bitwise trick for getting the next greater number than one given with the same number of 1’s in binary representation.


allSubsetKBit(int,int)

/**
* Iterates over all the subset of k elements in a set of n
* elements.
*
* The maximun number of elements of the given set is 63.
* k must be 0<k<=n.
* Subset are represented at bit level, 1 means belonging,
* and 0 not belonging.
* REF: Warren, Hackers Delight, p.14.
* @param n Number of elements of the set, 0<=n<=63.
* @param k Number of element of the subset, 0<k<=n.
*/
public static void allSubsetKBit(int n, int k) {

long subset = 0;
// Set 1 k first bits
for (int i=0; i<k; ++i) {
subset |= 1<<i;
}

long limite = 1<<n;

long smallest, ripple, ones;
while (subset < limite) {
printSubset(n, subset);

// From Hacker's Delight
// Next greater number with the same number of 1's.
smallest = subset & -subset;
ripple = subset + smallest;
ones = subset ^ ripple;
ones = (ones>>2)/smallest;
subset = ripple | ones;
}
}



allSubsetKArrayIterative(int,int)

/**
* Iterates over all the subset of a given set of n elements,
* iterative version.
*
* The size of the set doesn't have any restriction, but
* the memory heap size.
* k must be 0<k<=n.
* The subset is represented by an array of booleans, where
* true means belonging, and false means not belonging.
* @param n Number of elements of the set. No restrictions.
* @param k Number of element of the subset, 0<=k<=n.
*/
public static void allSubsetKArrayIterative(int n, int k) {
boolean[] subset = new boolean[n];

while (true) {

int subsetCount = 0;
for (int i=0; i<n; ++i) {
if (subset[i]) {
++subsetCount;
}
}

if (subsetCount==k) {
printSubset(n, subset);
}

// Add 1
int i=0;
do {
subset[i] = !subset[i];
++i;
} while (i<n && !subset[i-1]);

if (i>=n && !subset[i-1]) break;
}
}

allSubsetKArrayRecursive(int,int)

/**
* Iterates over all the subset of a given set of n elements,
* recursive version.
*
* The size of the set doesn't have any restriction, but
* the memory heap size.
* k must be 0<k<=n.
* The subset is represented by an array of booleans, where
* true means belonging, and false means not belonging.
* @param n Number of elements of the set. No restrictions.
* @param k Number of element of the subset, 0<k<=n.
*/
public static void allSubsetKArrayRecursive(int n, int k) {
boolean[] subset = new boolean[n];
allSubsetKArrayRecursion(n, k, subset, 0, 0);
}

private static void allSubsetKArrayRecursion(int n, int k, boolean[] subset, int subsetElements, int i) {

if (i < n) {
subset[i] = true;
allSubsetKArrayRecursion(n, k, subset, subsetElements+1, i+1);

subset[i] = false;
allSubsetKArrayRecursion(n, k, subset, subsetElements, i + 1);
} else {

if (k==subsetElements) {
printSubset(n, subset);
}
}
}

(contents)


Auxiliar methods

These methods do a function with the subset given by the methods above. In this case, they print the subset. These are the methods that need to be changed for changing the behaviour.

printSubset(int,long)

/**
* Prints a subset represented with the bits of a long.
*
* @param n Maximum number of elements of the subset.
* @param subset Bit representation of the subset.
*/
private static void printSubset(int n, long subset) {
for (int j = n-1; j >= 0; --j) {
System.out.printf("%d", ((subset & (1L << j)) != 0) ? 1 : 0);
}
System.out.printf("%n");
}

printSubset(int,boolean[])

/**
* Prints a subset represented by an array of booleans.
*
* @param n Maximum number of elementos of the subset.
* @param subset Subser represented by an array of booleans.
*/
private static void printSubset(int n, boolean[] subset) {
for (int j = n-1; j >= 0; --j) {
System.out.printf("%d", (subset[j]) ? 1 : 0);
}
System.out.printf("%n");
}

(contents)

Referencess

"Hacker's Delight", by Henry S. Warren Jr.
"k-subconjuntos.".

(contents)


Hano Cup

It is my customized java framework based on and compatible to Java Cup 2007 competition. It provides an interface to simulate football (soccer) matches between programmed teams that implement 'Tactica' interface. I have added several useful characteristics to program new teams. Details about this project are here. It includes an auto-executable jar file and an Eclipse project with the sources.

OH MUMMY!

Play it here!

Classics are back, and I wanted to pay tribute to one of the first games I had, the mythical OH MUMMY. This is a new entry for the J4K 2007 Contest, so, its size is less than 4K.
Any comment or suggestion is always welcome.


Introduction

It is a long time ago when I had my first computer, an Amstrad CPC 464. Now, its 4Mhz and 64K of RAM seem to be tiny, but thanks to it, with BASIC as programming language, I started to like programming.

Then, games are loaded from a cassette, and loading last very long. Bugs were really annoying, because you had to load the complete program (about 30-60 minutes) to realize that it didn’t work

One of the first games I got was Oh mummy!. It was funny trying to deal with more and more mummyes. I’m sure that if you had played this game, you remember its song; you can find it here.

How to play

The objective is to find the two objects that allow you to pass to the next level. In the original game, the objects were a key and a kind of sarcophagus, but due to the size of the final jar file has to be under 4k, I had to substitute them by green blocks. For knowing what a block hides, you have to walk all around it.

For passing of level, after finding the two green blocks, you have to go back to the initial position.

Be careful with the mummies. They look slow at the beginning, but the are cleverer and cleverer in each new level.

Controls are the direction arrows.

Source code

Finally I submitted the source you can download it at ohmummy_src.zip.

The code is optimized for 4 Kbytes, and I had to apply my own compression format to the sprite image to mimimize its size. Compression:
  • 1 bit for transparency
    • 0 = transparent
    • 1 = colored
  • If colored, 2 bits for the color
    • 2 bits = index in the color palette 0-based


OriginalCompressed

6.966 bytes
418 bytes