Showing posts with label 14. Show all posts
Showing posts with label 14. Show all posts

Thursday, December 12, 2013

Book Review 14


Book #14 Getting Started with Processing
Casey Reas and Ben Fry

First of all, I love the Processing language. It's fun, portable, and easy to learn. I abhor the name. Why? Because every time I google it, I never found it! Really, I think Proce55ing is better because when I google that, it goes right to the site!

So, having actually learned the language, why did I pick up the book? Because I love the language and I want as many people to use it as possible. The book is interesting because it is the first "Getting Started" book from O'Reilly that I found. And I found out that hand-drawn sketches makes perfectly usable illustrations, even when it can best served with computer graphic or CAD.

I find the book features just the right amount of personal touches for the artist in me, and yet not skimp on the technical side for the scientist in me. A rare treat that is yet to be duplicated from other "Getting Started" books.

The only complaint that I have is that the subject matter is too brief. It touches on other Processing usage, such as Arduino. However, I think that extra projects such as Arduino is best left to other "Getting Started" book. You can put a mention there, of course, but let's not dwell upon them.

All in all, a good book marred only by trying to be comprehensive in a small book. Highly recommended.

Monday, November 25, 2013

Cooking Journal #14


Baked Potato

It's always a hassle to skin a potato. That's why I never bothered. Sometimes, though, you want a good mash potato. My solution to that is to microwave the potato.



First, I make some cuts for ventilation. Exploding potato in microwave is very bad.



Then hit Baked Potatoes selection in the microwave. Let stand after baking.



The nice baked potato makes skin peeling easy. Just squish the potato. The skin will fall right off!

And that's it. Serve with butter and enjoy!



Saturday, November 23, 2013

Nintendo Journal #14


Digital Picture Frame



On one of my trip to Thrift store, I found this picture frame for cheap. Just a small one. I was hoping to be able to score the display for Raspberry Pi use. No such luck. The whole thing was integrated very well. I couldn't tell what kind of display that is, and the interface. In the end, it is a good digital picture frame. So, I use it as such.

Unfortunately, I don't have a good picture album to display. In the end, I simply download Nintendo 3DS data to a flash card, and stick it into the device. It shows mostly Animal Crossing New Leaf. This here is when I was visiting Morpheel's town. Monocot is the name of the town, but it was only once, a long time ago, and heavy thunderstorm. I remember the storm and Gulliver sleeping on the beach.

Thursday, August 29, 2013

Raspberry Pi Journal #14

Adding a Temperature Widget

Go to the bottom bar on the GUI Desktop. Hit the right mouse button, and a menu will pop up. One of the option is Add/Remove panel item. Among them is a Temperature sensor.

Select that to add it to the bar. You can move it up and down for proper placement. The temperature reading is in Celcius, and anything below 70 degree is fine. My usual temperature reading is about 54 degree.

There is an exception. When I was connecting my Kindle to it, it sometimes goes to 84 degree for a second or two. I wonder why? My guess is that there is a voltage drain that somehow causes the calibration to be off. Otherwise, no harm.

Wednesday, August 21, 2013

Petit Computer Journal #14



Amazing Mazes!


It has been a long time, hasn't it? I took one month sabbatical. It became 3 months. How time flies! I got jolted into action by the bugs on my windshield! It's spring! Time to get moving! Haha, joking aside, it IS time for me to get up and do something.

I have been working on this maze generation program that I planned to use on D&D type of game. The eventual code will create "rooms" out of the maze.
And here is the whole program

'MAZE
'APRIL 2013
'HARRY HARDJONO
CLS:CLEAR
DIM XDIR[5]
DIM YDIR[5]


'ROOM: MAKE ROOMS
'PATH: DRAW PATH
'CHOICE: CHOOSE PATH
'INIT: SET PARAMS
'MAZE: MAKE MAZE

GOTO @INIT

So far, so good. I'm allocating memory in the beginning of the program. I also map out the structure of the program in terms of subroutines.

