Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: Challenge: Algorithm To Generate Bubble Blast 2 Puzzles With Difficulty

by Limbic~Region (Chancellor)
on Sep 11, 2013 at 15:54 UTC ( #1053515=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Challenge: Algorithm To Generate Bubble Blast 2 Puzzles With Difficulty
in thread Challenge: Algorithm To Generate Bubble Blast 2 Puzzles With Difficulty

MidLifeXis,
The main function is a bit long for my tastes

I agree. It grew over time. I am also more verbose than I need to be. I am using -O3 for gcc which I believe inlines whatever it can. I am potentially considering a new direction entirely so if I touch it again, I will certainly make more use of functions.

Some of the repeated board manipulations or constants should probably be put into macros

Macros are incredibly powerful but if you don't code enough in C to make them second nature they can have the opposite effect as intended (making code harder to understand rather than easier). I prefer to explicitly say what I am doing when working in a language I am not comfortable in so that I understand the code when I come back to it later. As far as magic numbers - yeah. I started to make variables to give them meaning but wasn't consistent as I tried to finish the code. In a re-write I would probably have some global static variables defined outside of main.

Other than that, do you have a profiler that shows any hotspots?

No. I was expecting someone to look at the way I copy one array to another and say a far more efficent way of doing that was memcopy with a working example but alas, no such luck.

Cheers - L~R


Comment on Re^5: Challenge: Algorithm To Generate Bubble Blast 2 Puzzles With Difficulty
Re^6: Challenge: Algorithm To Generate Bubble Blast 2 Puzzles With Difficulty
by BrowserUk (Pope) on Sep 11, 2013 at 16:05 UTC
    Some of the repeated board manipulations or constants should probably be put into macros

    Macros are incredibly powerful but if you don't code enough in C to make them second nature they can have the opposite effect as intended

    Don't use macros, use functions marked inline instead:

    inline int func( int arg ) { // stuff return 1; }

    All the benefits of macros with none of the nasty side-effects or opacity.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053515]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-10-24 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls