draw 함수부터 이어서



void draw(char piece, int numberOfRules, char *rule, char **ruleDes, double turningRadian, int depth, int currentDepth, state *currentState, stack *stk, bmpfile_t *bmpFile) {
        
        //safety
        if (depth < currentDepth)
                return;
        if (currentDepth != depth) {
                int i;
                for (i = 0; i < numberOfRules; i++) {
                        if (*(rule + i) == piece) {
                                int p;
                                for (p = 0; p < strlen(*(ruleDes + i)); p++) {
//                                printf(\"depth : %d rate:%lf\\n\", currentDepth, currentState->rate);
        
                                        draw(ruleDes[i][p], numberOfRules, rule, ruleDes, turningRadian, depth, (currentDepth + 1), currentState, stk, bmpFile);
                                }
                                return;
                        }
                }
        }
        if (piece == \'F\') { 
                double t;
                for (t = 0; t < currentState->rate; t += 1) {
                        bmp_set_pixel(bmpFile, currentState->x + t, currentState->heading * (currentState->x + t), pixelW);
                }
                (currentState->x) += currentState->rate * cos(currentState->heading);
                (currentState->y) += currentState->rate * sin(currentState->heading);
        } else if (piece == \'f\') {
                (currentState->x) += currentState->rate * cos(currentState->heading);
                (currentState->y) += currentState->rate * sin(currentState->heading);
        } else if (piece == \'+\') {
                (currentState->heading) += turningRadian;
        } else if (piece == \'-\') {
                (currentState->heading) -= turningRadian;
        } else if (piece == \'[\') {
                push(stk, currentState);
//                printf(\"pushcurrent : %lf, %lf, %lf\\n\", currentState->x, currentState->y, currentState->rate);
        } else if (piece == \']\') {
                currentState = pop(stk);
//                printf(\"popcurrent : %lf, %lf, %lf\\n\", currentState->x, currentState->y, currentState->rate);
        }
        
        
}


대략 설명하자면 프랙탈 이미지 있잖아?

그걸 bmpfile로 뽑아내야되는건데

문자열을 주고 그 문자열에 대한 규칙을 주면 그걸 가지고 만드는거야...

인풋은 도스창이나 터미널에서 < input.txt 이런식으로 STDIN으로 받거든...

그 파일이 대략
2    <-그림 갯수

10   <-규칙 적용 횟수
20.0 <- \'+\' 나 \'-\'가 나왔을때 회전각도
-90.0  <- 초기 진행각도
VZFFF <최초 문자열
5 <- 규칙 갯수
V -> [+++W][---W]YV
W -> +X[-W]Z
X -> -W[+X]Z
Y -> YZ
Z -> [-FFF][+FFF]F  <-규칙갯수

8   <-다시 규칙 적용 횟수....
30.0
-90.0
X
2
F -> FF
X -> F[+X]F[-X]+X


이런식이고, 코드는 아직 미완인데

이미지 생성한다음 하나로 합치는부분만 안해놨어...


문제 되는 부분은 evaluate랑, draw 함수인데

진짜 왜 안되는지도 모르겠고

뭐가 문제인지도 모르겠어...

두 함수 다 문자열에서 char하나씩 받아와서, 규칙 적용횟수 넘었나 체크하고
상응하는 규칙 있나 찾아서 적용하는 함수인데...

프갤 능력자형들, 컴과 1학년 좆뉴비좀 도와줘...

뭔지 대충 알것같은 형들은..힌트만 줘도 감사하게 받을게...

소스코드 내가쓴건 정리도 안해놔서 엄청 지저분하네
디버깅 할때 쓴 프린트문도 여기저기 널려있고..미안

여튼...굽신굽신...