Tuesday, 24 November 2009

The Unified Representation of Simple Mathematics

Someone has told me the following words of wisdom: "Use inheritance only where it makes sense to do so". When it comes to mathematical problems, we think it does make sense to use inheritance, and so we have a base class called somewhat surprisingly "the exercise class" that contains some properties common to all exercises/problems. One such subcategory of problems are textual problems, which I am currently working to implement. These will consist of: the problem text containing variable names, a formula that is used to compute the answer, a list of variables that will take bounded random values, and an answer comment string, so that the pupils can learn something too, which is quite important!
While working on this I realised that quite a bit more can be moved out into our basic math representation; A variable taking on a bounded random value for instance, is something that we will have a use for in many problems. Also, I needed a simple mathematical expressions parser so the computer can calculate the problem result. This would not strictly be necessary, but is done in this way because then it will be very easy for a teacher to create new text problems that the system can use, simply by entering a problem string with variable names isntead of values, entering a formual such as (x1+2*x2)/2, specifying variable bounds and also supply a nice solution comment string.
This was an excellent reason to visit one of my favourite branches of computer science, namely the theory of formal languages. Simple mathematical expressions are ... simple, and can be parsed by a push-down automaton, like many programming languages. In my current implementation I lex and parse expressions involving addition, subtraction, multiplication, division, and parenthesis, by the following grammar (Backus Naur Form):
Expr ::= Term | Expr "+" Term | Expr "-" Term
Term ::= Atom | Term "*" Atom | Term "/" Atom
Atom ::= int | "(" Expr ")"

Special consideration must be taken for the case of division, something which I am working on right now.

Tuesday, 17 November 2009

The Ants are Working

Getting things up and running with neither the magical Google Plug-in for Eclipse nor Eclipse itself is certainly tedious. The positive side of all this, is that one gets to know the details of what the system does. After finalising my Ant build script for GWT I struggled a lot with the App Engine part, until I noticed Google generously provided an ant_macros.xml file with the App Engine SDK! Having inported the definitions from that file, and copied some commands from some example project, I can now do quite a lot with the build file, including copying files, compiling them, packaging, running in hosted mode or through a local App Engine server, cleaning up directories, and my favourite: datanucleus enhance, just because it sounds so high-tech-sci-fi-y.
Tere are probably some libraries and procedures we don't really use in our project, but at this point I dare not modify things that work!

datanucleusenhance:
[enhance] DataNucleus Enhancer (version 1.1.4) : Enhancement of classes
[enhance] DataNucleus Enhancer completed with success for 1 classes. Timings :
input=250 ms, enhance=40 ms, total=290 ms. Consult the log for full details

BUILD SUCCESSFUL
Total time: 2 seconds

Facebook Application

We are now up and running on Facebook!

After having read through tons of policies and even more documentaion, Math Empire is now up on Facebook. However it was not hard to actually get it up, but it seems stupid to just upload it and hope that it follows Facebooks rules.

The program still has no user authorization abilities, but that will hopefully be added later. So far the application is in sandbox-mode, so it can't be accessed from within facebook, but that will hopefully change soon.

Picture of our application inside Facebook:

Sunday, 15 November 2009

Sudoku

A simple sudoku-game has been added to the exercises available in the application.

I had some trouble with CSS, so i havn't been able to change the font-size inside the sudoku-grid, or practically not anywhere else either...
So far the sudoku-exercise can only display one sudoku-game, new games must be inserted somewhat manually, i.e. prociding a 81-digit long string representing the grid. There is no way to correct the ongoing game either, so no results can be stored.

Saturday, 14 November 2009

Clean(er) Code and Facebook

I have cleaned up the code a bit, the previous berserking-rage-coding-marathon was devastating on code readability, hopefully the code is a bit more readable right now.

I have added an abstract Exercise-class. Exercises can inherit that class and call its methods, hopefully that will make it easier to implement new types of exercises. A class that implements the exercise-class in implemented, therefore the application now features four different types of exercises(+,-,*,/).

Facebook
I have tried to find ways to connect with Facebook, but all tutorials I've found is using php, a language that I'm not familiar with. After some desperate struggling on the net, I found a Facebook Java API. I will look more on that now. Generally Facebook-related things seems to have enormous amounts of guides and tutorials available online.

Tuesday, 10 November 2009

Save your progress

I have managed to get Google Datastore to work with our application!

The server now stores the results of users. The user-name entered when 'logging in' is stored and sent to the server together with the achieved results. If that name exists in the server's database, the result data will be updated, otherwise it will create a new data element.

The code works, but it will need some cleanups(sigh, zzz) ...

User Authentication

I've been looking into user authentication. It is quite a challenge, considering all issues involved. We want users to be able to log in to Math Empire using accounts they already have registered with other services. If we let users sign in with their Google account for example, we can let Google worry about most issues associated with user authentication. Nice! But still, if we are to support multiple services we will have to differentiate these at some level. I've been looking at OpenID lately, which looks promising.
Ideally, there would be a single common interface towards different services, and an implementation of that protocol could be used to authenticate users from whatever service supporting it. Sure, such a wide perspective has its own set of drawbacks, but it sounds great anyway!

Monday, 9 November 2009

The Little Things IDE's do...

Since I (Daniel) uses neither Eclipse nor any other Java IDE, I have realised the painful way how great the little things IDE's do are. I am not talking about syntax highlighting, or dynamic intelligent "write half the code for me" features. No, I'm thinking about building and deployment, managing file paths, environment variables and tool chains, etc.
I hope Ant will do the trick for me, once I get all the paths set up in a nice, clean way. When that is working it shouldn't be difficult to write some small scripts to consolidate everything into a single "build the code and show me the result" script, like the Eclipse command "Run" I guess.

We are online!

A first pre-pre-pre-Alfa version is now up on Google's App-Engine servers.
Have a look at it on:

http://themathempire.appspot.com/

All EULA's that I had to read through just to get it up there made me sleepy.

About the app's current state:

Don't mind the login-menu, nothing actually happens when you type something in. That functionality will be added later on (of course).

Right now the application can be used to train basic arithmetic skills, two summands are randomized, twenty at a time, and the user has to add them together. The server stores the success-ratio of submitted answers.

Saturday, 7 November 2009

Getting Started!

Ideas and visions are running through our minds, and I have just finished some sketches. Tonight I will dream nightmares about uncontrollable CSS-monsters.

Have a look at the first storyboard sketch (There would have been more of them unless I ran out of black lead):

That one turned up to look like this:


It cant do anything useful yet, it just exists. Hopefully it will up on the net soon..

Friday, 6 November 2009

Math Empire dev blog up and running!

This is the first among many posts on the development of Math Empire, the fun way to learn mathematics!
We chose to go the Google way when it comes to services and platforms, so now it is time to sign up for them all.