Mini project suggestions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Josh Sebastian

    #16
    Re: Mini project suggestions

    On Thu, 02 Oct 2003 15:07:14 -0400, jeffc wrote:
    [color=blue]
    >
    > "Michael Strorm" <mstrorm@yahoo. co.uk> wrote in message
    > news:5e705cb0.0 310011430.cbc75 7d@posting.goog le.com...[color=green]
    >> To get to the point, I'm wanting to start a moderately-sized
    >> project that would take a week (working full time on it, which I won't
    >> be :-) ) to do reasonably, cover a decent subset of the language, be
    >> interesting to do, and workable under (say) gcc on Linux (without too
    >> much nonstandard code). It'd also be interesting to get some practice
    >> in software design in there.[/color]
    >
    > I thought writing a Blackjack (21) simulator was a great exercise.[/color]

    Games in general and card games in particular are good, I think. The first
    non-trivial graphical program I wrote was a version of Set (a card game
    made by MENSA) for Windows.

    Josh

    Comment

    • jeffc

      #17
      Re: Mini project suggestions


      "Josh Sebastian" <curien@cox.net > wrote in message
      news:pan.2003.1 0.02.21.44.36.5 99965@cox.net.. .[color=blue]
      > On Thu, 02 Oct 2003 15:07:14 -0400, jeffc wrote:
      >[color=green]
      > >
      > > "Michael Strorm" <mstrorm@yahoo. co.uk> wrote in message
      > > news:5e705cb0.0 310011430.cbc75 7d@posting.goog le.com...[color=darkred]
      > >> To get to the point, I'm wanting to start a moderately-sized
      > >> project that would take a week (working full time on it, which I won't
      > >> be :-) ) to do reasonably, cover a decent subset of the language, be
      > >> interesting to do, and workable under (say) gcc on Linux (without too
      > >> much nonstandard code). It'd also be interesting to get some practice
      > >> in software design in there.[/color]
      > >
      > > I thought writing a Blackjack (21) simulator was a great exercise.[/color]
      >
      > Games in general and card games in particular are good, I think. The first
      > non-trivial graphical program I wrote was a version of Set (a card game
      > made by MENSA) for Windows.[/color]

      Actually, mine was non-graphical. It was not a game per se, but a
      simulation of what your results would be after so many hands of blackjack,
      with different betting strategies. e.g., if you split 10s rather than
      staying with 20, would you do better or worse in the long run? (worse, by
      the way :-)


      Comment

      • Gene Wirchenko

        #18
        Re: Mini project suggestions

        On Thu, 2 Oct 2003 19:51:12 GMT, Default User <first.last@com pany.com>
        wrote:
        [color=blue]
        >Gene Wirchenko wrote:
        >[color=green]
        >> Quite. There are OO languages for writing these games. See
        >> rec.art.int-fiction.[/color][/color]
        ^^^
        "arts".
        [color=blue]
        >That doesn't provide any instruction in C++ programming. There are two
        >different, related but distinct ideas:
        >
        >
        >1. If you want to learn C++, writing a TA game is a good exercise.
        >
        >2. If you want to write TA games, TADS, Inform or another dedicated
        >language would be a better choice than C++.[/color]

        Agreed.

        Sincerely,

        Gene Wirchenko

        Comment

        • osmium

          #19
          Re: Mini project suggestions

          > > I thought writing a Blackjack (21) simulator was a great exercise.

          I think Solitaire might be fun, just the computational aspects, no graphics.
          Besides I would really like to know what the probability of winning that
          game is, no cheating. I think the classic form is called Klondike.
          Blackjack sounds too easy to use up a week.


          Comment

          • jeffc

            #20
            Re: Mini project suggestions


            "osmium" <r124c4u102@com cast.net> wrote in message
            news:bliahv$cqk 46$1@ID-179017.news.uni-berlin.de...[color=blue][color=green][color=darkred]
            > > > I thought writing a Blackjack (21) simulator was a great exercise.[/color][/color]
            >
            > I think Solitaire might be fun, just the computational aspects, no[/color]
            graphics.[color=blue]
            > Besides I would really like to know what the probability of winning that
            > game is, no cheating. I think the classic form is called Klondike.[/color]

            It shouldn't be too hard to figure it out pretty closely. When you play for
            money, it costs $52, and you get $5 back for every card you place. placing
            10 cards is about the break even point. That's for 1 card at a time, once
            through the deck. The house has to retain a slight edge. Most games you'll
            make significantly less than $52 (place fewer than 10 cards). That's to
            balance breaking the bank.
            [color=blue]
            > Blackjack sounds too easy to use up a week.[/color]

            Sure, getting the game to work. But writing a real simulation that
            calculates percentage of return for the betting strategy you choose is not
            too easy. There's more to it than asking "hit or stay". And there are
            quite a few rules, not to mention rules variations, that have to be taken
            into account. Like most things, it's more complicated than you think. An
            excellent exercise.


            Comment

            • Nils Petter Vaskinn

              #21
              Re: Mini project suggestions

              On Wed, 01 Oct 2003 23:19:44 -0400, Jonathan Mcdougall wrote:
              [color=blue]
              > But PLEASE, before you ask, there is no way in C++ to clear the screen or
              > change the colour of the output :)[/color]

              for (int i = 0; i < MAX_LINES; i++) {
              std::cout << "\n";
              }
              std::cout.flush ();

              Is the closest i can think of as a way to clear the screen using only the
              standard library.

              He could do something like:

              void Screen::clear()
              {
              #if defined PLATFORM_1
              /* do platform specific clear */
              #else
              /* Do scroll past the top clear */
              #endif
              }

              --
              NPV
              "Linux is to Lego as Windows is to Fisher Price." - Doctor J Frink

              Comment

              • Gene Wirchenko

                #22
                Re: Mini project suggestions

                On Fri, 03 Oct 2003 08:38:58 GMT, "Nils Petter Vaskinn"
                <no@spam.for.me .invalid> wrote:

                [snip]
                [color=blue]
                >for (int i = 0; i < MAX_LINES; i++) {
                > std::cout << "\n";
                >}
                >std::cout.flus h();
                >
                >Is the closest i can think of as a way to clear the screen using only the
                >standard library.[/color]

                1) MAX_LINES?

                2) It will not work if the cursor is positioned other than on the
                bottom line.

                [snip]

                Sincerely,

                Gene Wirchenko

                Comment

                • Kevin Goodsell

                  #23
                  Re: Mini project suggestions

                  Nils Petter Vaskinn wrote:[color=blue]
                  >
                  > He could do something like:
                  >
                  > void Screen::clear()
                  > {
                  > #if defined PLATFORM_1
                  > /* do platform specific clear */
                  > #else
                  > /* Do scroll past the top clear */
                  > #endif
                  > }
                  >[/color]

                  Personally, I'd take a different approach. All that conditional
                  compilation code could get very ugly. I think I'd have a source file set
                  aside for platform-dependent screen operations, and a new implementation
                  of it can be supplied for each platform. Also, a default implementation
                  could be available.

                  -Kevin
                  --
                  My email address is valid, but changes periodically.
                  To contact me please use the address from a recent posting.

                  Comment

                  • Gene Wirchenko

                    #24
                    Re: Mini project suggestions

                    On Thu, 2 Oct 2003 15:15:51 -0400, "jeffc" <nobody@nowhere .com> wrote:
                    [color=blue]
                    >
                    >"jeffc" <nobody@nowhere .com> wrote in message
                    >news:3f7c7845_ 1@news1.prserv. net...[color=green]
                    >>
                    >>
                    >> I thought writing a Blackjack (21) simulator was a great exercise.[/color]
                    >
                    >You didn't mention OO, but in addition I found this to be an outstanding
                    >exercise in OO design. It's not complex, but at the same time makes you
                    >think quite about the relationships between the objects involved. Obviously
                    >you need a deck of cards, but who has it? If the dealer has it, then how
                    >much access to it does he have? Do you need a card table? Do you need a
                    >casino? Who gets your chips when you lose, the dealer or the casino? When
                    >you are dealt a hand, where does the hand go? (In a real casino, the hand
                    >is "yours", but you can't touch the cards - only the dealer can. At the
                    >same time, only you can make decisions about changing your hand, and the
                    >dealer can't. So who "owns" or "has" the hand - you or the dealer?) Do you
                    >even need a deck of cards? Can't you just deal a "card" as a random number
                    >"out of thin air", from an "infinite deck"? (Before deciding, note that the
                    >odds of getting a blackjack are higher in real life when using 1 deck of
                    >cards than with 2!!)[/color]

                    You dealt me two ten of diamonds. Hold still while I go get my
                    gun.

                    Sincerely,

                    Gene Wirchenko

                    Comment

                    • Kevin Goodsell

                      #25
                      Re: Mini project suggestions

                      Gene Wirchenko wrote:[color=blue]
                      >
                      >
                      > You dealt me two ten of diamonds. Hold still while I go get my
                      > gun.[/color]

                      Hm? Why would you do that? That's a damn good hand!

                      (Most if not all casinos use more than one deck of cards in blackjack.
                      Some use up to 8, I believe.)

                      -Kevin
                      --
                      My email address is valid, but changes periodically.
                      To contact me please use the address from a recent posting.

                      Comment

                      • Mike Wahler

                        #26
                        Re: Mini project suggestions

                        "Gene Wirchenko" <gwirchenkoEXCE PT@CAPITALSwenc omine.com> wrote in message
                        news:dotrnvcido ovnlrj5o5v2soqu pq3rhbk4v@4ax.c om...[color=blue][color=green]
                        > >odds of getting a blackjack are higher in real life when using 1 deck of
                        > >cards than with 2!!)[/color]
                        >
                        > You dealt me two ten of diamonds. Hold still while I go get my
                        > gun.[/color]

                        Never played or watched a blackjack game in a casino,
                        have you?

                        -Mike


                        Comment

                        • cheeser

                          #27
                          Re: Mini project suggestions

                          > To get to the point, I'm wanting to start a moderately-sized[color=blue]
                          > project that would take a week (working full time on it, which I won't
                          > be :-) ) to do reasonably, cover a decent subset of the language, be
                          > interesting to do, and workable under (say) gcc on Linux (without too
                          > much nonstandard code). It'd also be interesting to get some practice
                          > in software design in there.
                          > So, I'd be interested to get some suggestions, because I feel like
                          > doing *something* with all this knowledge (and more importantly,
                          > finding out what I don't know well). Thanks![/color]

                          One of my all-time favorite projects that I've taken on is to write a
                          program to solve sliding tile puzzles (8-puzzles). I'm sure you've seen
                          them - a square grid broken up into 9 tiles, but one of the tiles is
                          missing, allowing the other tiles to slide around.

                          If you're feeling really ambitious, you could try to write a generic
                          implementation that could be used to solve any one-player game for which a
                          state space search is applicable.

                          If you choose this project though, be aware of one thing: Not all puzzes are
                          solvable! For example, if you start in this state:

                          123
                          405
                          678

                          (0 represents the missing tile)

                          and make it your goal to get to this state:

                          132
                          405
                          678

                          it is impossible. Exactly half of all possible board positions are
                          reachable from a given puzzle configuration.

                          Here's a good test puzzle that does have a solution:

                          308
                          257
                          146

                          With this being the goal state:

                          123
                          405
                          678

                          This project will require some research on your part to find a suitable
                          algorithm, but the implementation of that algorithm will teach you a lot
                          about C++. Also, try to use the C++ Standard Library for as much of your
                          implementation as you can.

                          Anyway, have fun with whatever you do and good luck!

                          Dave



                          Comment

                          • Michael Strorm

                            #28
                            Re: Mini project suggestions

                            "Jonathan Mcdougall" <jonathanmcdoug all@DELyahoo.ca > wrote in message news:<%PMeb.823 98$tJ6.2168193@ wagner.videotro n.net>...[color=blue]
                            > But PLEASE, before you ask, there is no way in C++ to clear the screen or
                            > change the colour of the output :)[/color]

                            Funny, I was going to make some remark about outputting ANSI codes to
                            stdout from a standard
                            std::cout << "Your string here";
                            which would be well within the ISO standard, right?

                            Of course, it wouldn't be portable, but it would still be within the
                            standard >;-)

                            In all seriousness, point taken, I knew ANSI C (89) didn't support
                            such stuff, and I wasn't expecting ISO C++ to do that either.

                            <troll>but id like to know how to do that in visual c++ anyway</troll>

                            - Michael S

                            Comment

                            • Michael Strorm

                              #29
                              Re: Mini project suggestions

                              Gene Wirchenko <gwirchenkoEXCE PT@CAPITALSwenc omine.com> wrote in message news:<npronv0cf 3p0736dcs3otq9e 9b6ir4df7e@4ax. com>...[color=blue]
                              > On Thu, 2 Oct 2003 16:35:14 GMT, Default User <first.last@com pany.com>
                              > wrote:
                              >[color=green]
                              > >Gene Wirchenko wrote:
                              > >[color=darkred]
                              > >> You could write a small text adventure. It need not do much, but
                              > >> just to bring it up to framework level, you are going to have to do a
                              > >> lot of work with I/O and string manipulation. There are plenty of
                              > >> opportunities to define classes or use STL. After you have the
                              > >> framework, you can bolt on a lot of other stuff that fits your fancy.[/color][/color]
                              >[color=green]
                              > >That's a pretty good project, if you like TA games. It was my learning
                              > >program for C many moons ago. It's probably even better for C++, because
                              > >the OO approach is natural for a game like that.[/color]
                              >
                              > Quite. There are OO languages for writing these games. See
                              > rec.art.int-fiction.[/color]

                              I'm going for the "text adventure" suggestion.... although it's going
                              to be more like a framework than an actual text adventure. And the
                              text adventure I'm designing to go round it will probably be quite
                              strange- more an opportunity to implement some ideas I had (for
                              example, multiple characters in the game acting independently, all
                              represented by concrete implementations of some abstract base class.
                              And then I noticed how 'rooms', 'objects' and 'characters' all have
                              some common characteristics which suggest an inheritance
                              relationship... and so on.

                              Oh, and I agree with the comment elsewhere in the thread about this
                              being an excuse to learn C++ better as opposed to the optimal choice
                              to design a text adventure. The former is *definitely* what I'm after.

                              I think I'd have trouble making it fit into 16KB if I was using C++
                              ;-)

                              - Michael S

                              Comment

                              • Michael Strorm

                                #30
                                Re: Mini project suggestions

                                "jeffc" <nobody@nowhere .com> wrote in message news:<3f7c7845_ 1@news1.prserv. net>...[color=blue]
                                > I thought writing a Blackjack (21) simulator was a great exercise.[/color]

                                Hey, I already wrote a Connect-4 simulator with pruning blah-blah for
                                university... that's quite enough Artificial Intelligence for one
                                year. ;-)

                                Seriously, good idea- I'll look at it after having a stab at the text
                                adventure.

                                - Michael S

                                Comment

                                Working...