Friday, March 30, 2012

Unit Brain Structure

Topic: Programming, AI

Brain: noun the brain as the center of thought, understanding, etc.; mind; intellect.

While this is not the first definition that is thought about when one thinks about the brain, I just wanted to make clear that this is what I intend by the word in the following discussion.

Earlier, I spoke about my personal research into artificial intelligence, and now I would like to speak more about the "brains" behind this.

As I mentioned before, the Demeter Project focuses on creating AI testing environments, as well as the AI themselves. These Units of AI quite obviously need some sort of brain; an area of code where they can come up with answers to questions, debate which action should be conducted next, etc. We humans have our actual biological brain which allows us to think and make decisions based on the environment around us.

So now we need to define a brain for our Unit; the brain itself will have the symbol [X], where X is the name of our Unit (Azure's brain would be denoted [Azure]). So let me propose the following definition for [X]:
[X] = ($, Π, δ, Γ)

Ah, Greek letters, the international symbols to denote pretentiousness. Indeed, the only reason I added Greek letters to my system was because it looked cooler. But each of these letters and symbols mean something, which I will now define.

$ stands for the Unit's Reasoning Module, and is currently the only (partially-)implemented part of the brain. This allows the Unit to make decisions based on its environment and come to conclusions such as "the robin is a bird, so it flies" or "a human has 'cheveux'". It can also come up to conclusions such as "this thing has fur, four legs and it meows, so it is probably a cat".

Π refers to the Unit's Memory Management Module (MMM), which would record the "important" events which occurred in the past. I put "important" between quotes because that is one of the biggest challenges about machine memory; we humans have a memory capacity which would roughly be equal to 2.5 million gigabytes, roughly the equivalent of 300 years of video content. So obviously, it is (so far) impossible to store this kind of data on a computer, so what do we "filter out" and what do we "leave in"? If we leave in too much, will the AI become "terminally nostalgic"? All unanswered questions.

δ and Γ both refer to the Decision Module of the Unit's brain, and would be responsible of communicating with $ and Π to make decisions based on input from the environment. δ more specifically refers to what I like to call the Frontal Lobe of the unit. When this module is active, it would be akin to a "thought process" in a human being.

I haven't delved too much into Γ, and there is a good reason for it; it is still extremely vague in my mind, and perhaps the only part of the brain implementation which would be tightly-coupled with the implementation of a body. Γ is called the Subconscious Brain, and would be responsible for every decision which would not need to be "thought" about. For example, suppose you have a Unit which wants to go from point A to point B. Let us suppose that this decision has been made by δ. Now, we do not want δ to be occupied with the actual task of moving the Unit's legs (wheels, w/e): we want δ to learn paths, memorize locations, sounds, images. It will be Γ's task to do all the "subconscious" moves; when you're walking, you don't think about your legs, or which muscles you need to use in order to walk. This is what would probably be the most complicated part of the Unit's brain.

Anyway, I think I have said enough today about the brain's structure. Please tell me what you think in the comments. Until then, stay cool!
-Snowman

Tuesday, March 27, 2012

And That's All I Have To Say About That

Topic: Varia

Opinion: noun a personal view, attitude, or appraisal.

I don't like doing this, posting an update only to refer you to another article, but I felt the need to share this with you:
Pourquoi je suis pour la hausse et contre la gratuité, de Lise Ravary
Please note that this article is in French.

Stay cool,
Snowman

Wednesday, March 21, 2012

Keep At It

Topic: Programming, Varia

Expert: noun a person who has special skill or knowledge in some particular field; specialist; authority: a language expert.

People have unrealistic expectations when it comes to programming (and this applies also in every other area of life). There are books out there with stupid, outrageous titles: Learn X In Y Days, with Y being anything between 3 and 10 and X being almost anything. I used to be a TA for an introductory course at McGill University, and it would aggravate me to no end when students would complain after getting a bad grade, stating that all they "needed" to do to pass the course was "read a 'for dummies' book".

You cannot expect to be an expert in a field the first time you enter it. True, there are some exceptions, but they are incredibly rare. Harold Ramis once said "It takes at least 10 years to get good at anything", and I couldn't agree more. And before you get good, you're going to have to be bad, and that's okay. Everybody starts everywhere.

What's my point? Well, people get discouraged when they're told they're bad at something, and most people quit trying to do it. And this is not limited to programming; learning to play an instrument, or learning to play a sport, or learning any field of study takes a long time.

So people, if you feel bad at something you want to do, just keep at it!

Stay cool,
Snowman

Tuesday, March 20, 2012

Keep Calm and Carry On

Topic: Varia, Riots

Survival: noun the act or fact of surviving, especially under adverse or unusual circumstances.

Living in Quebec, more specifically Montreal, these days has become slightly dangerous for students (and people in general) due to the abnormally-high amount of protesters. Now, I don't want to start preaching about which side is right; the tuition hike is a subject that I (along with all my friends I'm sure) am sick and tired of hearing about. Instead, I will post a few tips for those of you who might be stuck in the middle of a riot.

