Android is a Google platform for mobile devices. IDE Eclipse allows for the Android plug in and the programming is in Java.
Fig 1. Android Logo
The 'Hello World' program was indeed some struggle, not because of the code but rather since one has to wait for about a minute as the emulator executes the program.
Trying out this simple program in Quincy gives a weird output !
What is happening is that, The printf statement: printf("The answer is %d\n"); tells the program to print an integer, but fails to supply one. The printf function doesn't know this, so it will take the next number off the stack (some random number) and print it. The correct code should be: printf("The answer is %d\n", answer);
Fig 2. Corrected Program, 2+2 = 4
Running the program in Unix (Ubuntu) gave another result ! 2+2 = 134518880
Fig 3. 2+2 = 134518880
REFERENCES (1) Oualinne, Steve "How not to Program in C++", No Starch Press 2003 (2) Quincy
Another game of chance with Pygame ! with a piratey touch to it ! The tokens used in the slot machine are (1) The Jolly Roger (2) Pirate mate (3) Anchor (4) Treasure-map and (5) Gun.
5 Tokens , 3 slots ! ......
Fig1. Randomisation is achieved with 3 variables
May be the best game of chance I have made , the obvious thread can be traced to Pygame Dice and Pygame Toss discussed here earlier.
Fig2. Start-up screen
Fig3.User-Input Screen
Fig4. 'Loser' Getting all 3 different tokens
Fig5. 'Good Job' Getting at least '2' similar tokens
Extending the idea of tossing a coin to the throw of a pair of dice. The throw doesn't have equal probable events , ie: Probability of getting a cumulative sum of 10 is not the same of getting a cumulative sum of 7.
The probabilities of rolling a cumulative sum of 'n' is maximum for rolling a 7 (16.67% , lucky seven) while it is the lowest for rolling a 2 or 12 (2.78%).
To allow the user to have the 12 choices (2-12 and Quit) two variables are used as posx and posy (single variable pos used in the toss of a coin), to make a grid.
Fig1. The start up screen
Fig2. The user interface
Fig3. The Result screen (1)
Fig 4. The Result screen (2)
The coding gets lengthy due to the 36 possible outcomes of the event. The lines of codes tally to nearly 1450 across 2 python files.
It is worth noting that throw of a single die is an equal-probable event with all events bearing a 16.67% probability thus programming such an interface would be lot easier and just matter to add on to the toss of a coin code.
I got inspired to try out GAMEMAKER 7.0 after skirting through the wonderful book by Jacob Habgood and Mark Overmars.
Fig 1 . The Game Maker's Apprentice
GAMEMAKER reduced the 'coding' aspects and allows creation of games using GUI. Excellent software ! in some beginnner's pursuit I was able to create game snippets similar to PAC-MAN and SUPER-MARIO.The software is also supported by GAME MAKER LANGUAGE (GML) which is similar to Java/C++.
Fig 2. Game snippet similar to SUPER-MARIO. The 'mushrooms' add life and energy whilst the 'snakes' reduces it.
WINDOWS does not support multithreading concurrent and real-time structures. What an irony !.The most popular OS does not allow systems and structures which can control the most breathtaking technologies of the day. Aerospace , trains, nuclear power plants and other state of the art embedded technologies cannot use WINDOWS !
When I learned about Real-Time and Concurrent Systems ,it was not very acceptable that Microsoft would make such a redundant OS. A bit of dabbling on the internet led me to Article Number 22523 in Microsoft knowledge base.
Fig1. Article 22523
Which clearly stated that ,
"In no sense can Microsoft Windows be considered a "real-time" system. It is a message-driven, event-polling system, with nonpreemptive scheduling".
Being initiated in Windows and using it for about ten years , did make me stubborn and I tried to look for other alternatives which would allow to construct real-time structures in Windows.
Cygwin came to my rescue ! However on running threads in POSIX and tasks in Ada, I realised that it is only a cheap makeover.
Python and Ada however worked in windows , Ada because it is a concurrent language and platform is not an issue. Python did execute the threads , though on a closer inspection it revealed that Python reduces the concurrent codes to their sequential evil twin brother.
A simple code which which prints out 'Hello World' and the thread number ;
Fig 2. The threading code
gives slightly different results with different OS. When run on Ubuntu Linux ,
Fig 3. Execution in Ubuntu
The order of execution of the threads is 3,4,1,5,2 then 1,2,3,4,5 and then 5,4,3,2,1. Thus the order of execution is non-deterministic , typical of real-time systems.
However on Windows ,
Fig 4. Execution in Windows, 'evil twin brother'
the order of execution is deterministic , as seen above. Thus windows prevents the real-time characteristics of non-determinism and reduces it to sequential processes.
Linux confirms the standard characteristics of concurrency as nondeterminism and preemption , hence a joy for all concurrent programmers. Seems Bill Gates got it wrong this time !