~ubuntu-branches/debian/squeeze/gnubg/squeeze

« back to all changes in this revision

Viewing changes to formatgs.c

  • Committer: Bazaar Package Importer
  • Author(s): Russ Allbery
  • Date: 2010-01-21 14:44:59 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100121144459-khynfv4s1cce4mji
Tags: 0.90+20091206-4
* Avoid building the one-sided rollout database during an
  architecture-dependent build.  Not only does this avoid wasted time on
  the buildds, since it's an architecture-independent file, but it
  should hopefully fix FTBFS problems on the kfreebsd-* buildds.
* Enable SSE on all amd64 systems, not just Linux ones.
* Add a trailing blank line to NEWS.Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * along with this program; if not, write to the Free Software
17
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 *
19
 
 * $Id: formatgs.c,v 1.23 2008/03/18 01:30:32 c_anthon Exp $
 
19
 * $Id: formatgs.c,v 1.32 2009/06/24 18:38:45 Superfly_Jon Exp $
20
20
 */
21
21
 
22
22
#include "config.h"
23
23
#include "backgammon.h"
24
24
 
25
25
#include <glib.h>
26
 
#include <glib/gi18n.h>
27
26
 
28
27
#include "formatgs.h"
29
28
#include "format.h"
32
31
#include "export.h"
33
32
 
34
33
 
35
 
static char *total_text(int nMatchTo)
 
34
static const char *total_text(int nMatchTo)
36
35
{
37
 
    return nMatchTo ? _("EMG (MWC)") : _("EMG (Points)");
 
36
        if (nMatchTo)
 
37
                        return _("EMG (MWC)");
 
38
        else
 
39
                        return _("EMG (Points)");
38
40
}
39
41
 
40
 
static char *rate_text(int nMatchTo)
 
42
static const char *rate_text(int nMatchTo)
41
43
{
42
 
    return nMatchTo ? _("mEMG (MWC)") : _("mEMG (Points)");
 
44
        if (nMatchTo)
 
45
                return _("mEMG (MWC)");
 
46
        else
 
47
                return _("mEMG (Points)");
43
48
}
44
49
 
45
50
static char **
100
105
      return g_strdup_printf( "%3d (%+6.3f (%+7.3f))", 
101
106
                              n, rn, ru );
102
107
  }
103
 
    
104
 
  g_assert_not_reached();
105
 
  return NULL;
106
108
 
107
109
}
108
110
 
127
129
 
128
130
}
129
131
 
130
 
extern GList *
131
 
formatGS( const statcontext *psc, const int nMatchTo,
132
 
          const int fIsMatch, const enum _formatgs fg ) {
 
132
extern GList *formatGS( const statcontext *psc, const int nMatchTo, const enum _formatgs fg ) {
133
133
 
134
134
  GList *list = NULL;
135
135
  char **aasz;
143
143
 
144
144
      static int ai[ 4 ] = { SKILL_NONE, SKILL_DOUBTFUL,
145
145
                             SKILL_BAD, SKILL_VERYBAD };
146
 
      static char *asz[4] = {
 
146
      static const char *asz[4] = {
147
147
        N_("Unmarked moves"),
148
148
        N_("Moves marked doubtful"),
149
149
        N_("Moves marked bad"),
202
202
      for ( i = 0; i < 2; ++i )
203
203
        if ( psc->anUnforcedMoves[ i ] )
204
204
          aasz[ i + 1 ] =
205
 
            g_strdup( gettext ( aszRating[ GetRating( aaaar[ CHEQUERPLAY ][ PERMOVE ][ i ][ NORMALISED ] ) ] ) );
 
205
            g_strdup( Q_(aszRating[ GetRating( aaaar[ CHEQUERPLAY ][ PERMOVE ][ i ][ NORMALISED ] ) ] ) );
206
206
        else 
207
207
          aasz[ i + 1 ] = g_strdup( _("n/a") );
208
208
 
214
214
 
215
215
  case FORMATGS_CUBE:
216
216
    {
217
 
      static char *asz[] = {
 
217
      static const char *asz[] = {
218
218
        N_("Total cube decisions"),
219
219
        N_("Close or actual cube decisions"),
220
220
        N_("Doubles"),
221
221
        N_("Takes"),
222
222
        N_("Passes") };
223
223
 
224
 
      static char *asz2[] = {
 
224
      static const char *asz2[] = {
225
225
        N_("Missed doubles below CP"),
226
226
        N_("Missed doubles above CP"),
227
227
        N_("Wrong doubles below DP"),
318
318
      for ( i = 0; i < 2; ++i )
319
319
        if ( psc->anCloseCube[ i ] )
320
320
          aasz[ i + 1 ] =
321
 
            g_strdup( gettext ( aszRating[ GetRating( aaaar[ CUBEDECISION ][ PERMOVE ][ i ][ NORMALISED ] ) ] ) );
 
321
            g_strdup( Q_ ( aszRating[ GetRating( aaaar[ CUBEDECISION ][ PERMOVE ][ i ][ NORMALISED ] ) ] ) );
322
322
        else 
323
323
          aasz[ i + 1 ] = g_strdup( _("n/a") );
324
324
 
332
332
  case FORMATGS_LUCK: 
333
333
    {
334
334
 
335
 
      static char *asz[] = {
 
335
      static const char *asz[] = {
336
336
        N_("Rolls marked very lucky"),
337
337
        N_("Rolls marked lucky"),
338
338
        N_("Rolls unmarked"),
386
386
      for ( i = 0; i < 2; ++i )
387
387
        if ( psc->anTotalMoves[ i ] )
388
388
          aasz[ i + 1 ] =
389
 
            g_strdup( gettext ( aszLuckRating[ getLuckRating( psc->arLuck[ i ][ 0 ] / psc->anTotalMoves[ i ] ) ] ) );
 
389
            g_strdup( Q_(aszLuckRating[ getLuckRating( psc->arLuck[ i ][ 0 ] / psc->anTotalMoves[ i ] ) ]) );
390
390
        else 
391
391
          aasz[ i + 1 ] = g_strdup( _("n/a") );
392
392
 
437
437
        aasz[ 0 ] = g_strdup( _("Snowie error rate") );
438
438
 
439
439
        for ( i = 0; i < 2; ++i )
440
 
          if ( ( n = psc->anTotalMoves[ 0 ] + psc->anTotalMoves[ 1 ] ) )
 
440
          if ( ( n = psc->anTotalMoves[ 0 ] + psc->anTotalMoves[ 1 ] ) > 0 )
441
441
            aasz[ i + 1 ] = 
442
442
              errorRateMP( -aaaar[ COMBINED ][ TOTAL ][ i ][ NORMALISED ] / n,
443
443
                           0.0f, nMatchTo );
455
455
        for ( i = 0; i < 2; ++i )
456
456
          if ( psc->anCloseCube[ i ] + psc->anUnforcedMoves[ i ] )
457
457
            aasz[ i + 1 ] =
458
 
              g_strdup( gettext ( aszRating[ GetRating( aaaar[ COMBINED ][ PERMOVE ][ i ][ NORMALISED ] ) ] ) );
 
458
              g_strdup( Q_ ( aszRating[ GetRating( aaaar[ COMBINED ][ PERMOVE ][ i ][ NORMALISED ] ) ] ) );
459
459
          else 
460
460
            aasz[ i + 1 ] = g_strdup( _("n/a") );
461
461
 
480
480
                                            psc->arLuckAdj,
481
481
                                            nMatchTo ) );
482
482
 
483
 
          if ( fIsMatch && nMatchTo ) {
 
483
          if ( nMatchTo ) {
484
484
 
485
485
            /* luck based fibs rating */
486
486
          
511
511
 
512
512
        /* error based fibs rating */
513
513
 
514
 
        if ( fIsMatch && nMatchTo ) {
 
514
        if ( nMatchTo ) {
515
515
 
516
516
          aasz = g_malloc( 3 * sizeof ( *aasz ) );
517
517
          aasz[ 0 ] = g_strdup( _("Error based abs. FIBS rating") );
561
561
 
562
562
      }
563
563
 
564
 
      if( psc->fDice && fIsMatch && !nMatchTo && psc->nGames > 1 ) {
 
564
      if( psc->fDice && !nMatchTo && psc->nGames > 1 ) {
565
565
 
566
 
        static char *asz[ 2 ][ 2 ] = {
 
566
        static const char *asz[ 2 ][ 2 ] = {
567
567
          { N_("Advantage (actual) in ppg"),
568
568
            /* xgettext: no-c-format */
569
569
            N_("95% confidence interval (ppg)") },
599
599
          aasz[ 0 ] = g_strdup( gettext( asz[ i ][ 1 ] ) );
600
600
      
601
601
          for ( j = 0; j < 2; ++j ) 
602
 
            aasz[ j + 1 ] = 
603
 
              g_strdup_printf( "%*.*f",
604
 
                               fOutputDigits + 3, fOutputDigits,
605
 
                               1.95996f * sqrt( af[ i ][ 1 ][ j ] / psc->nGames ) );
606
 
 
 
602
          {
 
603
                  float ci = 1.95996f * sqrtf( af[ i ][ 1 ][ j ] / psc->nGames );
 
604
                  float max = af[i][0][j]+ci;
 
605
                  float min = af[i][0][j]-ci;
 
606
                  aasz[ j + 1 ] = g_strdup_printf( "[%*.*f,%*.*f]",
 
607
                                  fOutputDigits + 3, fOutputDigits, min,
 
608
                                  fOutputDigits + 3, fOutputDigits, max );
 
609
          }
607
610
          list = g_list_append( list, aasz );
608
611
 
609
612
        }