arimbun

Pathfinder 2.0 released

Tags: ,

Pathfinder 2.0 is the latest update to the original Pathfinder, an artificial intelligence bot written in Python which is capable of traveling through a maze between two specific points. Version 2.0 incorporates a graphical user interface (GUI) and the removal of user interaction via the command prompt. This new interactive GUI allows user to:

  1. Resize the maze anywhere from 8×8 to 16×16.
  2. Specify forbidden nodes, start node and end node anywhere within the maze.
  3. Select one of the five available algorithms for use with path searching.
  4. View the resulting path from start to goal on a given maze display window.

Source code may be downloaded from within my GitHub repository. Critics and suggestions welcome.

Useful Vim configurations

Tags: ,

For those with preference for Vim command line text editor for their programming tasks, there’s a few settings that you can tweak to enhance its usability. The config file is usually located in /usr/share/vim/vimrc on Linux and Mac machines, unto which you can add the following lines:

syntax on

This turns on syntax highlighting. This is default on Ubuntu, but Mac users (as of Snow Leopard) will need to add this manually.

set number

This turns on line numbering, which is essential for programmers.

set smartindent
set autoindent

As you may have guessed, this spices up Vim’s indentation a little bit. I’ve noticed that they prevent the cursor from returning to the start of a line when the Return key is pressed. There are also other indenting options, such as cindent, but I find it particularly annoying and never used it.

set shiftwidth=4
set tabstop=4

These set tabstops every 4 characters, which is standard for most programming languages. You may substitute it with other values if preferred.

augroup vimrc_autocmds
  au!
  autocmd BufRead * highlight OverLength ctermbg=red ctermfg=white guibg=#592929
  autocmd BufRead * match OverLength /\%81v.*/
augroup END

This is a temporary solution to the right margin problem with Vim written by cyrilrbt as Vim does not support displaying right side margin. When these 5 lines are added, Vim will highlight the 81st character onwards with the colour scheme of an error message (white font on red background).

Restart Vim and all changes should take effect immediately.

  • Author: arimbun
  • Published: Jul 25th, 2010
  • Category: Mac
  • Comments: None

Apache/MySQL/PHP config on Snow Leopard

Tags: , , , , ,

By default, Mac OS X 10.6 (Snow Leopard) bundles with Apache/MySQL/PHP. However, they do not quite work out of the box. Follow these extra steps and you’ll get your web server up and running in no time.

  • Author: arimbun
  • Published: Jul 21st, 2010
  • Category: Uncategorized
  • Comments: 3

Weird MSN chatbot

Tags: , ,

If you have enough friends in MSN, it is quite normal to see one or two that send you malicious links. This time I encountered a bot of a more intelligent breed: it actually talked to me and acted like a human. Well, close enough anyway. And this was repeated twice.

PHP: echo and print

Tags: , , ,

Both commands are used to display some output, so what’s the difference? I chanced upon an interesting article that covers the differences between the two. I’ll put up the summary here:

  • echo is (marginally) faster than print. Providing that the statement is in a large enough loop, one will notice a slight performance gain by using echo. It’s probably advisable in the long run, unless you’re already used to print.
  • passing mutiple string parameters is faster than concatenating multiple echo calls. See example below:
  • // "." signals concatenation and is slower
    echo "hello" . "world"
    
    // "," signals multiple arguments and is faster
    echo "hello", "world"

The Pathfinder

Tags: ,

Artificial Intelligence (AI) has always been one of my interests. I was lucky enough to enrol in possibly one of the best courses offered at The University of Sydney, namely COMP3308 Introduction to Artificial Intelligence. My first assignment touched on path search algorithms which form the basis of “smart robots”. The problem in a nutshell is to write a program that, given a start node and a finish node, finds a path through a given maze (8×8 or 16×16) in the most efficient way. Five different algorithms were used: breadth-first search, depth-first search, greedy best-first search, A* search and hill-climbing search.

You can download the Python source code and documentation on my GitHub.

I am planning a version 2 which will incorporate a GUI for visual aid of the simulation, but first I’ll need to get my Python GUI programming up to speed…

Jobs admits antennagate on iPhone 4

Tags: , , ,

It took a while, but Steve Jobs finally admitted in a press conference that poor signal calculation algorithm was to blame for the wireless signal problem. I find this one particularly interesting; I would have thought that the built-in antenna design was responsible, but algorithm? Is the problem really inherent to the software?

Update: It appears that the software update was only meant to improve the phone’s calculation of signal strength and did not actually solve the problem it had with signal loss.

  • Author: arimbun
  • Published: Jul 16th, 2010
  • Category: Linux
  • Comments: 2

Introduction to rsync — quick file synchronisation

Tags: , ,

rsync is a very good utility for synchronising files over a network. It works based on the delta-transfer algorithm—only data in the source that do not exist on the destination are copied over. This method saves plenty of time and bandwidth compared to the standard cp command.

Example: rsync $SRC $DST

On your local machine, you can use this to:
1. Copy files in a directory into another. Below code will match all files in the home directory that have the .txt extension and copy them all into /path/to/heaven.

rsync -v /home/login_name/*.txt /path/to/heaven

2. Copy directories (recursively) from a directory into another. The command below is similar to the previous, except that all directories (and their contents) are copied as well.

rsync -vr /home/login_name/* /path/to/heaven

© 2010 arimbun

Powered by Wordpress and Magatheme