Percolation/Bond percolation: Difference between revisions
Content added Content deleted
(C++ version) |
(C++ version enhanced) |
||
Line 166: | Line 166: | ||
#include <iostream> |
#include <iostream> |
||
#include <string> |
#include <string> |
||
// cell states: |
|||
enum { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
}; |
|||
using namespace std; |
using namespace std; |
||
Line 186: | Line 179: | ||
cells = start + m; |
cells = start + m; |
||
for (auto i = 0u; i < m; i++) |
for (auto i = 0u; i < m; i++) |
||
start[i] = |
start[i] = RBWALL; |
||
end = cells; |
end = cells; |
||
Line 231: | Line 224: | ||
private: |
private: |
||
enum cell_state { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
RBWALL = RWALL | BWALL // right/bottom wall |
|||
}; |
|||
typedef unsigned int cell; |
typedef unsigned int cell; |
||
Line 239: | Line 239: | ||
return (!(p[0] & BWALL) && fill(p + m)) || (!(p[0] & RWALL) && fill(p + 1)) || |
return (!(p[0] & BWALL) && fill(p + m)) || (!(p[0] & RWALL) && fill(p + 1)) || |
||
(!(p[-1] & RWALL) && fill(p - 1)) || (!(p[0 - m] & BWALL) && fill(p - m)); |
|||
} |
} |
||