1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef __TILE_H_
#define __TILE_H_
 
#include <iostream>
 
class Tile {
private:
    bool enterable;
    Tile* up;
    Tile* down;
    Tile* left;
    Tile* right;
    bool dfsVisited;
    char ch;            //test
 
public:
    Tile(char ch = '#'
        :enterable(false),
        up(nullptr), down(nullptr), 
        left(nullptr), right(nullptr),
        dfsVisited(false),
        ch(ch)            //test
    { ; }
    
 
    // 출입불가 and 자신으로의 모든 참조(up,left...)를 nullptr로 만들기.
    void isolate() {
        enterable = false;                ch = '#';//test
        if (up)        { up->setDown(nullptr);        up = nullptr; }        //어쩌면 뒤쪽은 필요 없을수도...
        if (down)    { down->setUp(nullptr);        down = nullptr; }
        if (left)    { left->setRight(nullptr);    left = nullptr; }
        if (right)    { right->setLeft(nullptr);    right = nullptr; }
    }
 
 
    ///get, set///
    void setEnterable(bool ent) { this->enterable = ent; }
    void setUp(Tile* tile)        { this->up = tile; }
    void setDown(Tile* tile)    { this->down = tile; }
    void setLeft(Tile* tile)    { this->left = tile; }
    void setRight(Tile* tile)    { this->right = tile; }
    void setDfsVisited(bool visited) { this->dfsVisited = visited; }
    void setCh(char ch) { this->ch = ch; }
    
    bool getEnterable() const { return enterable; }
    Tile* getUp()    { return up; }
    Tile* getDown() { return down; }
    Tile* getLeft() { return left; }
    Tile* getRight(){ return right; }
    bool getDfsVisited() const { return dfsVisited; }
    char getCh() { return ch; }
};
 
#endif
cs



여러가지로 실험하면서 해본 거라서 딱 미로 관련된 것만 있는 것도 아니고


싱글톤도 실험하고 

미로 사이를 포인터로 이을지 
아니면 한단계 위에서 격자형으로만 만들지도 제대로 안 정하고 막 한 거

특히 Tile 객체 여러개를 가지고 있는 Maze를 클래스로 뽑아내지도 않았음 귀찮아서...