Grauniad's Random Code Snippets

Started by Grauniad, December 18, 2012, 08:19:38 PM

Previous topic - Next topic

Grauniad

I'm creating this as a repository for code  I played with in CRPLTowers.

Once
  ShowTraceLog
   "HelloWorld" Trace
    0 61 RandInt
    Trace
    CurrentCoords 0 0 61 RandInt 1 10 trace5
     CurrentCoords 0 0 61 RandInt 1 10 CreateSpore
Trace5
     "end" Trace
EndOnce


30 Delay


Some debugging framework code


Once
  ShowTraceLog
  10  ->Eaten
  5 0 do
     <-Eaten Trace
      <-Eaten 1 sub Eaten
   Loop
EndOnce
A goodnight to all and to all a good night - Goodnight Moon

Grauniad

I'm pretty sure I saw a post from lurkily that claimed the "sub" operation was broken.

I tested the Sub function and it worked just fine with ordinary integers.

In the context of the  "sub" operation removing creeper, it may be a matter of perspective.

Bear in mind that the creeper is deposited (or withdrawn) from a single cell and that it will rapidly flow out from the point of origin (or in towards the point of subtraction) making any operation appear less than effective.

Here is a map that demonstrates creeper at two locations near one another.
A goodnight to all and to all a good night - Goodnight Moon

lurkily

#2
Quote from: Grauniad on December 20, 2012, 01:44:55 PMI'm pretty sure I saw a post from lurkily that claimed the "sub" operation was broken.
You did.  I was mistaken.

I parsed the lengthy strip of code into segments separated by parenthesis to illustrate to myself what groups were collapsing into what, and found that I forgot a value required by the 'SetCreeper' function.  This was why sub was failing.  I made the same error in two scripts, even though I hand-typed both.  Since independently written scripts showed the same results, I failed to look rigorously enough for my own mistakes.

I realized my error quickly enough that I took my post down quickly - I wanted to avoid causing any confusion.