Now hold on, says Avid Reader, they are just peaceful protests! They won't turn into riots!

Yeah, just step outside and watch. More and more of these "peaceful protests" are turning to violence and vandalism. I have my own, very strong opinion about these protests and the reasons behind them, but like I mentioned earlier I do not believe it is my place to start debating.

So here are a few things you can do if you are ever stuck in a riot you never wanted to be part of in the first place:

1. Avoid Protests: If you feel like being yelled at and shoved around would effectively ruin your day (how someone can feel angry after being pushed and hit is beyond me), then it might be a good idea to avoid the protests altogether. Obviously this is not always possible for various reasons, but doing so effectively prevents you from being in a position you would like to avoid.

2. Keep Calm, Keep Your Head Down, and Keep Moving: Riots tend to make people edgy and angry and, sometimes, violent, so keeping calm will keep you from doing something which you would regret. If someone pushes or shoves you, don't respond (as that would just aggravate the situation) and keep walking.
Keeping your head down, shoulders hunched, will not only protect your face, but it will avoid drawing attention to you, thus reducing the risk that you'll be caught in a brawl.
Finally, keep moving. As soon as you stop, you are now basically part of the rioting crowd.

3. Stay Indoors: Well I think this one speaks for itself.

4. Carry Sugary Foods With You: This one is a little obscure and confusing. When in a riot, your adrenaline levels automatically increase, thus draining your energy reserves faster than normal. If that happens, then you may become too tired (especially at the end of the day) to make the right decisions based on your immediate situation. Sugary foods can therefore provide the energy you might temporarily need to leave the riot.
Edit: I was told by my better half that it takes up to an hour for the body to absorb the energy contained in sugar, and that it is the fastest the human body can gain energy, and so it is better to eat before going through a protest area.

5. Stay On The Sidelines: Walk along walls, avoid taking sides in the riot, and try to look as innocent and, for a lack of better term, uncomfortable as possible. Don't film anything, don't take pictures, just keep walking as though you would rather be anywhere else than there (which is probably true). This will help you go along unnoticed by both the crowd and the police.

6. Avoid Getting Hit By Riot Control Chemicals: Again, speaks for itself.

7. Move Away From The Riot: Walk, don't run, as running will attract attention to yourself. Try to avoid moving against a crowd, as you will be pushed and shoved; instead move with the crowd until you can find a side street or a doorway where you can break away. Avoid major roads, as they are more likely to be filled with rioters or police officers. In Montreal, try and take the metro. The metro system is usually unaffected by riots. However, in other cities it is in fact considered a bad idea to use public transportation.

8. Don't Antagonize The Police: Your personal safety is your number one priority, and antagonizing the police force is the number one thing you don't want to do. If they talk to you, listen and answer honestly. Explain that you just want to get away from the riot. In most cases they will point you to a safe area. In the worst case, they will take you as a rioter (see point 9).

Now, these are all used to avoid being in trouble in a riot, but sometimes you cannot avoid being caught in. The following 3 points are things to do if you end up being in distress.

9. If You Are Mistaken As A Rioter: Do not resist! If you go peacefully you will not be roughed or hit by the police force. Follow their instructions. Police officers usually only arrest people who attack them or who vandalize the area, and so if you "play nice" you will be left alone. If you are arrested, then simply explain your situation as calmly as possible. Again, your personal safety is the most important thing, and even though it sucks, you are safe while arrested.

10. If You Are Sprayed With Chemicals: If you are sprayed by tear gas or other chemicals, a simple solution of sodium bicarbonate (baking soda) with water will usually wash off the chemicals. In fact, if you can it could be a good idea to keep a bottle of that solution with you so that you can apply it to affected areas as soon as you are sprayed. This solution does not work on pepper spray. If you are hit by pepper spray, find a water source as quickly as possible and wash it off. Keeping a bottle of water with you also greatly helps.

11. If You Are Stuck In Your Car: First of all, no matter what happens, don't run over rioters, as this will put you in the "oh-so-definitely-screwed" zone with both the rioters and the police, greatly reducing your chances of survival. Remain in your car while the riot continues around you, as your car becomes a shelter from projectiles. Do not attempt to respond if someone hits your vehicle. If, however, your car becomes a target for vandalism (i.e. several people are targeting it) then abandon your vehicle and move away as fast as possible without running. Pulling your shirt over your head can help protect you. Before thinking about the cost of your wrecked car, think about what can happen; cars are regularly torched and smashed in a riot, and if you are stuck in one you can become severely hurt or you may die.

Hopefully none of you will need to use any of these tips, but with the amount of riots we've had so far in 2012 increases the likelihood of an all-out riot breaking out around you.

