User-based win-loss support, and more

Developers
2004-11-11
2013-04-15
  • Jack Twilley

    Jack Twilley - 2004-11-11

    I've implemented a user-based (not bot-based) win-loss score recording.  This involved adding columns to the user table and adding some simple SQLish stuff.  There's no useful way to display the results yet, but the data's being collected.

    I'll submit a patch for this after I finish the other bit I'm working on, which is adding a column to the user table for faceID so you always start with your preferred face.  Whee.

     
    • Chad McHenry

      Chad McHenry - 2004-11-11

      Yes, I've long thought that the user database should be used for something more than just passwords :)

       
      • Jack Twilley

        Jack Twilley - 2004-11-11

        Hopefully by the end of the day I'll be able to post the patch, and you can modify the applet to provide a sane way to select a default face.

        Also, if anyone else out there feels like writing a simple applet to display the standings, feel free.

         
    • Jack Twilley

      Jack Twilley - 2004-11-11

      Okay, I lied, I've submitted the patch for win-loss and some other database stuff.  I have to find the right place for the face stuff, then I'll post another patch.

       
      • Jack Twilley

        Jack Twilley - 2004-11-12

        And now it's all done!

        1064827 is the patch number.

        Please test it and let me know how it goes!

         
        • peutri

          peutri - 2005-01-18

          Tested and works great at home.

          Thanks for providing! :)

           
          • Jack Twilley

            Jack Twilley - 2005-01-18

            Excellent.  Did you write any software to view the results?

             
            • peutri

              peutri - 2005-01-18

              Some basic php with a stupid rating function. I'll have to find a better one sometime, but it suits my (few) regular players fine.

               
    • Rivet

      Rivet - 2005-03-03

      Jack,  I implemented your patch, but then decided that it didn't go far enough, so I made the following additions:

      1.  Face - I store all of the faces used by humans having an account at the end of the game and then use the stored face whenever the account holder sits down.  They can still change faces, but the last one they use in a completed game will be stored and retrieved the next time they sit down.

      2. Win/Losses -  I store wins, losses, and total points for all persons having an account on my server and for all of the robots.  I have also created a method for the user to view theses statistics plus some derived statistics as well.  The new interface shows:  Name, Rank, Wins, Losses, Total Points, Average Points Per Game, and Percent of Games Won for both humans and robots.  Rank is determined by sorting the data by:  Winning Percentage, Average Points scored, and then by total points.

      These modifications can be experienced at www.browan.org.

      PS  -  I'm attempting to modify the statistics tables to allow the user to sort the statistics data by any column they chose (such as by name or by average points scored).  But that may be overkill.  What do you think?

       
      • Ryan Herbert

        Ryan Herbert - 2005-03-03

        Can you submit your patch on here, either as a patch from the baseline CVS or as a patch to his patch (1064827)?  Remembering the last face you used is a feature I was thinking about adding.

         
        • Rivet

          Rivet - 2005-03-04

          Great minds think alike, I guess.  I'd be happy to submit a patch.  Can you point me to some instructions for submitting a patch.  I'm a novice Java programmer and am not sure which tools to use.

           
          • Ryan Herbert

            Ryan Herbert - 2005-03-04

            I'm assuming that you're directly modified source that you've checked out of CVS, but you haven't checked it in. If so, you should be able to do this to generate a unified patch file:

            cvs diff -u > ../mypatchname.patch

            Of course, if you're using WinCVS or Eclipse for checking out the source, you'll have to figure out where to run a commandline CVS...  Let me know some more specifics about your setup if you need more help.

             
            • Rivet

              Rivet - 2005-03-04

              I'm afraid that I didn't check out any source code.  I downloaded and modified the code using Sun's IDE running on XP Home.

              The classes and files I modified are:
              soc.message.SOCMessage
              soc.server.SOCServer
              soc.server.database.SOCDBHelper
              index.html

              The classes and files I created are:
              soc.client.SOCStatisticsClient
              soc.message.SOCGetStatistics
              soc.message.SOCResetStatistics
              soc.message.SOCShowStatistics
              statistics.html

              I've browsed the online CVS files and determined that none of the files I've changed appear to have any modifications since I downloaded version 1.0.6,
              so I should be able to check out the sources now and then checkin the sources with my mods.

              However, I'm not sure what to do with .html files.  I've modified index.html extensively for my site.  I suppose I could check out the original index.html and then only change the necessary parts for the implementation.  The statistics.html file I created is designed for my site.  Do I need to create a generic html file for upload?

              I've never done a check-in or check-out using CVS.  Can it be done using the CVS capability built in to the IDE?

              And thanks for the help.

               
              • Ryan Herbert

                Ryan Herbert - 2005-03-04

                You should be able to do a cvs checkout using the IDE, but all I can find is that it supports CVS - I haven't been able to find any documentation on actually using CVS in the IDE. 

                If it's not easy to figure out how to use their CVS client, you could try it with WinCVS - I could walk you through how to set that up.  Even without that, though, you could use a program like WinMerge to generate a diff between the original source files you started with and your modified files.

                As for your extensively modified HTML file, for the patch it'd be best if you could just move over the changes applicable for your patch.  WinMerge can make moving those changes over fairly easy.

                 
    • Rivet

      Rivet - 2005-03-07

      OK Ryan, I think I've figured out how to use the IDE/CVS combo.  I've checked out the project.  But now I have the following problems:

      1.  After I copied all of the changed files to the Working Directory, I tried a build (using 1.4.2) and got some errors, all in SOCServer.java, which, although they are in a file I modified, appear to be unrelated to my changes.  (I can send a file with the errors, but the line numbers won't be correct for you.)  Should I just ingnore them?  Or should I get these to build before I deliver the patch?

      2.  I can't get the IDE to perform a recursive diff.  It seems that I have to diff individual files or folders.  Any ideas on getting a recursive diff?  Or do I need to concatenate the output of all the diffs?

      3.  Though the diffs show the references to the new files I have created, they do not show the content of these new files.  How do I get the new files included in the patch?

      I would find this much easier if we could actully talk.  Is there any way this could be arranged.  I'd be glad to make the call.

       
    • Rivet

      Rivet - 2005-03-09

      Well, I've merged the updated files, and have successfully compiled and tested the result, but I'm still having the following problems:

      1.  I can get a recursive, unified diff using the IDE, but it won't let me start the diff at the top level.  It will only start file level for java files and the folder level for html files.  Does anybody know of any work-arrounds for this, or should I just download and install another tool to do the diffs?  I already have Cygwin installed, but the shell window goes away shortly after it appears.

      2.  Will the recursive diff contain the new files I have added in their output?

      3.  The changes for version 1.3  of soc.server.database.SOCDBHelper do not show up in the diffs.  I just checked out jsettlers on friday.  What's going on?

      I would really like to get this patch uploaded.  Any help would be appreciated.

       
      • Ryan Herbert

        Ryan Herbert - 2005-03-10

        Sorry I took so long...  I don't really know anything about that IDE, so I'm afraid that I can't be much help with starting the diffs at the project directory level.  I also don't know if it'd include the new files you've added in the diff, so I'd recommend giving WinMerge a try to generate the diff for you.

        To use WinMerge, I'd just extract a clean copy of the jsettlers source somewhere and have WinMerge do a diff between the two directories.

        If you e-mail that diff to my sourceforge address or put it someplace that I can download it, I can give it a try and let you know if it works for me.

        As for #3...  I'm not sure what you mean, but if the file is different from the repository version, WinMerge should pick it up.

         
        • Rivet

          Rivet - 2005-03-10

          I installed WinMerge and checked out the versions labeled "HEAD" to a fresh directory.  I then ran WinMerge to show the diffs between the baseline and modified jsettlers directories recursivley.  The result showed literally hundreds of different files.  This result doesn't appear very useful (or correct) to me.

          I then diffed the files I deemed to have changed using the IDE/CVS tools.  But these tools do not allow me to diff the new files I have created.  Nor does WinMerge, as a matter of fact.  When I try to produce a patch with WinMerge it produces a diff file that tells me that every single line has been deleted and replaced by (mostly identical) new lines.  (And yes, I told the WinMerge patch tool to ignore end of line character differences.) 

          I have placed the (4) diff files and all of the new files that I created into a folder on my desktop.  I surmised that you, with all of your knowledge and wizard-like abilities, would be able to create an appropriate patch file.  But it appears there is no way to send this folder to you through the SourceForge mail (I can't find a way to include attachments).  Now what?

           
          • Chad McHenry

            Chad McHenry - 2005-03-10

            Learning to create patches is definitely worth the effort if you enjoy working on and contributing to projects!

            I can't speak toward any of the IDEs. Do you have cygwin installed? It provides standard unix tools for windows environment, including standard command line tools such as a shell, cvs, ssh, diff, patch, and many, many other useful things.  You can get it from http://www.cygwin.com.

            When I've had to use an IDE, I still find it easiest to get the IDE to work with the project structure and shell tools, rather than the other way around.  That way when I can't figure out the "IDE way" to do things, I have a fall back.

            My suggestion is to get cygwin, and check out the project as anonymous, using cvs from a shell: http://sourceforge.net/cvs/?group_id=103866 . Configure your IDE to use that directory.  The project has an ant file, and many modern IDE's can use this, which would be a Good Thing, rather than trying to use an IDE specific directory structure for output.

            If you can't get a cvs diff from the top level of the project using the IDE, use the shell, cd to the project dir and type the cvs diff command:

            > cvs diff -u

            I've never been able to get a diff from CVS which includes files you've added to the project. Those will have to be submitted, along with the patch. Specify the directory they belong in. If your patch adds many files, consider a single tarball instead of many attachments.

            ...Chad

             
            • Rivet

              Rivet - 2005-03-14

              I had more problems creating the patch than I had writing and testing the code.

              I already had cygwin installed, but I hadn't installed the cvs addon.  After I installed cygwin's CVS tool, I was able to generate a unified recursive diff.  But the diff showed literally thousands of lines and tens of files changed that I hadn't touched.  I figured that maybe my jsettlers download wasn't up-to-date, so I checked out a fresh version from cvs using the IDE.  Doing another diff showed the same differences as before. 

              A quick inspection of the diff showed that my changes were indeed there, but there were many thousands of changed lines that were not part of my code changes.  In most of these case the diff indicated that entire files had every line changed!  But the only difference I could see in the lines was the newline character at the end of each line, one version had none and the other version had DOS line endings.  Where did these dos newline characters come from?  I did not edit, or even open, most the files indicated as changed.

              I then cleaned up the diff by deleting all of the lines for the files I did not change.  When I first tried to submit the patch, I discovered that only one attached file is permitted (using the SourceForge patch interface).  This would not allow me to include the new files I created.  So I placed the diff and all of the changed files in one directory and tarred that directory using the following line:

              tar cvf - `find . -print` > ../stats.patch

              I then gzipped the resulting .tar file to create the .tar.gz file.  When I inspected the .tar.gz file, I found that it contained two of everything!  I'm not sure how that happened.  I guess I still have a long way to go to learn how to create patches quickly and easily.

              Thanks for your encouragement.

               
              • Chad McHenry

                Chad McHenry - 2005-03-15

                > I had more problems creating the patch than I had writing and testing the code.

                Welcome to the world of development!  Learning and configuring new tools is always a PITA (thus my distaste for the "latest-and greatest" IDE). I've come to take the tools I use for granted, as you may someday too!  We'll get you through it, but it does take some patience :-)

                > ...but there were many thousands of changed lines...the only difference I could see in the lines was the newline character ...

                Very common problem for windows CVS users. Google may help.  What I can tell you is that CVS is "supposed" to take care of changing line feeds as it check in/out files, doing diffs, etc.., but I've heard of this problem on LOTS of win CVS clients (turtlecvs wincvs, and cygwin included).

                Something that may or may not help: Cygwin has a notion of "default" line feed when it creates new files (but which utils are affected?) and I recall having to choose DOS (CRLF) or UNIX (LF) when I originally installed cygwin.  I choose Unix (why use two character new-lines????), though I don't know if that is why I don't see this problem.

                I have seen this happen to files unexpectedly though, when I pipe a file through a windows app that uses CRLF.  Even Java has it's quirks working within cygwin (CLASSPATH still requires ';' which bash doesn't like)

                > I then cleaned up the diff by deleting all of the lines for the files I did not change.

                As long as you delete the entire patch section for each file you don't want included, you should be ok, but be aware that patch files are notoriously fragile. Careful! You may want to apply the patch to a fresh repository checkout to see that it still works.

                > ...and tarred that directory using the following line:
                >
                > tar cvf - `find . -print` > ../stats.patch

                A better way to create a tarball of the directory "myfiles" which is in the current directory:

                $ tar -zcf myfiles.tar.gz myfiles

                the -z flag causes tar to gzip it's output (a gnu extension) saving us a step.  Tar is recursive, so just tar the directory, not files from within the directory. This is also nice because the tarball unpacks to a single directory which you should give the same name as the tarball (sans extensions).  Much cleaner for the receiver, otherwise they'll need to create a directory to untar the files to and cd to it before untarring... blah!

                > I found that it contained two of everything!

                I have no idea :-) Try the command I suggested above.

                ...Chad

                 

Log in to post a comment.