| 03-01-2010, 11:24 AM | #1 |
I'm now writing a map for my AI course project. I use World Editor to simulate the Wumpus World. Now i've writen about 800 lines codes. Constantly i find things went wrong when i test the map. When met with a bug , i just use BJDebugMsg function to display related variables' values. For example, these are some of my debug codes: Zinc://! zinc library Debug { // ------------ for debugging ------------ public { // For debug loop integer iDg,jDg; // To see tht point's position function SeeLoc(location loc) { CreateDestructableLoc('B002',loc,0,3,1); } // To see tht point's position function SeePos(real x,real y) { CreateDestructable('B002',x,y,0,3,1); } // To see point (x,y) function PrintXY(string str,integer x,integer y) { BJDebugMsg(str+"["+I2S(x)+","+I2S(y)+"]"); } function PrintI(string str,integer i) { BJDebugMsg(str+I2S(i)); } function Print(integer x) { BJDebugMsg(I2S(x)); } function B2I(boolean b) -> integer { if(b) return 1; else return 0; } // To print models function PrintModels() { BJDebugMsg("AvaliableModel's size = "+I2S(GridCalc.nModels)); for(iDg=0;iDg<GridCalc.nModels;iDg+=1) { for(jDg=0;jDg<Maze.gridc.outEdge.size;jDg+=1) { BJDebugMsg("Model["+I2S(iDg)+","+I2S(jDg)+"]="+I2S(B2I(GridCalc.bAvaliableModel[iDg][jDg]))); } } } // To print a grid's env function PrintEnvs(integer x,integer y,integer e) { BJDebugMsg("env["+I2S(x)+","+I2S(y)+"]="+I2S(B2I(Maze.grids[x][y].env[e]))); } } // debug print inEdge & outEdge //! textmacro ioprint takes IOE BJDebugMsg("$IOE$Edge.size = "+I2S(Maze.gridc.$IOE$Edge.size)); for(iDg=0;iDg<Maze.gridc.$IOE$Edge.size;iDg+=1) { PrintXY("$IOE$Edge["+I2S(iDg)+"]=", Maze.gridc.$IOE$Edge.GetX(iDg), Maze.gridc.$IOE$Edge.GetY(iDg) ); } //! endtextmacro } //! endzinc That the only way I can use for debugging my map right now. It's toooooo verbose to write these kide of debugging codes. I't not clear or simple. It slow me down too much for writing the map. So i came here to ask some suggestions from you guys. And i want to know, how do you debug you map or check the reason of errors ? note: English is not my mother language, so excuse me for some of the language grammar errors. ![]() |
| 03-01-2010, 11:44 AM | #2 |
Hey, I've changed your jass tags to zinc ones. The most advanced debugging aid we have is grimoire's war3err thing which mostly aids you to know when you have an unitialized variable access. perhaps you would have to write textmacros for your usual debug things... Don't forget about debug blocks. |
| 03-01-2010, 11:57 AM | #3 |
Thanks, then i'll go to read the Grimoire's documentation and see how Grimoire's war3err goes. by the way, can Grimoire's war3err make dynamically debugging(step by step) possible? that means debugging when running the map. |
| 03-01-2010, 12:48 PM | #4 | |
Quote:
Grimoire does have a full-on debugger, but I don't think anyone has tested to see if it's broken in an eon. |
| 03-01-2010, 08:29 PM | #5 |
I use "debug call BJDebugMsg()" all along. Mostly, I test things every time that I changed something, and check whether it works or not. You shouldn't do that big steps if you do a lot of mistakes :P |
| 03-01-2010, 10:54 PM | #6 |
yes , i think i made a mistake. i should have test my code constantly while writing. now the problem just get difficult to solve. |
| 03-01-2010, 11:25 PM | #7 |
You could be happy and it was something small actually. Happens to me often enough though. |
| 03-02-2010, 12:06 AM | #8 |
Make sure your logic is correct. like display letter for each if/then/else branch. I find I usually have a backwards logic issue or I forget a condition and things blow up. |
| 03-02-2010, 12:42 AM | #9 |
First I check things that need to be created or initialized, like structs, timers and groups. Then I just put lots of BJDebugMsg to display the variables. But most of my bugs are non-initialized variables >.< (Damn groups, someday... someday...) |
| 03-02-2010, 02:02 AM | #10 |
sounds like there is only this "display debug" way to check map errors. :Sad i'm eager for a dynamic debugger for jass like Olledbg,VC's debugger and etc. |
| 03-02-2010, 03:49 AM | #11 |
Hahahahaha |
| 03-02-2010, 04:28 AM | #12 |
If my code just isn't running. I usually dump checkpoints at the begging and end of my code block. If it displays checkpoint 1 but not 2, i know somethings gone wrong in between that block of code. If its running but running incorrectly, then i usually print out the variables i suspect are getting messed up. |