This is it for today, readers. Stay safe, stay cool.

- Snowman

Monday, March 19, 2012

Promela Verification

Topic: Programming

Experiment: noun a test, trial, or tentative procedure; an act or operation for the purpose of discovering something unknown or of testing a principle, supposition, etc.: a chemical experiment; a teaching experiment; an experiment in living.

Promela is a verification modelling language used to verify the correctness of various programming paradigms, ranging from distributed systems to complex algorithm verification. I am presenting this language to you so that you can conduct a simple experiment.

Most, if not all, programmers are familiar with the mutual exclusion (mutex) problem; if you have multiple concurrently-running systems, how can you ensure correctness of data modification? Here is a simple example:

Suppose your program consists of 3 phases: the non-critical (NC) phase, the wait (W) phase and the critical (C) phase. You can have multiple programs running concurrently, each in their own subphase. For example, if you have two programs running, P1 and P2, then at a specific example snapshot (at a given instant) of the runtime, P1 can be in its NC phase while P2 can be in its W phase; we will denote this {1:NC, 2:W}.

We labelled these phases as such to demonstrate the mutex problem; at any given moment, we want only one program to be in its critical phase. This means that no two (or more) programs are in their critical phase at the same time. Using the above notation with only two programs, we want to assure that the following snapshot is impossible: {1:C, 2:C}.

Various algorithms exist to ensure that mutex is respected and enforced, such as Peterson's 2-Process MUTEX Algorithm or Dekker's Algorithm. This is not news to anyone, and anyone who has had any experience with concurrent systems has probably encountered these.

However, as anyone who has had any experience with concurrent systems can agree, testing these algorithms can be a pain. Enter Promela.

I won't teach you Promela here, as I believe it is a language which is taught by experience, but I will tell you about its benefits. I was forced to learn Promela in a course which I did not want to take, and it has proven to be an invaluable tool in algorithm and system verification. While it is certainly not easy to learn and use, it almost provides direct proof that your algorithm works by allowing you to do certain things which might not be possible in other programming languages, such as atomicity constraints.

(Note for the wise: if you cannot do these things in other languages, than why is it useful to test them in Promela? Well suppose you develop a theoretical polynomial-time algorithm for the 3CNFSAT problem, and thus prove that P = NP, but that algorithm requires some atomicity constraints, then C++ cannot really be used to test it, whereas Promela can give you the tools required.)

For those wanting to learn Promela, multiple websites exist which provide everything you need to get started. Additionally, you would need an interpreter, SPIN (the Simple Promela INterpreter), which also provides real-time LTL formula checking with finite automata acceptance capabilities.

Oh, and the experiment I mentioned? Just take your favourite algorithm, and try to implement it in Promela!

If you have any questions, please feel free to post them in the comments section. Until then, stay cool readers!

- Snowman

Friday, March 16, 2012

They Can't Take That Away From Me

Topic: Programming

Cat: noun a small domesticated carnivore, Felis domestica or F. catus, bred in a number of varieties.

This post will have nothing to do with cats, but everything to do with Frank Sinatra. See, Mr. Sinatra is what I call my programming buddy, and this post will be about programming buddies.

Almost everyone has one. A stress toy, a piece of lint, a coffee mug, a humorous image, anything which distracts them from their job and at the same time allows them to reflect on the problem at hand. From my experience, anything can be a programming buddy. My coworker has this block puzzle he has yet to solve, and another has a pyramid of beer cans. See, it does not have to be an active object, or something you necessarily need to interact with. It is simply something familiar with which you decorate your work space.

What's the use of a programming buddy? Well programming buddies are part of the office environment, something which when improved can increase creativity, productivity and motivation. For me, it's listening to Frank Sinatra.

If you haven't gotten one yet, try and find one! But remember to keep it relatively passive as to not completely drain your productivity; just as your buddy can help you, it can also, if poorly chosen, become an obsession of yours.

That was it for today. Have a nice weekend reader!

- Snowman

Wednesday, March 14, 2012

March 2012 DERP

Topic: DERP

Derp: noun the word that describes a particularly retarded face: a retarded smile, and the eyes pointing in different directions.

Every month I will try to post a DERP I found in order for this blog to not be all full of serious stuffs. This is this month's DERP.



Snowman out!

How To Become A Hacker

Topic: Programming

Hacker: noun 1. A person or thing that hacks. 2. Computer slang. A computer enthusiast.

I found this interesting little article entitled How To Become A Hacker while browsing the other day, and I thought I ought to share it with you guys. One of the most important things they talk about (in the introduction! convenient!) is the difference between a hacker and a cracker. Why do I bring this forward? Well, it annoys me when people mislabel crackers as hackers, and vice-versa.

Want a handy tip to remember the difference? You don't hack a safe.

Snowman out!