static void ReadNeededBitMaps( void *theEnv) { char *bitMapStorage, *bitMapPtr; unsigned long space; long i; unsigned short *tempSize; /*=======================================*/ /* Determine the number of bitmaps to be */ /* read and space required for them. */ /*=======================================*/ GenReadBinary(theEnv,(void *) &SymbolData(theEnv)->NumberOfBitMaps,(unsigned long) sizeof(long int)); GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long int)); if (SymbolData(theEnv)->NumberOfBitMaps == 0) { SymbolData(theEnv)->BitMapArray = NULL; return; } /*=======================================*/ /* Allocate area for bitmaps to be read. */ /*=======================================*/ bitMapStorage = (char *) gm3(theEnv,(long) space); GenReadBinary(theEnv,(void *) bitMapStorage,space); /*================================================*/ /* Store the bitMap pointers in the bitmap array. */ /*================================================*/ SymbolData(theEnv)->BitMapArray = (BITMAP_HN **) gm3(theEnv,(long) sizeof(BITMAP_HN *) * SymbolData(theEnv)->NumberOfBitMaps); bitMapPtr = bitMapStorage; for (i = 0; i < SymbolData(theEnv)->NumberOfBitMaps; i++) { tempSize = (unsigned short *) bitMapPtr; SymbolData(theEnv)->BitMapArray[i] = (BITMAP_HN *) EnvAddBitMap(theEnv,bitMapPtr+sizeof(unsigned short),*tempSize); bitMapPtr += *tempSize + sizeof(unsigned short); } /*=========================*/ /* Free the bitmap buffer. */ /*=========================*/ rm3(theEnv,(void *) bitMapStorage,(long) space); }
static void mix_columns(uint8_t *state) { int i; uint8_t cpy[4]; for (i = 0; i < 4; i++) { cpy[0] = state[0 * 4 + i]; cpy[1] = state[1 * 4 + i]; cpy[2] = state[2 * 4 + i]; cpy[3] = state[3 * 4 + i]; state[i] = gm2(cpy[0]) ^ gm1(cpy[3]) ^ gm1(cpy[2]) ^ gm3(cpy[1]); state[4+i] = gm2(cpy[1]) ^ gm1(cpy[0]) ^ gm1(cpy[3]) ^ gm3(cpy[2]); state[8+i] = gm2(cpy[2]) ^ gm1(cpy[1]) ^ gm1(cpy[0]) ^ gm3(cpy[3]); state[12+i] = gm2(cpy[3]) ^ gm1(cpy[2]) ^ gm1(cpy[1]) ^ gm3(cpy[0]); } }
globle void ReadNeededSymbols( void *theEnv) { char *symbolNames, *namePtr; unsigned long space; long i; /*=================================================*/ /* Determine the number of symbol names to be read */ /* and space required for them. */ /*=================================================*/ GenReadBinary(theEnv,(void *) &SymbolData(theEnv)->NumberOfSymbols,(unsigned long) sizeof(long int)); GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long int)); if (SymbolData(theEnv)->NumberOfSymbols == 0) { SymbolData(theEnv)->SymbolArray = NULL; return; } /*=======================================*/ /* Allocate area for strings to be read. */ /*=======================================*/ symbolNames = (char *) gm3(theEnv,(long) space); GenReadBinary(theEnv,(void *) symbolNames,space); /*================================================*/ /* Store the symbol pointers in the symbol array. */ /*================================================*/ SymbolData(theEnv)->SymbolArray = (SYMBOL_HN **) gm3(theEnv,(long) sizeof(SYMBOL_HN *) * SymbolData(theEnv)->NumberOfSymbols); namePtr = symbolNames; for (i = 0; i < SymbolData(theEnv)->NumberOfSymbols; i++) { SymbolData(theEnv)->SymbolArray[i] = (SYMBOL_HN *) EnvAddSymbol(theEnv,namePtr); namePtr += strlen(namePtr) + 1; } /*=======================*/ /* Free the name buffer. */ /*=======================*/ rm3(theEnv,(void *) symbolNames,(long) space); }
globle struct expr *PackExpression( struct expr *original) { struct expr *packPtr; if (original == NULL) return (NULL); packPtr = (struct expr *) gm3((long) sizeof (struct expr) * (long) ExpressionSize(original)); ListToPacked(original,packPtr,0L); return(packPtr); }
globle void ReadNeededIntegers( void *theEnv) { long long *integerValues; long i; /*==============================================*/ /* Determine the number of integers to be read. */ /*==============================================*/ GenReadBinary(theEnv,&SymbolData(theEnv)->NumberOfIntegers,(unsigned long) sizeof(unsigned long int)); if (SymbolData(theEnv)->NumberOfIntegers == 0) { SymbolData(theEnv)->IntegerArray = NULL; return; } /*=================================*/ /* Allocate area for the integers. */ /*=================================*/ integerValues = (long long *) gm3(theEnv,(long) (sizeof(long long) * SymbolData(theEnv)->NumberOfIntegers)); GenReadBinary(theEnv,(void *) integerValues,(unsigned long) (sizeof(long long) * SymbolData(theEnv)->NumberOfIntegers)); /*==========================================*/ /* Store the integers in the integer array. */ /*==========================================*/ SymbolData(theEnv)->IntegerArray = (INTEGER_HN **) gm3(theEnv,(long) (sizeof(INTEGER_HN *) * SymbolData(theEnv)->NumberOfIntegers)); for (i = 0; i < SymbolData(theEnv)->NumberOfIntegers; i++) { SymbolData(theEnv)->IntegerArray[i] = (INTEGER_HN *) EnvAddLong(theEnv,integerValues[i]); } /*==========================*/ /* Free the integer buffer. */ /*==========================*/ rm3(theEnv,(void *) integerValues,(long) (sizeof(long long) * SymbolData(theEnv)->NumberOfIntegers)); }
globle void ReadNeededFloats( void *theEnv) { double *floatValues; long i; /*============================================*/ /* Determine the number of floats to be read. */ /*============================================*/ GenReadBinary(theEnv,&SymbolData(theEnv)->NumberOfFloats,(unsigned long) sizeof(long int)); if (SymbolData(theEnv)->NumberOfFloats == 0) { SymbolData(theEnv)->FloatArray = NULL; return; } /*===============================*/ /* Allocate area for the floats. */ /*===============================*/ floatValues = (double *) gm3(theEnv,(long) sizeof(double) * SymbolData(theEnv)->NumberOfFloats); GenReadBinary(theEnv,(void *) floatValues,(unsigned long) (sizeof(double) * SymbolData(theEnv)->NumberOfFloats)); /*======================================*/ /* Store the floats in the float array. */ /*======================================*/ SymbolData(theEnv)->FloatArray = (FLOAT_HN **) gm3(theEnv,(long) sizeof(FLOAT_HN *) * SymbolData(theEnv)->NumberOfFloats); for (i = 0; i < SymbolData(theEnv)->NumberOfFloats; i++) { SymbolData(theEnv)->FloatArray[i] = (FLOAT_HN *) EnvAddDouble(theEnv,floatValues[i]); } /*========================*/ /* Free the float buffer. */ /*========================*/ rm3(theEnv,(void *) floatValues,(long) (sizeof(double) * SymbolData(theEnv)->NumberOfFloats)); }
globle void InitializeDefrules( void *theEnv) { unsigned long i; AllocateEnvironmentData(theEnv,DEFRULE_DATA,sizeof(struct defruleData),DeallocateDefruleData); InitializeEngine(theEnv); InitializeAgenda(theEnv); InitializePatterns(theEnv); InitializeDefruleModules(theEnv); AddReservedPatternSymbol(theEnv,(char*)"and",NULL); AddReservedPatternSymbol(theEnv,(char*)"not",NULL); AddReservedPatternSymbol(theEnv,(char*)"or",NULL); AddReservedPatternSymbol(theEnv,(char*)"test",NULL); AddReservedPatternSymbol(theEnv,(char*)"logical",NULL); AddReservedPatternSymbol(theEnv,(char*)"exists",NULL); AddReservedPatternSymbol(theEnv,(char*)"forall",NULL); DefruleBasicCommands(theEnv); DefruleCommands(theEnv); DefruleData(theEnv)->DefruleConstruct = AddConstruct(theEnv,(char*)"defrule",(char*)"defrules", ParseDefrule,EnvFindDefrule, GetConstructNamePointer,GetConstructPPForm, GetConstructModuleItem,EnvGetNextDefrule,SetNextConstruct, EnvIsDefruleDeletable,EnvUndefrule,ReturnDefrule); DefruleData(theEnv)->AlphaMemoryTable = (ALPHA_MEMORY_HASH **) gm3(theEnv,sizeof (ALPHA_MEMORY_HASH *) * ALPHA_MEMORY_HASH_SIZE); for (i = 0; i < ALPHA_MEMORY_HASH_SIZE; i++) DefruleData(theEnv)->AlphaMemoryTable[i] = NULL; DefruleData(theEnv)->BetaMemoryResizingFlag = TRUE; DefruleData(theEnv)->RightPrimeJoins = NULL; DefruleData(theEnv)->LeftPrimeJoins = NULL; }
bool GameStep::step3() { srand(time(NULL)); int frame=0; sf::Music menuMusic; //logoMusic=new sf::Music("logo.wav"); menuMusic.openFromFile("music/part3.wav"); menuMusic.play(); menuMusic.setLoop(true); Gamestep3 gm3(*window); gm3.init(); while (window->isOpen() && !gm3.win && !gm3.lose) { stepEvent(); if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)){ if(!pauseMenu()){ return false; } } //Supprimer impérativement if (sf::Keyboard::isKeyPressed(sf::Keyboard::T)){ gm3.win=true; } gm3.update(); frame++; } if(!gm3.lose){ score+=7500-frame; if(score<0) score=0; } return true; }
static DATA_OBJECT_PTR GetSaveFactsDeftemplateNames( void *theEnv, struct expr *theList, int saveCode, int *count, int *error) { struct expr *tempList; DATA_OBJECT_PTR theDOArray; int i, tempCount; struct deftemplate *theDeftemplate = NULL; /*=============================*/ /* Initialize the error state. */ /*=============================*/ *error = FALSE; /*=====================================================*/ /* If no deftemplate names were specified as arguments */ /* then the deftemplate name list is empty. */ /*=====================================================*/ if (theList == NULL) { *count = 0; return(NULL); } /*======================================*/ /* Determine the number of deftemplate */ /* names to be stored in the name list. */ /*======================================*/ for (tempList = theList, *count = 0; tempList != NULL; tempList = tempList->nextArg, (*count)++) { /* Do Nothing */ } /*=========================================*/ /* Allocate the storage for the name list. */ /*=========================================*/ theDOArray = (DATA_OBJECT_PTR) gm3(theEnv,(long) sizeof(DATA_OBJECT) * *count); /*=====================================*/ /* Loop through each of the arguments. */ /*=====================================*/ for (tempList = theList, i = 0; i < *count; tempList = tempList->nextArg, i++) { /*========================*/ /* Evaluate the argument. */ /*========================*/ EvaluateExpression(theEnv,tempList,&theDOArray[i]); if (EvaluationData(theEnv)->EvaluationError) { *error = TRUE; rm3(theEnv,theDOArray,(long) sizeof(DATA_OBJECT) * *count); return(NULL); } /*======================================*/ /* A deftemplate name must be a symbol. */ /*======================================*/ if (theDOArray[i].type != SYMBOL) { *error = TRUE; ExpectedTypeError1(theEnv,(char*)"save-facts",3+i,(char*)"symbol"); rm3(theEnv,theDOArray,(long) sizeof(DATA_OBJECT) * *count); return(NULL); } /*===================================================*/ /* Find the deftemplate. For a local save, look only */ /* in the current module. For a visible save, look */ /* in all visible modules. */ /*===================================================*/ if (saveCode == LOCAL_SAVE) { theDeftemplate = (struct deftemplate *) EnvFindDeftemplate(theEnv,ValueToString(theDOArray[i].value)); if (theDeftemplate == NULL) { *error = TRUE; ExpectedTypeError1(theEnv,(char*)"save-facts",3+i,(char*)"local deftemplate name"); rm3(theEnv,theDOArray,(long) sizeof(DATA_OBJECT) * *count); return(NULL); } } else if (saveCode == VISIBLE_SAVE) { theDeftemplate = (struct deftemplate *) FindImportedConstruct(theEnv,(char*)"deftemplate",NULL, ValueToString(theDOArray[i].value), &tempCount,TRUE,NULL); if (theDeftemplate == NULL) { *error = TRUE; ExpectedTypeError1(theEnv,(char*)"save-facts",3+i,(char*)"visible deftemplate name"); rm3(theEnv,theDOArray,(long) sizeof(DATA_OBJECT) * *count); return(NULL); } } /*==================================*/ /* Add a pointer to the deftemplate */ /* to the array being created. */ /*==================================*/ theDOArray[i].type = DEFTEMPLATE_PTR; theDOArray[i].value = (void *) theDeftemplate; } /*===================================*/ /* Return the array of deftemplates. */ /*===================================*/ return(theDOArray); }
globle void StoreInMultifield( void *theEnv, DATA_OBJECT *returnValue, EXPRESSION *expptr, int garbageSegment) { DATA_OBJECT val_ptr; DATA_OBJECT *val_arr; struct multifield *theMultifield; struct multifield *orig_ptr; long start, end, i,j, k, argCount; unsigned long seg_size; argCount = CountArguments(expptr); /*=========================================*/ /* If no arguments are given return a NULL */ /* multifield of length zero. */ /*=========================================*/ if (argCount == 0) { SetpType(returnValue,MULTIFIELD); SetpDOBegin(returnValue,1); SetpDOEnd(returnValue,0); if (garbageSegment) theMultifield = (struct multifield *) EnvCreateMultifield(theEnv,0L); else theMultifield = (struct multifield *) CreateMultifield2(theEnv,0L); SetpValue(returnValue,(void *) theMultifield); return; } else { /*========================================*/ /* Get a new segment with length equal to */ /* the total length of all the arguments. */ /*========================================*/ val_arr = (DATA_OBJECT *) gm3(theEnv,(long) sizeof(DATA_OBJECT) * argCount); seg_size = 0; for (i = 1; i <= argCount; i++, expptr = expptr->nextArg) { EvaluateExpression(theEnv,expptr,&val_ptr); if (EvaluationData(theEnv)->EvaluationError) { SetpType(returnValue,MULTIFIELD); SetpDOBegin(returnValue,1); SetpDOEnd(returnValue,0); if (garbageSegment) { theMultifield = (struct multifield *) EnvCreateMultifield(theEnv,0L); } else theMultifield = (struct multifield *) CreateMultifield2(theEnv,0L); SetpValue(returnValue,(void *) theMultifield); rm3(theEnv,val_arr,(long) sizeof(DATA_OBJECT) * argCount); return; } SetpType(val_arr+i-1,GetType(val_ptr)); if (GetType(val_ptr) == MULTIFIELD) { SetpValue(val_arr+i-1,GetpValue(&val_ptr)); start = GetDOBegin(val_ptr); end = GetDOEnd(val_ptr); } else if (GetType(val_ptr) == RVOID) { SetpValue(val_arr+i-1,GetValue(val_ptr)); start = 1; end = 0; } else { SetpValue(val_arr+i-1,GetValue(val_ptr)); start = end = -1; } seg_size += (unsigned long) (end - start + 1); SetpDOBegin(val_arr+i-1,start); SetpDOEnd(val_arr+i-1,end); } if (garbageSegment) { theMultifield = (struct multifield *) EnvCreateMultifield(theEnv,seg_size); } else theMultifield = (struct multifield *) CreateMultifield2(theEnv,seg_size); /*========================================*/ /* Copy each argument into new segment. */ /*========================================*/ for (k = 0, j = 1; k < argCount; k++) { if (GetpType(val_arr+k) == MULTIFIELD) { start = GetpDOBegin(val_arr+k); end = GetpDOEnd(val_arr+k); orig_ptr = (struct multifield *) GetpValue(val_arr+k); for (i = start; i < end + 1; i++, j++) { SetMFType(theMultifield,j,(GetMFType(orig_ptr,i))); SetMFValue(theMultifield,j,(GetMFValue(orig_ptr,i))); } } else if (GetpType(val_arr+k) != RVOID) { SetMFType(theMultifield,j,(short) (GetpType(val_arr+k))); SetMFValue(theMultifield,j,(GetpValue(val_arr+k))); j++; } } /*=========================*/ /* Return the new segment. */ /*=========================*/ SetpType(returnValue,MULTIFIELD); SetpDOBegin(returnValue,1); SetpDOEnd(returnValue,(long) seg_size); SetpValue(returnValue,(void *) theMultifield); rm3(theEnv,val_arr,(long) sizeof(DATA_OBJECT) * argCount); return; } }
L::QRNSequence* L::Make::qrnNet (int n, const Hypercube &h, Index size) { /* * 1rtg Digital Sequences in Base 2 * ||| * ||\__ Generator Matrix 2 * || * |\___ 0 - Truncate * | 1 - Center * | 2 - Full * | * | 5 - Add equidistributed coordinate * | * \____ 0 - Index 0 * 1 - Index 1 * 2 - Index 2 * 3 - Index 16 * 4 - Index 100 * * 9 - Randomize */ if (n >= 1000 && n < 2000) { int nn = n; int gen = nn % 10; nn /= 10; GM2* gm; try { gm = generatorMatrix2 (gen, h.getDimension()); } catch (GeneratorMatrixDoesNotExist &) { throw QRNSequenceDoesNotExist (n); } if (nn % 5 >= 3) throw QRNSequenceDoesNotExist (n); DigitalNet::Truncation trunc = truncs [nn % 5]; nn /= 5; bool equi = nn % 2; nn /= 2; int index = nn % 10; nn /= 10; if (index > 4 && index < 9) throw QRNSequenceDoesNotExist (n); typedef DigitalNet2Gray<u64> DN2G; DN2G* dn = new DN2G (*gm, h, ms1(size), indices[index], equi, trunc); if (index == 9) dn->randomize(*mt); delete gm; return new QRNSequenceP<DN2G> (dn); } #if 0 /* * 2agg Digital Sequences in general base * | | * | \__ Generator Matrix Gen * | * \____ 0 - Naive * 1 - Normal * 2 - Gray-Code */ if (n >= 2000 && n < 3000) { int nn = n; int gen = nn % 100; nn /= 100; GMGen* gm; try { gm = generatorMatrixGen (gen); } catch (GeneratorMatrixDoesNotExist &) { throw QRNSequenceDoesNotExist (n); } int type = nn % 10; nn /= 10; if (type >= 3) throw QRNSequenceDoesNotExist (n); int base = gm->getBase(); QRNSequence* seq; typedef LookupField<unsigned char> Ring; LookupGaloisField<unsigned char> r (base); typedef DigitalNetGenNormal <Ring, Index> Normal; typedef DigitalNetGenNaive <Ring, Index> Naive; typedef DigitalNetGenGray <Ring, Index> Gray; typedef DigitalNetGenCyclicGray<Ring, Index> Cyclic; switch (type) { case 0: seq = new QRNSequenceP<Naive> (new Naive (*gm, r, h)); break; case 1: seq = new QRNSequenceP<Normal> (new Normal (*gm, r, h)); break; case 2: { if (Prime::test (base)) seq = new QRNSequenceP<Cyclic> (new Cyclic (*gm, r, h)); else seq = new QRNSequenceP<Gray> (new Gray (*gm, r, h)); break; } default: throw InternalError (__FILE__, __LINE__); } delete gm; return seq; } #endif /* * 2agg Digital Sequences in general base * | | * | \__ Generator Matrix Gen * | * \____ 1 - Fix one-dim projection * 2 - Fix two-dim projection */ if (n >= 2000 && n < 3000) { int nn = n; int gen = nn % 100; nn /= 100; GMGen* gm; try { gm = generatorMatrixGen (gen, h.getDimension()); } catch (GeneratorMatrixDoesNotExist &) { throw QRNSequenceDoesNotExist (n); } int base = gm->getBase(); int m = logInt (size, Index (base)); GMGen gm2 (AdjustM (m, AdjustPrec (m, *gm))); int fix = nn % 10; nn /= 10; if (fix > 2) throw QRNSequenceDoesNotExist (n); if (fix) { GeneratorMatrixGenRow<unsigned char> gm3 (gm2); if (fix == 1) fixOneDimensionalProjections (gm3); else fixTwoDimensionalProjections (gm3); assign (gm3, gm2); } QRNSequence* seq; typedef OneDimVectorSpace<LookupField<unsigned char> > VS; LookupGaloisField<unsigned char> r (base); VS vs (r); typedef DigitalNetGenGray <VS, Index> Gray; typedef DigitalNetGenCyclicGray<VS, Index> Cyclic; if (Prime::test (base)) seq = new QRNSequenceP<Cyclic> (new Cyclic (vs, gm2, h)); else seq = new QRNSequenceP<Gray> (new Gray (vs, gm2, h)); delete gm; return seq; } /* * 9xxx Special Cases * | * \____ 0 - Halton */ switch (n) { case 9000: return new QRNSequenceT<Halton> (h); default: throw QRNSequenceDoesNotExist (n); } }