@ROOM
'I'M SKIPPING THIS FOR NOW. TOO LAZY.
'LOOK IT UP ON QR CODE
RETURN

You're probably wondering what goes on here. All it does is scan the maze for straight walls, and removing them. Any bend in the wall and it will be left alone. The resulting "rooms" are unique. Setting the LINK variable to 0 will render this subroutine useless. For lots of spaces, I find LINK=8 is a good value to use. Higher values means less room.

@PATH
LOCATE CX,CY:?CHR$(32);
FOR PC=1 TO LEN(M$)-1
PDX=XDIR[INSTR(CIDX$,MID$(M$,PC,1))]
PDY=YDIR[INSTR(CIDX$,MID$(M$,PC,1))]
CX=CX+PDX:CY=CY+PDY
LOCATE CX,CY:?CHR$(32);
CX=CX+PDX:CY=CY+PDY
LOCATE CX,CY:?CHR$(32);
NEXT
RETURN

Path really draws the path of the maze. It goes by "UDLR" values of XDIR,YDIR arrays. I have the idea of making the subroutine generic by using string and draws all the path. No error checking here, so be careful when using this subroutine as-is.

@CHOICE
CS$=""
FOR CI=0 TO 3
CJ$=MID$(CIDX$,CI,1)
CPX=CX+(2*XDIR[CI])
CPY=CY+(2*YDIR[CI])
IF LEN(M$)>250 THEN CJ$=""
IF CPX<SCXMIN THEN CJ$=""
IF CPX>SCXMAX THEN CJ$=""
IF CPY<SCYMIN THEN CJ$=""
IF CPY>SCYMAX THEN CJ$=""
IF LINK==0 OR RND(LINK) THEN IF CHKCHR(CPX,CPY)!=151 THEN CJ$=""
CS$=CS$+CJ$
NEXT
C$=MID$(CS$,RND(LEN(CS$)),1)
RETURN

This subroutine merely take the current cursor position and looks at 4 different directions. Valid direction gets added to CS$. Invalid directions are those that are nested too deep, out-of-bounds, and dead-ended in a maze.

@INIT
CIDX$="UDLR"
XDIR(0)=0:YDIR(0)=-1
XDIR(1)=0:YDIR(1)=1
XDIR(2)=-1:YDIR(2)=0
XDIR(3)=1:YDIR(3)=0
SCXMIN=1:SCXMAX=29
SCYMIN=1:SCYMAX=21
SCXCUR=RND(SCXMAX/2)*2+1
SCYCUR=RND(SCYMAX/2)*2+1
LINK=88:'CHANGE THIS FOR CONNECTEDNESS
ROOM=FALSE

CLS:M$=""
FOR II=SCYMIN-1 TO SCYMAX+1:?CHR$(151)*31:NEXT

@INIT subroutine establishes the parameters of the program. The maze characteristics, other than SCXMAX,SCYMAX which defines the size of the maze would be LINK and ROOM=(TRUE/FALSE). Set ROOM to TRUE if you want open areas in the maze.

Also draws the initial background.

@MAZE
'HEAVY WIZARDRY
CX=SCXCUR:CY=SCYCUR
GOSUB @PATH
GOSUB @CHOICE
M$=M$+C$+C$
M$=LEFT$(M$,LEN(M$)-1)
IF LEN(M$) GOTO @MAZE
BEEP:IF ROOM THEN GOSUB @ROOM

This is the heart of the program. Traditionally, this is implemented by a recursive function. Obviously, BASIC has no recursion. I managed to flattened the whole algorithm. This used to be a double FOR-LOOP. Now, it's a single REPEAT-LOOP. Very clean and simple. I like it.

@END
IF BUTTON(0) GOTO @INIT
GOTO @END
Press any key to continue...

And there you have it. A short, simple and sweet maze generator routine. Feel free to use it on your games! I'm looking forward to see what you can come up with. Happy coding!