(note (code cslai))

Notes on codes, projects and everything

Introduction

We were asked to develop a program that demonstrate Artificial Intelligence and apply what we had learned in class into the program. Then we came out with an idea to develop a program that is able to do tarot reading. At first the program did not have a GUI and is operated through Swi-Prolog interpreter but in the end we included a GUI-frontend for the program using XPCE.

First the program will require 3 random numbers from the user, then a random number will be generated as the seed. Then the card will be “shuffled” (in fact, we did some calculations to the user provided random numbers) and then determine the orientation of the card (normal and reversed). Then, we use the computed number to pick a tarot card and get the reading based on the orientation.

Technical Information

Shuffling the Cards

To shuffle the cards, we use a random number and place the random number into the formula such that $$c=x^y\text{ mod }23$$ where c is the corresponding card number, x is the user provided number and y is the system generated random number. Then the orientation of the card is determine by calculating the mod 2 of the random number.

Search Strategy

To implement simple search strategy, we used a hash function to divide the total of 22 major arcana cards into 5 groups. Each group will have one individual database file storing the card characteristics and reading. Then, depending on the calculated number, the system will choose to query which database file to decrease the inclusion of database files. We may not be able to observe the performance enhancement as we only have 5 database files but it should be more obvious for system with more database files.

GUI-Frontend

I am the developer for the GUI front-end. At first we planned to write the GUI using other languages/platforms but because of the time constraint we decided to give up on GUI front-end. However, I managed to pick up basic XPCE GUI construction just in time and made a GUI for the program. However, the GUI is not very friendly and is not able to display images. Because XPCE is a multi-platform supported toolkit therefore the appearance of the GUI is consistent in various supported operating system.

Screenshots

2. Display Result

The program displays the result after computing the input.

The program is reading input through GUI

4. Display Result

The program displays the result through the GUI

Credits

• GUI by Me
• Core logic by Regina
• Database entry by Janet and Janice, modified by Regina

Random Posts

• Magic SQL

Ever wanted to find the number of days between two dates without counting weekend (Saturdays and Sundays)? In PHP you typically needs to do a lot of calculation and a lot of factors needs to be considered. Therefore, in the end you will end up having a whole bunch of code that you will probably start asking yourself whether you are programming a web-calendar or something similar.

• Proof of Concept: YQuery

After the last post, I found that it may be fun to write a wrapper for YUI in order to make it behave like jQuery. Therefore, the code below is clearly mainly for self-amusement and is not intended to be used in production projects. However, through coding this, I found that although the difference in design, but YUI is obviously capable to do what jQuery offers (if not more). I will not continue working on this so whoever interested may just copy and paste the code to further developing it.

• Fuzzy C-Means and Content Recommendation

This post is purely based on my own speculation as there’s no experiment on real-life data to actually back the arguments. I am currently trying to document down a plan for my experiment(s) on recommender system (this reminds me that I have not release the Flickr data collection tool :/) and my supervisor advised to write a paragraph or two on some of the key things. Since he is not going to read it, so I might as well just post it here as a note.

• Working Life

I didn’t realize that I have been working for 3 weeks until the Labour Day which was a public holiday. Many things happened in these few weeks and I am still struggling to catch up with it. My superior and colleagues have been very helpful and offered me some helpful tutorials and books. I was instructed to build a event scheduler application using codeigniter in the first week and then work on a side project that extends a form using DOM methods and properties.

• The Little Pythoner, Part 2

In the last part, I implemented a couple of primitive functions so that they can be applied in the following chapters. The second chapter of the book, is titled “Do it again, and again, and again…”. The title already hints that readers will deal with repetitions throughout the chapter.