Sunday, August 06, 2006

we don't know what we don't know

This is a first attempt to apply the laws of ignorance to myself. I think this has potential.
Known unknowns: All the things you know you don't know
Unknown unknowns: All the things you don't know you don't know
Errors: All the things you think you know but don't
Unknown knowns: All the things you don't know you know
Taboos: Dangerous, polluting or forbidden knowledge
Denials: All the things too painful to know, so you don't
- from The Domains of Ignorance, thanks to arti for pointer
Amazing logical angst that leads to hilarity when resolved.

This is about a programming problem that arose while working on the latest version (7c) of the Africa Map game. In this game you click a button and some of the countries jump of a map of Africa. Then you select them with the mouse and drag them back to their correct positions.

To help position the countries accurately I've written some code that displays the exact position of the mouse pointer as it moves across the screen

For the small African countries I decided to paint a small white dot in the middle of them. Then I could use that dot to set the origin for the sprite. When the game ran, I could drag the country, by the dot, to the position required and read the required position from the mouse pointer display

However, when I added one of these countries (Burkina Faso) with a dot to the country and name arrays and tested the game, something strange happened

This worked:
  • Burkina Faso was correctly positioned
  • the name of the country, Burkina Faso, appeared
  • the mouse pointer turned into a hand when it passed over Burkina Faso
This didn't work:
  • Burkina Faso wouldn't deselect with left button release, but the other countries did deselect
  • Burkina Faso wouldn't snap to position with left button release, when dragged close to its correct destination
burkinaFaso
Well, clearly the problem had something to do with left button release. But it didn't really make sense because all the other countries (the ones I did before the white dot experiment) were still working fine. And the new country is coded into exactly the same array as all the others and yet the behaviour on two crucial counts is very different.

What did I try:
  1. Made a list of what was working and what was not working, as recorded above. Good.
  2. Moved the new country to a different position in the array. Maybe I am counting the array incorrectly and being last on the array is the problem (not logical when you think about it, because if the array was the problem then nothing would have worked, not 2 things out of 5 not working)
  3. Adding another new country, with a dot, to the array and testing that. Exactly the same behaviour with the new new country. That test was worthwhile.
  4. Printed out all the code to have a closer look at it. Good.
  5. Through examining the code I determined there were two possible boolean variables that might explain this behaviour. The variable names were used (set to 1 when the countries were off the map and 0 when in their correct positions on the map) and selected (set to 1 when selected with the mouse left button and set to 0 when the button is released)
However, when I looked closely at the code it seemed that logically what was happening could not be happening. Because the following piece of code, contained in a Parent object and which was responsible for snapping the country to position, did not depend on any prior values of either variable, used or selected.
Information about object: objParent
Mouse Event for Left Released:
set variable selected to 0
execute code:

// snap to original position when close
// set used back to 0 when returned to start position
if (distance_to_point(xstart,ystart)<10)
x="xstart;" y="ystart;" used="0;"
It couldn't be that the inheritance from the Parent wasn't working because the mouse pointer changing to a hand was also inherited from the same Parent and that was working. So, I was hopelessly stuck in a logical impossibility.

My feelings at this point were disbelief, frustration and despair. How could this be happening? Cognitive dissonance.

But sometime later (this took a while) it suddenly hit me. The white dot was the same colour as the background colour, which was treated as transparent. I was dragging the object by a transparent hole and when I released the mouse it didn't register that I was releasing the object!!!!!

This led to an amazing emotional release where I staggered around the house laughing, nearly falling on the floor, being so overjoyed at finding the answer to my problem.

So, lets run this past the laws of ignorance.

Known unknowns: All the things you know you don't know. Sure as hell I knew that I didn't know why on earth my countries with dots were behaving so weirdly.
Unknown unknowns: All the things you don't know you don't know. Pass, someone else will have to tell me that.
Errors: All the things you think you know but don't. Well, programming / debugging is good for discovering that, as in this example. I thought I was doing something straightforward but unexpectedly a huge problem arose.
Unknown knowns: All the things you don't know you know. Somewhere deep in the background I knew something about the significance of dragging an object by a transparent hole. But that took a while to come out.
Taboos: Dangerous, polluting or forbidden knowledge. A hole in the middle, that is dangerous, I have found out.
Denials: All the things too painful to know, so you don't. I was pretty sure I was an idiot who couldn't see something that must have been obvious. That was painful but I didn't give up on it. I'll probably never be a highly skilled programmer but I'm still in denial on that one (partly).

1 comment:

Anonymous said...

"Domains of Ignorance" is such a powerful framework for metacognitive reflection ...love the descriptor "logical angst"