debugint
Notes the number on top of the integer stack so you can look at it from the bot's console, without popping it and at no cost.
Facts
- Word
debugint- Family
- Advanced
- Integer stack
- pops 1, pushes 1
- What it does
- Logs the top of the integer stack in the bot's trace, without popping it. It costs no energy. Above 16,777,216 the value may change a little.
- Cost
- Advanced command; debugint and debugbool are free
- Runs
- inside a gene: in the condition (cond) and in the body (start or else)
debugint looks at the number on top of the integer stack and notes it, along with the position of the word in the DNA, in the bot's trace. The stack stays the same. It is the way to see what value a calculation has halfway through without changing what the bot does.
cond
start
*.nrg debugint 10 div debugint .up store
stopTo see the trace, open the bot's console in the inspector and use the debug command: it shows each noted value with its position. The trace is cleared at the start of each bot's turn, so you always see the one from the last cycle.
It costs no energy, unlike the rest of the advanced operators, so it can be left in the DNA while you test. With one caveat: with numbers above 16,777,216 (which only come from big calculations, never from memory) it can change the value by a few units when noting it. For the boolean stack there is debugbool.