Thread: chutes and ladders

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by ckeener
    i quit, this program has defeated me. i give up, i dont care anymore! everything i try doesnt work. im through posting about it on here because everytime i geta reply i get excited that im finally goin to get it and then i just fail. maybe ill just flip burgers for a living. bahh
    that's okay... with an attitude like that you weren't made out for a programming job anyway.

    With coding, as with everything in life, you need to modularize. not only your code, but your algorithm... in more simplistic terms, break it down. look at what you need to do before you try to do it:
    • Pick a random number (spin the wheel)
    • move that random amount of times
    • depending on where you end up, do something


    now you break it up even further, for example, let's take that last bullet:
    • if you land on an empty space, do nothing
    • if you end up on a ladder, go to to the space it points to
    • if you end up on a chute, go to the space it points to.


    now we turn those steps into pseudocode :
    • if the space contains zero (0), go nowhere
    • if the space contains a negative number, acknowledge that it's a chute (print something to the screen), and go backwards that amount of spaces, wrapping to the next line if necessary
    • if the space contains a positive number, acknowledge that it's a ladder (print something to the screen), and go forwards that amount of spaces, wrapping to the next line if necessary
    Last edited by major_small; 03-16-2005 at 09:11 AM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed