måndag 18 februari 2013

Knight's Tour

Made an app for solving the Knight's tour problem [1] for various board sizes (n =m<=24). A knight's tour is a sequence of moves by a knight on a chessboard such that each square on the board is visited once and only once a.k.a a Hamiltonian path. A method for finding such paths is using a heuristic deviced by H. Warnsdorff called Warnsdorff's Rule. Using the heuristic we can solve the problem in linear time but sometimes it fails to produce a complete path due to the undeterministic nature of the heuristic.

There are several ways we can improve the success rate of Warnsdorff's Rule:

  • Second-level tiebreaking by Ira Pohl [2]. "For each tie move, sum the number of moves available to it at the next level and pick the one yielding a minimum."
  • Move-orderings by Squirell and Cull [3]. Use predefined lists of move-orderings to break ties. You can find move-orderings in the their paper that will give you a complete tour on every board with 10 <= n, m < 300.



















tisdag 15 januari 2013

Zcalendar

Did some calendar thingy with HTML5, PHP, JavaScript, jQuery Mobile and databases  as a course project.






torsdag 20 december 2012

Imposter


Imposter is an app that lets you post on Facebook and Twitter. Utilizing the Facebook SDK for Android and the Twitter4J Java library.



tisdag 11 december 2012

Big Boy Locator Deluxe

This app lets you find a Big Boy franchise near you in Sweden.
Simple as that!



 

onsdag 28 november 2012

OpenGL ES 2.0 with Android and something about Virtual Buffer Objects (VBO)

Feels great to go back to university studies after a summer hiatus! In this post I'm playing around with OpenGL or more specific OpenGL ES 2.0 which is a subset of OpenGL for embedded systems. OpenGL and computer graphics is a quite daunting topic to delve into, but I'm dissecting it bit for bit...

I did put together this demo Android application just to see some basic stuff like translating, scaling and rotating in action.

OpenGL ES Demo




















How to create and use Virtual Buffer Objects (VBOs) under Android.

Beginning with Android 2.2 (API Level 8), the framework supports the OpenGL ES 2.0 API specification according to the documentation but API Level 8 seems to be missing some functions in order to use VBOs so make sure that you are using at least API Level 9.


initialize phase

float[] data = {...};
FloatBuffer dataBuffer = FloatBuffer.wrap(data);

// create the buffer object and get a handle to it
IntBuffer buffer = IntBuffer.allocate(1);
GLES20.glGenBuffers(1, buffer);
int bufferObject = buffer.get(0);

// bind bufferObject to the GL_ARRAY_BUFFER
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferObject);
// allocates memory and copy data over to OpenGL memory 
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, data.length * 4, dataBuffer, GLES20.GL_STATIC_DRAW);
// cleanup 
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);


rendering phase


GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferObject);

GLES20.glEnableVertexAttribArray(...);

GLES20.glVertexAttribPointer(...);

GLES20.glDrawArrays(...);


onsdag 7 november 2012

Fridge

A small prototype app I made for a course project. I kinda let you manage your food items in your refrigerator with an expiration date and food quality warning system.