Sunday, August 07, 2005

hard programming problems


snake
Originally uploaded by Bill Kerr.
I've spent a lot of time recently trying to solve a programming problem in Game Maker (see snake picture)

Each time the snake eats then a new part of its body is created and it becomes longer. The first body part follows the head and the other body parts follow the previous body part, as they are created.

An unsophisticated solution would be to have lots of body parts, body0, body1, etc. and then body0 follows the head, body1 follows body0 and so on.

To tell the truth I didn't find doing that easy but I have got that far.

But there is a far better solution which requires keeping track of the unique id of each body object, storing those values and then calling them up and getting them to follow at the right time as each new body part is created. This way involves passing ids, creating arrays and accessing them with for loops and I'm still working on it.

Programming is a merciless task master. If you get something wrong then an error message comes up on the screen and that's it, think again. Syntax error. Or you might get a logical error where the program runs but doesn't do exactly what you want it to do. Think some more.

At times I think I'm close to a solution but then as I approach it the problem manifests new dimensions and the imagined solution recedes into an inaccessible recess. Sometimes a promising idea turns into a dead end but then I may not be sure that it is really a dead end or just that I don't know a small but vital technical point.

With programming, I often have good ideas to solve problems but the technical implementation is difficult. I have to stop and look up the manual, print out the code and study it, it can be a long and frustrating process.

"Technical implementation". What a nice, easy phrase which conceals hours of agonising and worrying about whether the problem will be solved or I'll have to give up.

At times I feel very stupid but for some reason feel compelled to go on. At various points I look at what I have achieved and think, "How could I have spent so much time and achieved so little?"

When you learn something new then you quickly forget the difficulties involved in learning it and just take it for granted. Perhaps that's why experts sometimes appear to be arrogant and lack empathy with my learning difficulties. That's a perception I have, an internal conversation I conduct about whether I am stupid or not.

Don't you hate it when people say, "This is easy".

2 Comments:

Anonymous skav said...

if snake eats
  create a body part where the head is
  move the head
  everything else stays where it is
else
  move tail to head
  move head

you always need to only move 2 pieces at least

2:54 PM  
Blogger pradyprady said...

i agree friend...

i've been to same situation ...

7:42 PM  

Post a Comment

Links to this post:

Create a Link

<< Home