// Randomize the initial layout of the cave. void CellularAutomata::RandomizeCave() { for (int y = 0; y < GetSizeY(); y++) for (int x = 0; x < GetSizeX(); x++) { if ((std::rand() % 101 < GetChanceToStayAlive())) { cave[y][x] = FLOOR; // } } }
float* FBoneDataVertexBuffer::LockData() { check(IsInRenderingThread() && GetSizeX() && IsValidRef(BoneBuffer)); check(!AllocSize && !AllocBlock); AllocSize = ComputeMemorySize(); AllocBlock = FMemory::Malloc(AllocSize + 15, 16); float* Data = (float*)AllocBlock; check(AllocSize && AllocBlock); check(Data); return Data; }
void ButtonPic::Draw(const Point2i &mousePosition) { Surface& surf = AppWarmux::GetInstance()->video->window; // center the image horizontally uint tmp_x = GetPositionX() + (GetSizeX() - m_img_normal.GetWidth())/2 ; uint tmp_y = GetPositionY(); surf.Blit(m_img_normal, Point2i(tmp_x, tmp_y)); if (Contains(mousePosition)) { surf.RectangleColor(*this, c_red, 1); txt_label->SetColor(black_color); } else { txt_label->SetColor(dark_gray_color); } txt_label->DrawCenterTop(GetPosition() + Point2i(GetSizeX()/2, GetSizeY() - txt_label->GetHeight())); }
void World::MakeExample() { for (int x = 0; x < GetSizeX(); x ++) { for ( int y = 0; y < GetSizeY(); y++) { if (x > 10 && x < 20 && y > 5 && y <25) { SetTile(x, y, tileManager->GetId("clay")); } else { SetTile(x, y, tileManager->GetId("grass")); } } } }
double Margolus::CalculationBlockEnergy(const Block& block, cuint& ix, cuint& iy) { double sumEnergy = 0.0; Cell cellIn, cellOut; //x gran 1 if (ix > 0) { cellIn = block.cells[0][1]; cellOut = cells[ix - 1][iy + 1][0]; PareEnergy(cellIn, cellOut, sumEnergy); cellIn = block.cells[0][0]; cellOut = cells[ix - 1][iy][0]; PareEnergy(cellIn, cellOut, sumEnergy); } //x gran 2 if (ix < GetSizeX() - 2) { cellIn = block.cells[1][1]; cellOut = cells[ix + 2][iy + 1][0]; PareEnergy(cellIn, cellOut, sumEnergy); cellIn = block.cells[1][0]; cellOut = cells[ix + 2][iy][0]; PareEnergy(cellIn, cellOut, sumEnergy); } //y gran 1 if (iy > 0) { cellIn = block.cells[1][0]; cellOut = cells[ix + 1][iy - 1][0]; PareEnergy(cellIn, cellOut, sumEnergy); cellIn = block.cells[0][0]; cellOut = cells[ix][iy - 1][0]; PareEnergy(cellIn, cellOut, sumEnergy); } //y gran 2 if (iy < GetSizeY() - 2) { cellIn = block.cells[1][1]; cellOut = cells[ix + 1][iy + 2][0]; PareEnergy(cellIn, cellOut, sumEnergy); cellIn = block.cells[0][1]; cellOut = cells[ix][iy + 2][0]; PareEnergy(cellIn, cellOut, sumEnergy); } //inside block for (uint i = 0; i < 4; ++i) { cellIn = block.cells[indexF[i][0]][indexF[i][1]]; cellOut = block.cells[indexF[i + 1][0]][indexF[i + 1][1]]; PareEnergyFull(cellIn, cellOut, sumEnergy); } if (!moveForward || block.move[movement] > 0) { sumEnergy += block.move[movement] * *steamEnergy_; } return sumEnergy; }
void CellularAutomata::LifeCycle() { FILETIME prevSysKernel, prevSysUser, prevProcKernel, prevProcUser; double usage = 0.0; MessyClass::GetInstance().Init(GetSizeX(), GetSizeY()); for (int i = 0; i < FileReader::GetInstance().FetchIntData(6); i++) // How many caves shall we generate? { ///////////////////////////////////////////// // Set all locations in the map to walls //// // This is just to remove junk-values. EmptyCave(); ///////////////////////////////////////////// // Randomize the initial map //////////////// RandomizeCave(); ///////////////////////////////////////////// // Generate the cave(s) ///////////////////// CPUUsage c; usage = c.GetCPUUsage(&prevSysKernel, &prevSysUser, &prevProcKernel, &prevProcUser, true); GenerateCave(); usage = c.GetCPUUsage(&prevSysKernel, &prevSysUser, &prevProcKernel, &prevProcUser); FileReader::GetInstance().WriteToFile(std::to_string(GetSizeX()) + "x" + std::to_string(GetSizeY()) + "_CPUUsage.txt", "", usage, 8); //PrintCave(); ///////////////////////////////////////////// // Save the cave(s) in seperate files /////// SaveCave(); // MessyClass::GetInstance().SaveImage(GetCavesGenerated(), GetCave()); CountFloorTiles(); system("CLS"); std::cout << "[ CAVE " << GetCavesGenerated() << " / " << GetCavesToGenerate() << " COMPLETED ]\n"; std::cout << "Floor tiles: " << GetFloorTiles() << " / " << GetSizeX() * GetSizeY() << "\n"; } CPUUsage c; c.FindUsage("Data/"+std::to_string(GetSizeX()) + "x" + std::to_string(GetSizeY()) + "_CPUUsage.txt", GetSizeX(), GetSizeY(), GetCavesToGenerate()); std::cout << "Generation completed!\n\nPress enter to exit program...\n"; }
void SampleImageDlg::EnableBasedOnConstraint() { GetTextToFile()->Enable(m_bToFile); GetDotDotDot()->Enable(m_bToFile); GetConstrain()->Enable(true); GetSmaller()->Enable(m_bConstraint); GetBigger()->Enable(m_bConstraint); GetSizeX()->SetEditable(!m_bConstraint); GetSizeY()->SetEditable(!m_bConstraint); GetSpacingX()->SetEditable(!m_bConstraint); GetSpacingY()->SetEditable(!m_bConstraint); }
void SampleImageDlg::OnSpacingXY( wxCommandEvent &event ) { if (m_bSetting) return; TransferDataFromWindow(); m_Size.x = (int) (m_fAreaX / m_fSpacingX); m_Size.y = (int) (m_fAreaY / m_fSpacingY); m_bSetting = true; GetSizeX()->GetValidator()->TransferToWindow(); GetSizeY()->GetValidator()->TransferToWindow(); m_bSetting = false; }
/* ___________________________________ | | | | | (x-1,y-1) | ( x, y-1) | (x+1,y-1) | |___________|___________|___________| | | | | | (x-1, y ) | (x, y ) | (x+1, y ) | |___________|___________|___________| | | | | | (x-1,y+1) | ( x, y+1) | (x+1,y+1) | |___________|___________|___________| */ int CellularAutomata::CountLivingNeighbours(int x, int y) { int numOfLivingNeighbours = 0; for (int i = -1; i < 2; i++) for (int j = -1; j < 2; j++) { int XNeighbour = x + j; int YNeighbour = y + i; if (i == 0 && j == 0); // We need to avoid looking on the current tile! else if (XNeighbour < 0 || YNeighbour < 0 || XNeighbour >= GetSizeX() || YNeighbour >= GetSizeY()) numOfLivingNeighbours++; else if (cave[YNeighbour][XNeighbour] == FLOOR) // numOfLivingNeighbours++; } return numOfLivingNeighbours; }
//gets the ref of a specific cell from a given position out of the region_array const CCellTypeWorld& CDungeon::GetCell(const C2DPosition<>& pos) const { C2DPosition<> region = pos / C2DPosition<>(CRegion::GetSizeX(),CRegion::GetSizeY()); //int regionX = pos[0] / CRegion::GetSizeX(); //int regionY = pos[1] / CRegion::GetSizeY(); const CCellTypeWorld* ret = 0; if (pos[0] >= 0 && GetSizeX() > pos[0] && pos[1] >= 0 && GetSizeY() > pos[1] && region[0] >= 0 && region[0] < AMOUNT_REGION_X && region[1] >= 0 && region[1] < AMOUNT_REGION_Y) ret = _regions[region[0]][region[1]].GetCell(pos); if (!ret) ret = _standardCellType; return *ret; }
void PasswordBox::BasicSetText(std::string const & new_txt) { std::string _new_txt = new_txt; if (max_nb_chars != 0 && _new_txt.size() > max_nb_chars) { _new_txt.resize(max_nb_chars); } clear_text = _new_txt; //printf("Real text: %s\n", clear_text.c_str()); Font * font = Font::GetInstance(GetFontSize(), GetFontStyle()); if (font->GetWidth(_new_txt) < GetSizeX() - 5) { Label::SetText(std::string(clear_text.size(), '*')); } else { cursor_pos = GetText().size(); } }
void cBlockArea::CropNibbles(NIBBLEARRAY & a_Array, int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ) { int NewSizeX = GetSizeX() - a_AddMinX - a_SubMaxX; int NewSizeY = GetSizeY() - a_AddMinY - a_SubMaxY; int NewSizeZ = GetSizeZ() - a_AddMinZ - a_SubMaxZ; NIBBLETYPE * NewNibbles = new NIBBLETYPE[NewSizeX * NewSizeY * NewSizeZ]; int idx = 0; for (int y = 0; y < NewSizeY; y++) { for (int z = 0; z < NewSizeZ; z++) { for (int x = 0; x < NewSizeX; x++) { NewNibbles[idx++] = a_Array[MakeIndex(x + a_AddMinX, y + a_AddMinY, z + a_AddMinZ)]; } // for x } // for z } // for y delete a_Array; a_Array = NewNibbles; }
void cBlockArea::CropBlockTypes(int a_AddMinX, int a_SubMaxX, int a_AddMinY, int a_SubMaxY, int a_AddMinZ, int a_SubMaxZ) { int NewSizeX = GetSizeX() - a_AddMinX - a_SubMaxX; int NewSizeY = GetSizeY() - a_AddMinY - a_SubMaxY; int NewSizeZ = GetSizeZ() - a_AddMinZ - a_SubMaxZ; BLOCKTYPE * NewBlockTypes = new BLOCKTYPE[NewSizeX * NewSizeY * NewSizeZ]; int idx = 0; for (int y = 0; y < NewSizeY; y++) { for (int z = 0; z < NewSizeZ; z++) { for (int x = 0; x < NewSizeX; x++) { int OldIndex = MakeIndex(x + a_AddMinX, y + a_AddMinY, z + a_AddMinZ); NewBlockTypes[idx++] = m_BlockTypes[OldIndex]; } // for x } // for z } // for y delete m_BlockTypes; m_BlockTypes = NewBlockTypes; }
uint32 UTextureCube::CalcTextureMemorySize( int32 MipCount ) const { uint32 Size = 0; if (PlatformData) { int32 SizeX = GetSizeX(); int32 SizeY = GetSizeY(); int32 NumMips = GetNumMips(); EPixelFormat Format = GetPixelFormat(); ensureMsgf(SizeX == SizeY, TEXT("Cubemap faces expected to be square. Actual sizes are: %i, %i"), SizeX, SizeY); // Figure out what the first mip to use is. int32 FirstMip = FMath::Max( 0, NumMips - MipCount ); FIntPoint MipExtents = CalcMipMapExtent(SizeX, SizeY, Format, FirstMip); uint32 TextureAlign = 0; uint64 TextureSize = RHICalcTextureCubePlatformSize(MipExtents.X, Format, NumMips, 0, TextureAlign); Size = (uint32)TextureSize; } return Size; }
// Describes how to set the sizes of all the buffers static void SetSizes(Arguments<T> &args) { args.a_size = GetSizeA(args); args.x_size = GetSizeX(args); args.y_size = GetSizeY(args); }
void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas) { // Block types are compulsory, block metas are voluntary if (!HasBlockTypes() || !a_Src.HasBlockTypes()) { LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__); return; } // Dst is *this, Src is a_Src int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy switch (a_Strategy) { case cBlockArea::msOverwrite: { InternalMergeBlocks<MetasValid, MergeCombinatorOverwrite<MetasValid> >( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); return; } // case msOverwrite case cBlockArea::msFillAir: { InternalMergeBlocks<MetasValid, MergeCombinatorFillAir<MetasValid> >( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); return; } // case msFillAir case cBlockArea::msImprint: { InternalMergeBlocks<MetasValid, MergeCombinatorImprint<MetasValid> >( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); return; } // case msImprint case cBlockArea::msLake: { InternalMergeBlocks<MetasValid, MergeCombinatorLake<MetasValid> >( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); return; } // case msLake case cBlockArea::msSpongePrint: { InternalMergeBlocks<MetasValid, MergeCombinatorSpongePrint<MetasValid> >( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); return; } // case msSpongePrint case cBlockArea::msDifference: { InternalMergeBlocks<MetasValid, MergeCombinatorDifference<MetasValid> >( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); return; } // case msDifference case cBlockArea::msMask: { InternalMergeBlocks<MetasValid, MergeCombinatorMask<MetasValid> >( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_Size.x, m_Size.y, m_Size.z ); return; } // case msMask } // switch (a_Strategy) LOGWARNING("Unknown block area merge strategy: %d", a_Strategy); ASSERT(!"Unknown block area merge strategy"); return; }
void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy) { // Block types are compulsory, block metas are voluntary if (!HasBlockTypes() || !a_Src.HasBlockTypes()) { LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__); return; } // Dst is *this, Src is a_Src int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas(); NIBBLETYPE * DstMetas = m_BlockMetas; bool IsDummyMetas = ((SrcMetas == NULL) || (DstMetas == NULL)); if (IsDummyMetas) { SrcMetas = new NIBBLETYPE[a_Src.GetBlockCount()]; DstMetas = new NIBBLETYPE[GetBlockCount()]; } switch (a_Strategy) { case msOverwrite: { InternalMergeBlocks( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_SizeX, m_SizeY, m_SizeZ, MergeCombinatorOverwrite ); break; } // case msOverwrite case msFillAir: { InternalMergeBlocks( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_SizeX, m_SizeY, m_SizeZ, MergeCombinatorFillAir ); break; } // case msFillAir case msImprint: { InternalMergeBlocks( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_SizeX, m_SizeY, m_SizeZ, MergeCombinatorImprint ); break; } // case msImprint case msLake: { InternalMergeBlocks( m_BlockTypes, a_Src.GetBlockTypes(), DstMetas, SrcMetas, SizeX, SizeY, SizeZ, SrcOffX, SrcOffY, SrcOffZ, DstOffX, DstOffY, DstOffZ, a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(), m_SizeX, m_SizeY, m_SizeZ, MergeCombinatorLake ); break; } // case msLake default: { LOGWARNING("Unknown block area merge strategy: %d", a_Strategy); ASSERT(!"Unknown block area merge strategy"); break; } } // switch (a_Strategy) if (IsDummyMetas) { delete[] SrcMetas; delete[] DstMetas; } }
// Describes how to set the sizes of all the buffers static void SetSizes(Arguments<T> &args, Queue&) { args.x_size = GetSizeX(args); }
void FShadowMapPendingTexture::StartEncoding(UWorld* InWorld) { // Create the shadow-map texture. UShadowMapTexture2D* Texture = new(Outer) UShadowMapTexture2D(FPostConstructInitializeProperties()); Texture->Filter = GUseBilinearLightmaps ? TF_Default : TF_Nearest; // Signed distance field textures get stored in linear space, since they need more precision near .5. Texture->SRGB = false; Texture->LODGroup = TEXTUREGROUP_Shadowmap; Texture->ShadowmapFlags = ShadowmapFlags; Texture->Source.Init2DWithMipChain(GetSizeX(), GetSizeY(), TSF_BGRA8); Texture->MipGenSettings = TMGS_LeaveExistingMips; Texture->CompressionNone = true; int32 TextureSizeX = Texture->Source.GetSizeX(); int32 TextureSizeY = Texture->Source.GetSizeY(); { // Create the uncompressed top mip-level. TArray< TArray<FFourDistanceFieldSamples> > MipData; FShadowMap2D::EncodeSingleTexture(*this, Texture, MipData); // Copy the mip-map data into the UShadowMapTexture2D's mip-map array. for(int32 MipIndex = 0;MipIndex < MipData.Num();MipIndex++) { FColor* DestMipData = (FColor*)Texture->Source.LockMip(MipIndex); uint32 MipSizeX = FMath::Max(1,TextureSizeX >> MipIndex); uint32 MipSizeY = FMath::Max(1,TextureSizeY >> MipIndex); for(uint32 Y = 0;Y < MipSizeY;Y++) { for(uint32 X = 0;X < MipSizeX;X++) { const FFourDistanceFieldSamples& SourceSample = MipData[MipIndex][Y * MipSizeX + X]; DestMipData[ Y * MipSizeX + X ] = FColor(SourceSample.Samples[0].Distance, SourceSample.Samples[1].Distance, SourceSample.Samples[2].Distance, SourceSample.Samples[3].Distance); } } Texture->Source.UnlockMip(MipIndex); } } // Update stats. int32 TextureSize = Texture->CalcTextureMemorySizeEnum( TMC_AllMips ); GNumShadowmapTotalTexels += TextureSizeX * TextureSizeY; GNumShadowmapTextures++; GShadowmapTotalSize += TextureSize; GShadowmapTotalStreamingSize += (ShadowmapFlags & SMF_Streamed) ? TextureSize : 0; UPackage* TexturePackage = Texture->GetOutermost(); for ( int32 LevelIndex=0; TexturePackage && LevelIndex < InWorld->GetNumLevels(); LevelIndex++ ) { ULevel* Level = InWorld->GetLevel(LevelIndex); UPackage* LevelPackage = Level->GetOutermost(); if ( TexturePackage == LevelPackage ) { Level->ShadowmapTotalSize += float(TextureSize) / 1024.0f; break; } } // Update the texture resource. Texture->BeginCachePlatformData(); Texture->FinishCachePlatformData(); Texture->UpdateResource(); }
// Describes how to set the sizes of all the buffers static void SetSizes(Arguments<T> &args) { args.x_size = GetSizeX(args); args.y_size = GetSizeY(args); args.scalar_size = GetSizeDot(args); }
const C2DPosition<> CDungeon::GetSize() { return C2DPosition<>(GetSizeX(), GetSizeY()); }
// Describes how to set the sizes of all the buffers static void SetSizes(Arguments<T> &args) { args.x_size = GetSizeX(args); args.scalar_size = GetSizeAsum(args); }
void Margolus::Calculation(cuint& dx, cuint& dy, cuint& dz) { //#pragma omp parallel for for (uint ix = dx; ix < GetSizeX() - 1; ix += 2) { for (uint iy = dy; iy < GetSizeY() - 1; iy += 2) { for (uint iz = dz; iz < GetSizeZ() - 1; iz += 2) { if (CheckEmpty(ix, iy, iz)) { continue; } blockSize3D = 1; CreateRotateNotBlock3D(blocks3D[0], ix, iy, iz); if (modifierMove && CheckMod(ix, iy, iz)) { if (CheckActive (ix, iy)) { if (CheckCanRotate3D(ClockWiceX, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceX, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceX, ix, iy, iz, true, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceX, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(CounterClockWiceX, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceX, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceX, ix, iy, iz, true, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceX, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(ClockWiceY, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceY, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceY, ix, iy, iz, true, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceY, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(CounterClockWiceY, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceY, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceY, ix, iy, iz, true, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceY, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(ClockWiceZ, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceZ, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceZ, ix, iy, iz, true, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceZ, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(CounterClockWiceZ, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceZ, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceZ, ix, iy, iz, true, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceZ, ix, iy, iz); ++blockSize3D; } } else { CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceX, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceX, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceY, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceY, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceZ, ix, iy, iz, false, true); ++blockSize3D; CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceZ, ix, iy, iz, false, true); ++blockSize3D; } } else { if (CheckCanRotate3D(ClockWiceX, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceX, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(CounterClockWiceX, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceX, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(ClockWiceY, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceY, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(CounterClockWiceY, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceY, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(ClockWiceZ, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], ClockWiceZ, ix, iy, iz); ++blockSize3D; } if (CheckCanRotate3D(CounterClockWiceZ, ix, iy, iz)) { CreateRotateBlock3D(blocks3D[blockSize3D], CounterClockWiceZ, ix, iy, iz); ++blockSize3D; } } double Z = 0.0; // + Energy for (uint i = 0; i < blockSize3D; ++i) { double energy = CalculationBlockEnergy(blocks3D[i], ix, iy, iz); //кДж/моль blocks3D[i].energy = exp(-energy / (R * *T)); Z += blocks3D[i].energy; } //normalization double sumProbability = 0.0; double rnd = (double)(rand()) / RAND_MAX; for (uint i = 0; i < blockSize3D; ++i) { sumProbability += blocks3D[i].energy / Z; if (rnd <= sumProbability) { ChangeBlock(blocks3D[i], ix, iy, iz); break; } } } } } }
// Save the cave in a textfile. void CellularAutomata::SaveCave() { FrameCave(); SetCavesGenerated(GetCavesGenerated() + 1); FileReader::GetInstance().WriteToFile(cave, GetCavesGenerated(), GetSizeY(), GetSizeX(), GetTimeToGenerate()); }
// Describes how to set the sizes of all the buffers static void SetSizes(Arguments<U> &args) { args.ap_size = GetSizeAP(args); args.x_size = GetSizeX(args); }