I had Mid Term project for 3d modeling course in the University. And I chose this building. Because I thought making stairs and waterwheel would be exciting and colors in the buildings were beautiful.



First, I made objects which I thought is easy to make. And I asked advices for stairs to my professor. And he made basic structure of stair part, and I added several, small, long cubes to the part.


So I made this stair structure.

My first building modeling. Every objects are made from simple cube. I used connect, inset, extrude, chamfer function.




Top of the window on the roof is used chamfer function to be curved. And bars in the window are made of long cubes rotated.



This window is also made from a cube. I used tesselate function to make small windows on top half on big cube.



I made this part with big cube. Actually I don't remember exactly how I made this, but maybe I deleted two faces of it and extrude top part


I made big house on the left first, and duplicated it then rotated it. And edited front face, and made other objects like windows, pillars, and etc

I finally finished making 3 by 3 matrix which have 1 ~ 9 numbers in it.

These are results. There is no repeated number but 1 ~ 9 numbers with random arrangement







And this is the code

////////////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <random>


using namespace std;


int num[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int arrNum[9];

int arr[3][3];


void createSudoku();
void printSudoku();
void bubbleSortArr();
void swap(double* a, double* b);
void printArrNum();
bool IsSame();


void main()
{
 createSudoku();
 printSudoku();
}


void createSudoku()
{
 while (1)
 {
  random_device rd;
  mt19937_64 rng(rd());

  uniform_int_distribution<__int64> dist1(1, 9);
  int k = 0;

  for (int i = 0; i < 3; i++)
  {
   for (int j = 0; j < 3; j++)
   {
    arr[i][j] = dist1(rng);
    arrNum[k] = arr[i][j];
    k++;
   }
  }
  bubbleSortArr();
  if (IsSame())
  {
   break;
  }
 }
}

void printSudoku()
{
 for (int i = 0; i < 3; i++)
 {
  for (int j = 0; j < 3; j++)
  {
   cout << arr[i][j] << " ";
  }
  cout << endl;
 }
}

void printArrNum()
{
 for (int i = 0; i < 9; i++)
 {
  cout << arrNum[i] << " ";
 }
}

void bubbleSortArr()
{
 for (int j = 0; j < 9; j++)
 {
  for (int k = 0; k < 9 - j - 1; k++)
  {
   if (arrNum[k] > arrNum[k + 1])
    swap(arrNum[k], arrNum[k + 1]);
  }
 }
}

void swap(double* a, double* b)
{
 double * temp;
 temp = a;
 a = b;
 b = temp;
}

//day1
bool IsSame()
{
 bool same = true;

  for (int i = 0; i < sizeof(num) / sizeof(int); i++)
  {
   if (num[i] != arrNum[i])
    same = false;
  } 

 return same;
}

////////////////////////////////////////////////////////////////////////////////////


Now, I will extend this to 9 by 9 Sudoku matrix

'공부(Study)' 카테고리의 다른 글

First Win32 Project  (0) 2017.02.15
Start studying MFC  (0) 2017.02.15
Sudoku Game with C++ - day 3  (0) 2016.07.21
Sudoku Game with C++ - day1  (0) 2016.07.06
Java Study - day1  (0) 2016.07.06

+ Recent posts