Thursday, May 31, 2012

Computer Program Development Phases

I was thinking of the different steps required to build a program. Here's one such steps:

Problem Identification
Resource Gathering
Expected Outcome
Design Algorithm
Implementation of Code
Clean up Phase
Testing and Feedback

How about this?

Data Structure

Or this?


Tuesday, May 29, 2012

Small Basic Fortune Teller

This is an example of accessing arrays. I suppose a better way to do this is to read a file into said array. You don't really need to answer the question since the program doesn't do anything with it.

'Clairvoyant - PZH705
'Fortune telling in Small Basic
'Example tutorial in how to access arrays.
'There are different ways to access arrays depending upon the codes.
'You can put this in one line if you're willing to string the text together
'and do proper calculation.
A[1]="It is certain"
A[2]="Yes - definitely"
A[3]="Most likely"
A[4]="Outlook good"
A[6]="Reply hazy"
A[7]="My reply is no"
A[8]="Outlook not so good"
A[9]="Very doubtful"
NL=Text.GetCharacter(13)+Text.GetCharacter(10) 'newline

TextWindow.Write(("What is your Yes/No Question? "+ NL))
Goto Loop

Monday, May 28, 2012

Snail Sam Rescue!

My not-so-good attempt at pitching a new game...

A game that features a hero mowing down bad guys, moving from left to right, with some jumping involved. Also, some platforms are moving. Erm. That's just about everything before.
Wait! Add rotational and 3D effects! Um, that's just so generic.
Okay, okay. You want original? Here goes:
Sweet Susie, Snail Sam's Sweetheart, has been Snail-napped! It is up to you to rescue her from the dreaded fate of being salted! Have Snail Sam upgrade his trusty Snail Scooter to various vehicles including, but not limited to School Bus, Soap Box, and Bikes with polygonal wheels. Successfully navigate hazardous environment such as discarded gum, dried soda, and melting ice cream on the porch(for sale on e-bay!). Have access to different weapons including Cows, Skunks, and Chihuahuas! Defeat various Bad Guys such as Postman, Teen DJ, and Old Ladies Pushing Carts Across the Parking Lot.
Will Sweet Susie be rescued? Will Snail Sam be flattened by careless walkers? It's up to you, young heroes! Hurry up and slime your way to Sweet Susie!

Wednesday, May 23, 2012

Ronald McDonald is better than you!

Ronald McDonald is better than you. Yes, the clown. That red, white and yellow fast food joint clown. No, really. I'm serious.

I was eating at a McDonald restaurant one day, and in walked a clown. I was like "What?! Ronald McDonald?!" He scanned the room quickly and said, "Hi everybody! I'm Ronald McDonald!" Everybody turned around and applauded.

He then made a speech about how he represents the food chain, and that if there's any a question or concern, that people should let him know. While he was making this speech, I sensed a genuine interest and concern coming from him.

Then he walked to a window, and while he was doing it, I sensed a tiredness coming from him. No doubt from his busy schedule.

Then he talked about how there will be children coming in the next day, and that he is going to prepare the place for the occasion. As he talked, I detected a sense of protectiveness around the children. This man really cares about the children.

Then he posed, and I snapped a picture. Then he was off to see the manager for the preparation day the next day.

The whole thing lasted for about a minute!

I have seen people as caring, hard-working, and loving the children as this clown, but I have never seen it done as quickly as he did. In that one minute, in my eyes, he went from corporate mouth-speak to a really, really impressive goodwill ambassador.

There aren't that many people in the world who can impress me in one minute. So, yes, I can say with confidence that Ronald McDonald is better than you.

Tuesday, May 22, 2012

Small Basic Prime Number

' Harry Hardjono
'May 2012
' Done in less than 30 minutes. :)

TextWindow.WriteLine("How many Prime numbers (1-1000)? ")
If N<1 Or N>1000 Then
  TextWindow.WriteLine("That's All Folks!")


  For i=1 To Array.GetItemCount(Prime)
    If (Math.Remainder(Num,Prime[i])=0) Then
      'Not Prime
  If Flag=1 Then
    TextWindow.WriteLine("   "+Num)
    if Array.GetItemCount(Prime)>=N Then
      Goto Ender
  Goto MainLoop

'TextWindow.Write("Press any key to continue...")
Goto Init

