Sunday, November 10, 2013
I am always perpetually short on time. As much as I want to, I did not pick up the latest Pokemon game out there. I still haven't touched Pokemon Black/White even though I have it. There's plenty of games out there that I want to play, but do not have time for. So the question is, what do I do with my time?
"Be fruitful and multiply"
That has been the guiding words ever since the beginning. There are currently 3 different activities that I do that occupies most of my time:
1. Nintendo Life's Petit Computer forum
2. Simpleton Geek's blog
In the past, I have spent the majority of my time growing Petit Computer community in Nintendo Life's forum, and it shows. It went from so-so gathering to getting a lot of people from other groups. Of course, I spent a lot of time in nurturing the community, and for the most part, it works. That is, until recently.
A couple jerks came into the board, and it's like every time they post something, it's either spam, false claim, or general whinings. There's no substance to the post. The moderator was asked, "Don't you get tired dealings with petty people?" The answer was, "Yes, but what can you do?"
I can think of a few things to do with them, but as I am not moderator, that's not my problem, is it? My problem is that I'm seeing the community that I've worked so hard for being turned into irrelevancy by some whiny kids. Ouch, in a big way.
A lot of good people has curtailed their activities there, and so will I. The truth is, I just don't see any future there at all. When sinful people go to Heaven, they'll just turn it into Hell.
So, I have been very active in my blog. The newly designed Simpleton Geek blog is very nice. It still has too wide of a subject. I still can't believe I actually put cooking in there. It should've been making/crafting. Oh, well. We'll see how this will turn out. There's quite a bit of Raspberry Pi posting, and in truth, I'm just barely scratching the surface. I think a whole blog dedicated to just Raspberry Pi would have been justified. It's just that I think Petit Computer needs a good place and there's no other place like it on the Internet.
Finally, my Nanowrimo project. It has been no secret that I dream of being a writer. In fact, my goal is to be a published writer this year. Thank God for technology. Self-published is a viable goal at this time. Like any Nanowrimo, I will put it into priority, ahead of everything else. It's too bad I started out late.
I got started on Nanowrimo on Friday. I went into a meeting on Panera Bread. After a few Write Wars, I managed to scrape by 2700 words or so. That's not bad for a couple hours. Still, I'm hoping to get 5000-10000 words per day, so I have a long way to go.
The subject of Nanowrimo? Petit Computer. I'm imagining how it would be like if students are being taught computer programming using Petit Computer. With Nintendo being perceived as "gaming" device, and Basic being perceived as "brain damage inducing", there's no way current educational system will pick it up. I think that Petit Computer is the perfect way to introduce students, especially young students, to the joys of computer programming.
Yes, computer programming can be fun. Not that people want to read stories on how everything is just peachy, so I'll be putting in some pain into the situations. Purely intellectual sense, since I don't believe in physical torture in my stories.
So, Nanowrimo first. Blog second, and maybe forum.
Saturday, November 9, 2013
A managers get A workers. B managers get C workers.
There is a prevalent idea that good community is one that is peaceful and members helps each others. On the most part, this is true. However, there are certain people whose personality is bad and will destroy the community. This is why I say that "if a sinful person goes into heaven, he will turn it into hell." A bad person can certainly destroy a community if goes unchecked.
There are helpful people, and there are unhelpful people. However, there are people whose action is to totally destroy other people. There is a book about it, whose title I will not name here because it contains a bad word, but I will tell you the ISBN: 978-0-446-52656-2 by Robert Sutton, PhD.
The point is that such toxic people undermine the productivity and community of everybody. Tremendous amount of profit is lost due to people not wanting to do their best, or perhaps spending time defending themselves from unfair attacks. There are signs of such toxic behavior outlined in the book, but here's my simplified guidelines:
1. Attack: "You are bad."
2. Complain: "You are bad because you did this."
3. Advice: "You are bad because you did this instead of that."
When somebody ridicule, belittle, or otherwise blame another person, but no reason is given, then it is obvious that the person isn't really interested in giving advice, but of attacking a person. You need to understand the difference between the two. A good person will always go toward giving advice. A bad person will always go toward attacking the person.
Imagine a scenario where two people are in disagreement. Person A spends 30 minutes explaining the whole concept, citing numerous researchs, and spent a lot of time going through the problem and various solutions. Person B says in entirety: "That's absolutely wrong. You have no idea what you're talking about."
It is obvious that Person B is not only stupid, and lazy, for doing no research and therefore no understanding of the issues involved. But he also attacks Person A ad hominem. If you are a manager and you do nothing about Person B, then Person A will no longer respect you and will go away. A good worker will not tolerate stupidity. As a manager, you are responsible to discipline Person B, if not, then the whole workplace will suffer greatly.
Good talent will leave. Bad talent will be fired. Either way, if you have large turnover rate, then you are doing it wrong.
Another thing that will hurt community is that of being selfish. Ignorance or lack of empathy. This manifest most visibly in "Posers". An idiot pretending to be somebody great. Can you imagine a Karateka white belt donning a black belt claiming to be a Grandmaster? Impossible, isn't it? And yet, these posers would actually do things like that.
This happens in all circles. Some Internet kids espouses legal advice, saying you can do this or that questionable actions, claiming all sort of "qualifications" except actually passing the BAR exam and being licensed to practice law. In some cases, the advice will actually get somebody into trouble.
Another case where some salesman would push a product without regards of safety. When challenged on grounds of safety, these salesman would attack the person who actually cares about the safety of the users. Posers pose very grave threat to the community indeed.
If you are a manager, or moderator of a community, you are responsible to weed out the posers. Failure to do so will destroy the community at best, causing people to sue you for condoning the spread of false information at worst. Failing to actively discipline the bad person will result in destruction of community.
If you're interested, you can research "Levitron", which is a trademark owned by Bill Hones. It describes a process where a spinning top levitates above a magnetic base, and is patented. And yet, everybody knows that Bill Hones isn't the inventor. Roy Harrigan is the true inventor. This is a clear example of blatant rip-off where the true patent was circumvented by dirty tricks. Yes, the patent office has re-examined the issue, but that doesn't change the fact that the second patent should not have been issued in the first place.
Furthermore, the fact that the patent has been circumvented actually caused damage to the product. The original patent specifies a spinning top above a round magnet. The revised one specifies square magnet. It doesn't take a rocket scientist that spinning top works better with round magnet. Thus, there's a perception that the product is extremely difficult to use, when in fact it isn't so!
What this means, is that patent office has no respect at all. The consensus is that patent office is a joke, and that anybody can get a patent if they try hard enough, and they did. Tremendous amount of patents have been filed that amounts to nothing more of obvious improvements of existing patent. Billions of dollars are spent in filing, and contesting patents. Is that the world you want to live in? Certainly that's the world the patent office wants to live in since more patents means more money. But really, is that the world you want to live in? Well, like it or not, that is the world we all live in.
There is a community that I was active, and in the beginning, we all pitched in to the greater for the community and it flourished. Then a couple disruptors came in. The moderator simply swept any disagreements under the rug, regardless of the correctness of the position. When I see people blatanly attack other people, and the moderator let it slide, the moderator lost all respect from me. I decided to curtail my activities there significantly.
It has been less than a week now, and there is no significant activity there at all. Just a bunch of kids throwing stuff out. Why would people want to go there? No reason. So, any chance of greatness has been snuffed, not for evil reason, but simply by ignorance.
A managers will get A worker. B managers will get C worker. When good people leave and bad people stay, it's time to get a new manager.
Monday, September 30, 2013
The 3 Laws of Ignoramus Doofus
1. After this, therefore because of this
An expansion of this is something that happens together, will always happen together. Fire together, wire together. These principles are scientifically proven by Markov's chain and Bayesian theorem.
2. I do it, because everybody does
When asked for justification, only come up with a single reason, regardless whether or not there are other reasons not to do it, or whether or not it is even relevant to the cause.
In any case, better to fail together with a lot of other people since doing so will give plenty of targets to point finger at.
3. I want it, therefore everybody wants it
Everybody is the same. If I am thirsty, you are too. If I am hungry you are too. If I like blue, so do you. If I find it funny that I dropped a bucket of dirty paint on your brand new car, you'd laugh too.
Sunday, September 1, 2013
You know, some people just aren't fit to function in public. You can see them in jails. Murderers, rapists, thieves, and burglars. They are society misfits who deserves to be put behind bars.
And yet, they aren't the only ones. There are other ways, too. A gentler way to choke community out of its existence, while claiming to be improving it. I was watching a travel show about New Zealand, recently, and there is a segment in there where New Zealanders talked about how it used to be that the people are about showing off, about who can catch more fish than anybody else. It took a while before people realize that natural resources are finite, and now they practice sustainable living. They only catch enough fish for themselves and their neighbors. Thus, New Zealand becomes a beautiful country.
Now, imagine if some new people, either tourists or young persons, came by and started to brag that they are better than the existing locals, and show them by catching a large amount of fish. Will the local stand it? Of course, not. It's their community and they stand to suffer when the fist disappear. Tourists will just go on to another country. Only the locals will suffer. So, it comes with justification that if there's some rude tourists wreak havoc the environment by not following catch limits, the local police will come down to them and fine them, or if that's not enough, jail them.
This happens throughout the all the communities, not just New Zealander. In fact, even virtual communities are not immune. I don't know what it is that the internet have that cause people to blatantly abuse other people. Bullying is a real danger on the Internet. They would posts objectionable materials, or otherwise behave in a manner that people would otherwise restrain in the real world. More than one people have dual personalities. A nice respectable person in real life, and a destroying demon in virtual communities.
I'm playing a game called Animal Crossing New Leaf, where you can invite other people to visit your town. There is a group of people called Raiders, who just pick up stuff on the ground without paying (stealing) or cut down all trees and run over flowers (Vandalism or worse). Why do people do that? This is not some single player games where it's you against the computer. This is real people who spent a lot of their time, making their town beautiful, and raiders just come and destroy it just for fun.
There is no rational explanation or justification for such destructive behavior. "Because it's virtual" is not a reason. It may be an excuse, but that still doesn't change the fact that somebody spent a lot of time building up something, only to be destroyed by some inconsiderate jerk. A lot of time that can be spend on something else is now gone. That there is real damage. Once that time is gone, you never get it back.
Talking about losing time, there is disruptive behavior. In internet forums, what if there's some loudmouth who keep asking already answered questions? What if there's somebody who keep posting a lot of trivial and irrelevant topics, despite people complaining of such action? That's time wasted. So, these disruptive behavior will gather ire from long-time contributors, people who have been there a long time, and know what community standards need to be upheld in order to maintain an orderly function. And when such disruptive person keep insisting doing disruptive behavior? Well, there's the ban user option. A virtual jail or "driven out of town", so to speak. And so, the community go back to being peaceful again.
Sometimes the moderators are young and clueless, and permit such behavior, or sometimes the forum is an open one without moderation. When the community does not discipline such behavior, such destructive person may thrive there. At least for a while. Then people will get fed up with such behavior and leave. I know I have left a few forums because they have turned into such vile fest, that there is nothing good left. Beware the lessons of Sodom and Gomorrah. Towns so sinful, God felt the need to destroy them. Did I just quote the Bible for lessons on the internet forums? Anyway, that is what happens.
Well, this is why I maintain this blogspot. If such people happens here, I will simply ban them. This is to preserve the sense of community. If there is no other civil community out there on the internet, at least this one will survive. I need to maintain vigilance because bad people do exists, and they may come here.
There was a town that was heaven on earth, and it was perfect. Then a murderer came by, murdered one of the resident, and the town never did regain its heavenly qualities. That is why there is heaven and hell. If sinful people comes to heaven, they will turn it into hell. A painful experience that happens over, and over, and over again.
In fact, one happened this morning. Sla*** in a Petit Computer Forum was kicking up a storm of troubles, and laughed out loud when Mor******* pointed out that people are avoiding the forum as the result. In other words, it is perfectly clear that he enjoys destroying communities. In the end, the moderators had to come in and clean up the mess. I just don't see how somebody can enjoy the destruction of the whole community. That's so tragic.
Thursday, August 29, 2013
I like the $8000 collection. I did some rough calculations, and estimated that 20 bells=1 dollars. That means 7 million bell house is about $350,000. That's about right.
Wednesday, August 28, 2013
Guides to Live By
- Considerateness. The Golden Rule. Do not do unto others, what you yourself do not desire.
- Growth. Continuous Improvement. Always be better than yesterday.
- Generosity. Be good neighbor. Give more than you take.
- Productive. Do something useful. Be fruitful and multiply.
Not much by themselves, but these rules will get you far.
Nothing about vacation, or have fun? Hmmm. Do I look like a spoiled kid to you? Kids today are so spoiled!
Tuesday, August 27, 2013
- Don't be stupid
- Set Reasonable Goal
- Make Plan
- Do Plan
- Adjust previous steps until done
Wednesday, August 21, 2013
I don't mind waiting a bit for all the instructions to come in. In the meantime, I'll be doing something nice with my Raspberry Pi.
Friday, August 16, 2013
Sure, the concept of remote working isn't new. The dumb terminal has been available since the first computer network. The point is: I'd rather download a small application so I can work locally, save locally, and only publish remotely.
I have been working on my blogspot, and the web app saves every 5 seconds. Of course the app is slow and plodding. Saving remotely takes a long time. I bet I can work 3 times faster if the saving isn't automatic. This does not take account that if the save fails for any reason, there'd be a message saying so, shifting the text a few lines down, and there goes my cursor placement.
The worst part is, saving isn't guaranteed. What if it fails for any reason? And if the network is flaky, you can bet that there will be problem. What now? You cannot save a local copy for back up. You have to face the fact that you are hostage in network connection uptime, or just bite the bullet and lose the whole work that you did.
Thursday, August 15, 2013
I have directory pages, and there will be more to come for ease of access. I will keep this blogspots for my usual ramblings.
Petit Computer Journal:
Raspberry Pi Journal
I hope by concentrating my technical papers there, it will have greater impact as you don't have to wade through my irrelevant musings.
I will still post my games, hobbies, and other musings here.
Tuesday, August 13, 2013
My American Mensa Academy score. I believe that is the IQ score. I usually score 150-160, but sometimes I get lucky. I'm sure with practice, I can score perfect, eventually. :)
Monday, August 5, 2013
Of Language GrammarThey compared Chimp and 2 year olds language faculties to see if there's any difference. The conclusion is that 2 year olds can understand grammar, where is Nim the Chimp does rote memorization. That's an interesting test and I suppose perhaps humans can feel superior to chimp. My question is: How about comparing adults to Google translate, or Watson? As I understand it, Watson trumps human. Does that mean we, in general, are less than 2 bit overgrown transistor?
Resurrecting Extinct SpeciesThe science is there now to create or re-create extinct species, even without existing creatures. They talked about Jurassic Park dinosaurs, of course. My question is: If indeed it is possible to create non-existing creatures, how many of these scientists are tempted to create Balrogs? Or maybe Orcs. The way I see it, just splice some Gorilla genes into, oh I don't know, rhinoceros? There, you have orcs.
Ice Maker in carsBuilt in ice makers? I thought most people just bring their ice box. Hey, I want microwave and ice maker in my car. My very own chuckwagon.
Drone in the SkyI think it's time that Google stops building self driving car and starts building self-piloting air planes. The challenges should be minimal. No jaywalker or stray deers, after all. Sell them to discount airliners or something. I'm sure they'll be happy to skip training qualified pilots. Imagine that, no more missing airports due to distracted pilots!
Origami KayakA cheap, lightweight, foldable, plastic kayak? I want one! Or maybe I want Pak-boat. Or perhaps, cardboard? Yeah, a cheap disposable kayak. Make the frames reusable, but the skin as shrink-wrap. I hope it lasts.
Hacking your educationThere's also an article about how you can read lessons from MIT classes on-line, for free! That's something interesting. Get the lessons, buy the textbooks, and do a CLEP test. Portfolio on website. Degree in one year! I like that. Now, who's hiring and what kind of classes do you want me to take? ;)
Sunday, August 4, 2013
Another reason for splitting the blog is that YouTube, which I have been using quite heavily lately, has decided to AutoPlay all their videos. As you see, the blog main page features several posts in one web page. This has the effect of multiple videos playing simultaneously. It's very confusing at best, and bandwidth hog at worst. When the video is HD, you are in effect are downloading multiple HD videos all at once. What if you just want to see one? You can't. You have to manually click on the link to expand just that one page. After that, all the next posts are gone, and there goes the advantage of multiple posting on a page.
That's why on my next BlogSpot, it will not feature YouTube videos, except by link that you need to click on. I will do my best to post pictures on it, though, so that you don't have to suffer watching my videos if you can just look at the pictures. I do have a very low video production quality values, as I simply use what is convenient, instead of what's proper. Video professionals will no doubt go blind looking at my very bad lighting. :)
Anyway, don't expect more Petit Computer Journal in this blog. Go to my other one, instead.
Thank you for reading.
Monday, May 27, 2013
Quickie Draw: A flipnote type app
I was reading messages in a Nintendo Life forum for Petit Computer when 2 people admitted to have inspiration to write a paint program over the weekend. I replied that it was unbelievable, because … me too! And suddenly, another one piped up and said that he too was inspired over the same weekend. Huh, sometimes real life is very strange.
So, anyway, I cooked up this drawing program real quick. I called it “Quickie Draw” because I wrote it in about one hour. It would have been faster, but it was done at the end of the day, and that day was extremely tiring because I was sick and was coughing and sneezing all day long. Overall, not a good condition to write computer programs.
QDRAW @INIT ACLS:GPAINT 1,1,1 PNLTYPE “OFF” GPAGE 1: GPAINT 1,1,1 LOCATE 7,5:?”QUICKIE DRAW” LOCATE 9,7:?”BY” LOCATE 11,9:?”HARRY HARDJONO” LOCATE 6,17:?”A CLEAR SCREEN” LOCATE 6,18:?”B END PROGRAM”
So far, so good. There’s no problem at all here, or rather, there shouldn’t be at all. For some reason, I mixed up X and Y coordinates, so the
“BY”somehow ended up in location 7,9. Ouch. How did that happen? Fixed it no problem.
@PRE S=TCHST:X0=TCHX:Y0=TCHY IF BTRIG()==16 GOTO @INIT IF BTRIG()==32 GOTO @END IF S==0 GOTO @PRE
You know, as simple as that @PRE is all about, I had a terrible time with it. The thing is, I knew it would be simple, but for some reason, I kept going off the deep end with various variables trying to keep track of different states of drawing. My brain was definitely jello when I did it. I kept thinking that my program was becoming too complicated and deleted my codes wholesale and started over. It was at my sixth attempt that I realized that
S=TCHSTshould be the first thing I should grab. Doh! After that, no problem.
@LOOP X1=TCHX:Y1=TCHY GLINE X0,Y0,X1,Y1,14 X0=X1:Y0=Y1 IF TCHST==0 GOTO @PRE ELSE GOTO @LOOP @END END
@Loop is very simple, isn’t it? And in fact, that’s all there is to it. If you ever want to write a paint program where you never let the pen leave the paper, that’s all there is to it. Haha, joking aside, computer programming can be easy and fun. Just don’t do it while you’re on deathbed unless you’re addicted to it (like me).
So far so good.
I posted the program to the forum. Chat a little bit and 50 minutes later, I wrote: “BTW, I changed the program to flipnote type.”
Interesting, isn’t it? I was sick to my deathbed, but after a breakthrough, I just kept going, and changing it to flipnote app. It wasn’t hard at all!
‘PNLTYPE “OFF”:PP=6:GOTO@ANIM PP=0 @INIT IF PP>0 GOTO @FADE ACLS:GPAINT 1,1,1 PNLTYPE “OFF” GPAGE 1:GPAINT 1,1,15 @TITLE LOCATE 7,5:?”QUICKIE DRAW” LOCATE 9,7:?”BY” LOCATE 11,9:?”HARRY HARDJONO” LOCATE 6,15:?”(A) NEW PAGE” LOCATE 6,16:?”(B) FLIP PICS” LOCATE 6,17:?”(X) END PROGRAM” LOCATE 10,20:?PP;”/99”The first line is commented. This is because it goes to animator subroutine directly, just in case you want to see your masterpiece in action without having to redraw the whole thing.
PPstands for number of pages, and although I peg it at 99 pages max, I doubt there is space in the program to hold that many.
@PRE S=TCHST:X0=TCHX:Y0=TCHY VSYNC 1 IF BTRIG()==16 THEN GOSUB @SP:GOTO @INIT IF BTRIG()==32 THEN GOSUB @SP:GOTO @ANIM IF BTRIG()==64 GOTO @END IF S==0 GOTO @PRE @LOOP X1=TCHX:Y1=TCHY GLINE X0,Y0,X1,Y1,14 X0=X1:Y0=Y1 IF TCHST==0 GOTO @PRE ELSE GOTO @LOOP @END ENDIt is very interesting that it doesn’t take much more code to turn the paint program into a flip note app. That’s because most of the work is done by the subroutines. A sign of well-designed program is that the implementation of such program is effortless. I know I’m bucking the convention here, but I think that heroic effort in computer programming is misguided. I’d rather have heroic effort in program design and pedestrian implementation of it. Computer programs that are easy to understand tend to get maintained more, and it’s not about documentation. It’s about the cleanliness of the algorithm. How many of you are willing to throw out existing code out and start over? Because if you do not, then you’re effectively working with first draft. Just ask any Communication teacher about the value of first draft. Not much, eh? Then why are you satisfied with your first implementation? Be willing to discard bad code!
@SP GOSUB @ERASE FN$=”GRP1:FLIP”+STR$(PP) SAVE FN$ PP=PP+1:IF PP>99 THEN PP=99 RETURN @ANIM WAIT 15:SYSBEEP=FALSE IF I<0 THEN I-0 FN$="GRP1:FLIP"+STR$(I) LOAD FN$,FALSE I=I+1:IF I>=PP THEN I=0 VSYNC 1:IF BTRIG()==64 GOTO @END GOTO @ANIM @ERASE FOR Y=0 TO 191:FOR X=0 TO 255 IF GSPOIT(X,Y)==1 THEN GPSET X,Y,15 NEXT X NEXT Y RETURN @FADE FOR Y=0 TO 191:FOR X=0 TO 255 IF GSPOIT(X,Y)==14 THEN GPSET X,Y,1 NEXT X NEXT Y GOTO @TITLEOK, so now we have a fully functioning flip note program. Notice, however, that it is not user friendly. It’s still rough on edges. However, due to good design, the algorithm is clean and modular and easy to change. One more round of polishing, and we’re good to go.
‘QUICKIE DRAW ‘A SIMPLE FLIPNOTE ‘HARRY HARDJONO MAY 2013 DELAY=10 PNLTYPE “OFF” INPUT “HOW MANY PAGES”;PP IF PP>0 GOTO@ANIM PP=0:CC=14 @INIT IF PP>0 THEN GOSUB @FADE:GOTO @TITLE ACLS:GPAINT 1,1,1 PNLTYPE “OFF” GPAGE 1:GPAINT 1,1,15The first thing you notice is that there is an
INPUTstatement, asking you how many pages. This is for the
@ANIMfunction. If you enter 0, then it will go to editing mode. Otherwise, it will animate the pages. This change will enable us to run the program from the main menu, instead of having to go to EDIT screen and edit the program manually.
Another change is that there is a variable
DELAYright in the beginning. This is for the delay loop for the animation. The more loops, the slower the flip. I simply set it to a number, instead of asking the user what he wants. This is for simplification of the program. With better UI, I may let the user specify the delay.
@TITLE LOCATE 7,5:?”QUICKIE DRAW” LOCATE 9,7:?”BY” LOCATE 11,9:?”HARRY HARDJONO” LOCATE 6,15:?”(A) NEW PAGE” LOCATE 6,16:?”(B) SAVE AND FLIP PICS” LOCATE 6,17:?”(X) COPY TO NEW PAGE” LOCATE 6,18:?”(Y) PEN/ERASER” LOCATE 10,20:?PP;”/99”
Nothing too new here. The biggest change is that I’m now very specific about (B). There is a concern that ending the drawing mode may not save the image. I simply made it explicit that yes, there will be a saving. If you do not intend to save it, then during program restart, simply specify 1 frame less than before. No problem.
(X) copy function is actually easier to do, since you’re not doing anything much. The Pen/Eraser function comes out of the copy function. This way, you can simply erase the difference, instead of drawing the whole thing over. I don’t really need to do this but it’s very convenient to the user.
@PRE S=TCHST:X0=TCHX:Y0=TCHY VSYNC 1 IF BTRIG()==16 THEN GOSUB @SP:GOTO @INIT IF BTRIG()==32 THEN GOSUB @SP:GOTO @ANIM IF BTRIG()==64 THEN GOSUB @SP:GOTO @TITLE IF BTRIG()==128 THEN CC=29-CC LOCATE 1,0:IF CC==14 THEN ?”X” ELSE ?”O” IF S==0 GOTO @PRE
There is a little trick in changing the
CCcolor. Notice that
CC=29-CC. This is very useful mathematical formula if you ever want to toggle the value of a variable between two numbers. Let’s say you want to toggle the variable G between 4 and 7. Simply add the two values and use the formula above. So, we have
G=(4+7)-G. In this case,
CC=(14+15)-CC. I suppose I should have written it that way so it won’t be so much a magic number.
Also, the X and O, is actually filled block and hollow block in the program. I simply put the ASCII equivalent here.
@LOOP X1=TCHX:Y1=TCHY IF CC==14 THEN GLINE X0,Y0,X1,Y1,CC ELSE GFILL X1-3,Y1-3,X1+3,Y1+3,CC X0=X1:Y0=Y1 IF TCHST==0 GOTO @PRE ELSE GOTO @LOOP @END SYSBEEP=TRUE END
GFILL. Why the difference? One is drawing (pencil) the other is erasing (eraser). I did try to erase with
GLINE. Didn’t like it one bit. I also added
SYSBEEP=TRUE.This is because I turned off
@ANIM. In general, it’s good to have a specific exit point such as
@ENDin the program even if you don’t know what you want to do with it.
@SP GOSUB @ERASE FN$=”GRP1:FLIP”+STR$(PP) SAVE FN$ PP=PP+1:IF PP>99 THEN PP=99 RETURN @ANIM LOCATE 6,15:?” “ LOCATE 6,16:?” “ LOCATE 6,17:?”(X) QUIT “ LOCATE 6,18:?” “ LOCATE 10,20:?RIGHT$(“0”+STR(I),2;”/99 “ SYSBEEP=FALSE IF I<0 THEN I-0 @ANIM2 LOCATE 10,20:?RIGHT$("0"+STR$(I),2);"/99 " FN$="GRP1:FLIP"+STR$(I) LOAD FN$,FALSE I=I+1:IF I>=PP THEN I=0 FOR J=0 TO DELAY:VSYNC 1:IF BTRIG()==64 GOTO @END NEXT J GOTO @ANIM2I had to duplicate the screen displays so the screen will update properly. I suppose I can write yet another function to simplify the structure. Since I’m going to be done with this, I decided to just leave it out like that. It is a good idea to put the screen displaying routine to a function, though. It makes it cleaner.
@ERASE LOCATE 0,0:?”Z” FOR Y=0 TO 191:FOR X=0 TO 255 IF GSPOIT(X,Y)==5 THEN GPSET X,Y,15 NEXT X NEXT Y LOCATE 0,0:?” “ RETURN @FADE LOCATE 0,0:?”Z“ FOR Y=0 TO 191:FOR X=0 TO 255 IF GSPOIT(X,Y)==14 THEN GPSET X,Y,5 NEXT X NEXT Y LOCATE 0,0:?” “ RETURN
The “Z” is the clock in the program. It indicates that the program is busy. It does take a while for the computer to scan the whole screen.
And that’s about it. Not a bad program to write in a hurry.
Monday, April 1, 2013
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
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.'MAZE 'APRIL 2013 'HARRY HARDJONO CLS:CLEAR DIM XDIR DIM YDIR 'ROOM: MAKE ROOMS 'PATH: DRAW PATH 'CHOICE: CHOOSE PATH 'INIT: SET PARAMS 'MAZE: MAKE MAZE GOTO @INIT
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.@ROOM 'I'M SKIPPING THIS FOR NOW. TOO LAZY. 'LOOK IT UP ON QR CODE 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.@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
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.@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
@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.@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
Also draws the initial background.
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.@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
Press any key to continue...@END IF BUTTON(0) GOTO @INIT GOTO @END
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!
Sunday, January 20, 2013
My next Petit Computer project will be virtual keyboard. That is very useful, since all other projects will use it. I'm thinking of doing a multipart project on it, simply because I am so busy! Biting more than I can chew, really. Stock market and PPH (Personal Productivity Hour) projects are two that I want to finish ASAP as those will really boost my productivity.
There may be Pathfinding project in the future, but that one is so convoluted that not only it will be multi-part, but also waiting for some level editor to be finished. Speaking of level editor, I'm thinking of writing a level editor for RPG games. That one should be fun. And since I did Turtle Logo in one hour using Small Basic, maybe I should do something similar to that in Petit Computer.