Like a star, I burn bright, dissipating into the night.

Jeff_Relf Me at Privacy.NET
Thu Jun 2 03:49:16 EDT 2005


Hi  phaywood,  Re:  Your grooving to this mantra of mine:
  Like a star, I burn bright, dissipating into the night.

Seeing as you're in Comp.Lang.C, I'll express that in MicroSoft_C++ 7.1,
slowly dissipating Sun into Night.

I'm using special 32 bit random number routines here,
but, because the appropriate graphics would be too much work,
the results can only be viewed in a debugger.

#pragma warning( disable:  4127 4508  )
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define LOOP while ( 1 )
#define Loop( N ) int J = - 1, LLL = N ; while ( ++ J < LLL )
#define LoopD( N ) int J = N ; while( -- J )
#define Tics ( QueryPerformanceCounter( ( Quad * ) & _Tics ), _Tics )

typedef LARGE_INTEGER Quad ;  typedef int * int_P ;

const int HighResQual = 0x400, DecM = HighResQual* 4- 1, LongLeg = 63
, Short_Leg = 37, BothLegs = LongLeg + Short_Leg
, Seed_Buf_Sz = 2 * BothLegs - 1, StopBit = 1 << 30
, EvenBits = StopBit - 2, Rand_Mask = StopBit - 1 ;

int LegsBuf [ BothLegs ], HighResBuf [ HighResQual ];
int_P RanE = HighResBuf + BothLegs, RanP ;
__int64 _Tics ;
Deal();

Shuffle () { int StreamSperation = 70 - 1, Seed_Buf[ Seed_Buf_Sz ]
  , Seed = int( Tics ), Seed_2 = Seed + 2 & EvenBits;  RanP = RanE ;
  { Loop( BothLegs ) { Seed_Buf[ J ] = Seed_2 ;  Seed_2 <<= 1 ; 
      if ( Seed_2 >= StopBit ) Seed_2 -= EvenBits; } }
  ZeroMemory( Seed_Buf + BothLegs, ( BothLegs - 1 ) * 4 ); Seed_Buf[ 1 ] ++ ; 
  Seed_2 = Seed & Rand_Mask ;
  LOOP {  { LoopD( BothLegs ) Seed_Buf[ 2 * J ] = Seed_Buf[ J ]; }
    { int_P P = Seed_Buf + 1, R = Seed_Buf + Seed_Buf_Sz - 1 ; 
      Loop( BothLegs - LongLeg / 2 - 1 ) 
        P[ 2 * J ] = R [ -2 * J ] & EvenBits ; }
    { int_P B = Seed_Buf, P = B + Seed_Buf_Sz, R = B + Short_Leg - 1 ; 
      LoopD( BothLegs ) {  if ( ! ( * -- P & 1 ) ) continue; 
      R [ J ] = R [ J ] - * P & Rand_Mask ; 
      B [ J - 1 ] = B [ J - 1 ] - * P & Rand_Mask; }  }
    if ( Seed_2 & 1 ) { memmove( Seed_Buf + 1, Seed_Buf, BothLegs * 4 );
      * Seed_Buf = Seed_Buf [ BothLegs ];
      if ( Seed_Buf [ BothLegs ] & 1 ) 
        Seed_Buf [ Short_Leg ] 
        = Seed_Buf [ Short_Leg ] - Seed_Buf[ BothLegs ] & Rand_Mask ;  }
    if ( ! Seed_2 && ! -- StreamSperation ) break ;  Seed_2 >>= 1 ;  }
  memmove( LegsBuf, Seed_Buf + Short_Leg, LongLeg * 4 ); 
  memmove( LegsBuf + LongLeg, Seed_Buf, Short_Leg * 4 );  Deal(); }

int Deal() {  if ( ! RanP ) Shuffle();
  if ( RanP && RanP < RanE )  return * RanP ++ ;  RanP = HighResBuf ;
  memmove( HighResBuf, LegsBuf, sizeof LegsBuf );
  { Loop( HighResQual - BothLegs ) 
      HighResBuf [ J + BothLegs ] 
      = HighResBuf [ J ] - HighResBuf [ J + LongLeg ] & Rand_Mask ;  }
  int_P  P = HighResBuf + HighResQual - Short_Leg; 
  { Loop( Short_Leg ) 
      LegsBuf [ J ] = P [ J - LongLeg ] - P [ J ] & Rand_Mask ;  }
  P = HighResBuf + HighResQual - LongLeg ; 
  Loop( LongLeg ) 
    LegsBuf [ J + Short_Leg ] = P [ J ] - LegsBuf [ J ] & Rand_Mask ;  
  return * RanP ++ ; }

inline float Rand() { return Deal() / ( float ) Rand_Mask ; }

main() {  double Star = 1e308, Night = 0 ;
  LOOP {  float Dissipation = Rand();
    if ( Star < Dissipation ) { Star = 0 ; return ; }
    Star -= Dissipation, Night += Dissipation ;  }  }




More information about the Python-list mailing list