Monday, May 21, 2012

Rayman Demo Nintendo 3DS

I just downloaded Rayman demo from Nintendo eShop. I had to update the system to do so, but I was so anticipating the demo. Rayman was very popular in its day.

The graphics are very nice. The frame rate is extremely smooth. The art style is very friendly. Overall feeling is that this is a very polished piece of software.

Unfortunately, I ran into high difficulty level immediately. This hard level of difficulty is supposed to sell more units? I doubt it.

Of course, this difficulty level is actually on par to what was then. About the same. It just goes to show you that as I get more sophisticated in my gaming taste, I become more discerning. So, unfortunately, I won't be buying this game.

Which is too bad. Even Earthworm Jim comes with easier to play difficulty level. In fact, if you look at the Kid Icarus game, the difficulty level is pitch-perfect, simply because you get to set it to very fine levels.

So, please, if you write/implement old games for modern day players, then please include selectable difficulty levels! Even id's Doom has it. Why can't you?

Wednesday, May 16, 2012

Artisan vs. Craftsman

Artisan vs. Craftsman

I was attending Comic fest a while back, and in one of the sessions, I asked an artist (who I will not name) how to be less derivative. I told him that the way I got my ideas is from watching bad movies and improve them. He responded by saying that I should get ideas from good movies.

Afterwards, I happened to met him in the hallway, and I told him that he didn't really answer my question. So I clarified the question. How can I be less derivative from the movies I watched? He kind of stumbled before telling me that I should follow the genre of the conventions. Say, a zombie movie has certain sections that define the genre and that I should follow that.

True enough. But how does that make me less derivative? He still didn't answer the question!

So, should I have clarified the question, yet again? I don't think so. He stumbled in the beginning, which tells me that he really doesn't know how to do it. How come an experienced professional artist doesn't know how to be an original? Answer: He doesn't because he's not an artist! He's a craftsman.

An artist thrives on original works. He seeks new ideas. A craftsman, however, seeks great execution of ideas. He may or may not generate original works. A designer is an artist. A woodworker is a craftsman. An artist designs cabinets; a craftsman makes them.

So, it is clear to me, that however skilled this craftsman is, he is not the person to seek when looking for original ideas. Therefore, I politely excused myself and left him to his way.

Tuesday, May 15, 2012

Small Basic Converter Code

One of April challenges is writing a converter, the kind that converts meter to yard. A lot of people are doing it the hard coding way. I am way to busy to do that. So, I decided to spend one hour on it, and no more! The result is here. Not perfect, but close enough.

There are several design issues:
1. The display for various conversion and the result is rolled into one.
2. You only select the original data, all the possible conversions is done automatically.
3. Range is limited to valid input
4. The data is provided via text. You can modify the text to suit.
5. More importantly, the text also include range of numbers, which the program uses for conversion. The ratio for conversion is calculated automatically. This includes negative numbers, or shifting numbers (i.e. 1-5 into 3-7)
6. I use a hidden Main scale to facilitate ease of conversion.
7. Pay attention to Field[] entries! They defined the data field locations!

These design decisions helped me contained the implementation of this program into one hour.

I did encounter one bug. When copying Choice Loop into NumLoop, I forgot to change the Goto statement, so it went back to Choice Loop. Easily fixed.

Turns out, the algorithm for conversion is robust enough to handle out of range condition, so that I don't have to restrict its input. I could have avoided that bug after all.

It also means, that I don't have to show the range of numbers. It means I can just display the descriptions, and the converted numbers. It would make a cleaner presentation.

'Small Basic Converter - ZLW480
'By Harry Hardjono
'April 2012

Field[1]=1 'N
Field[2]=3 'Description
Field[3]=14 'From
Field[4]=18 'Min
Field[5]=28 'To
Field[6]=30 'Max
Field[7]=40 ':

'Data[0]="N DescriptionFrom To :"
Data[1]="1 USD From 0 To 100000 : "
Data[2]="2 GBP From 0 To 158308 : "
Data[3]="3 CAD From 0 To 99962 : "
Data[4]="4 EUR From 0 To 130240 : "
Data[5]="5 AUD From 0 To 103447 : "

TextWindow.WriteLine("Small Basic Converter")

For i=1 To Array.GetItemCount(Data)
TextWindow.WriteLine(" ")
TextWindow.Write(("Which data(1-"+Array.GetItemCount(Data))+")?")
If (Choice<1 or Choice>Array.GetItemCount(Data)) then
TextWindow.WriteLine("Out of Range!")
Goto ChoiceLoop
TextWindow.WriteLine(Text.GetSubText(Data[Choice],Field[4],Field[5]-Field[4])+" to "+Text.GetSubText(Data[Choice],Field[6],Field[7]-Field[6]))
TextWindow.Write("Enter the amount: ")
' If (NumText.GetSubText(Data[Choice],Field[6],Field[7]-Field[6])) then
' TextWindow.WriteLine("Out of Range!")
' Goto NumLoop


Goto MainLoop
Sub map 'map function
'x1-x2-x3 y1-y2-y3

Tuesday, May 8, 2012

Small Basic Morse Code

I got bored one day, and hey, remember that Rock/Paper/Scissors game? That was quick. So I was hunting for a quick coding project, quicker than my usual one hour session. The Morse code is it. It took about 10 minutes, including typing all those entries. Of course, the original design was phonetic alphabet project, but I decided that typing Morse code entries would be faster than typing phonetic alphabet entries.

BTW, you don't have to limit yourself. You can do your own project like this, and substitute Klingon alphabet, for example. Do you know that Small Basic uses Unicode? Try looping some big numbers through Text.GetCharacter and you'll get the idea.

Of course, as luck would have it, I still have some time, so I improved it with tones. I think there is something wrong here because the sound is so soft! Oh, well.

'Extending the code, as well as decoding is left as an exercise for the reader!
TextWindow.Write("Enter Text:")
For i=1 To Text.GetLength(t)
TextWindow.Write((Morse[Text.ConvertToLowerCase(Text.GetSubText(t,i,1))])+" ")
TextWindow.WriteLine(" ")
Goto Loop

'Extending the code, as well as decoding is left as an exercise for the reader!
TextWindow.WriteLine("Morse Code Encoder by Harry Hardjono")
TextWindow.Write(Text.GetCharacter(13)+Text.GetCharacter(10)+"Enter Text:")
For i=1 To Text.GetLength(t)
MC=Text.Append(MC,(Morse[Text.ConvertToLowerCase(Text.GetSubText(t,i,1))]+" ")) 'Comment this out for no sound
TextWindow.Write((Morse[Text.ConvertToLowerCase(Text.GetSubText(t,i,1))])+" ")
PlayMorse() 'Comment this out for no sound
Goto Loop

Sub PlayMorse
TT="+=C12;-=C4; =P4;"
For j=1 To Text.GetLength(MC)

Tuesday, May 1, 2012

Small Basic Rock Paper Scissors Code

Just a little quickie, this time. I was looking at the Rock, Paper, Scissors that others have written, and Jason boiled it down to 2 lines. Which I think isn't strictly true. I'd have call it one line. Here is another one-liner. This one works by first splitting the input into 3, and splitting it again. Basically, a simpler way to handle multi-dimensional strings. I also added a touch of detail in that you actually type R/P/S as entry. I could have added the code to convert the input into uppercase, but it's long enough as it is.

I do not do tutorials, at least at this time, but I left out all the original code as comments so hopefully, you can learn from it.

'Rock Paper Scissor
' by Harry Hardjono
'April 2012 - GTJ601
'This is an implementation of Rock-Paper-Scissors
'Rock beat Scisscors
'Scisscors beat Paper
'Paper beat Rock
'The input requires capital letter, and is one of these:
'(R)ock, (P)aper,(S)cissors
'The program will randomly choose one of them
'and display the result.
'The output is encoded because I'm too lazy to type them out.
'">R" means "You choose Rock."
'">P" means "You choose Paper."
'">S" means "You choose Scissors."
'"vR" means "Computer chooses Rock."
'"vP" means "Computer chooses Paper."
'"vS" means "Computer chooses Scissors."
'"=W" means "You win!"
'"=L" means "Computer wins!"
'"=D" means "It's a draw!"
'So, ">RvS=W" is interpreted as:
'"You choose Rock. Computer chooses Scissors. You win!"
'The following is the original source code before
'I collapse them into one line.
'Goto Loop

Goto Loop