forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
genWalls.cpp
1 #include "stdinc.h"
2 
12 int main(int argc, char* argv[]) {
13  int n, seed; double pLeft, pTop, pBoth;
14  if (argc != 6 ||
15  sscanf(argv[1],"%d",&n) != 1 ||
16  sscanf(argv[2],"%lf",&pLeft) != 1 ||
17  sscanf(argv[3],"%lf",&pTop) != 1 ||
18  sscanf(argv[4],"%lf",&pBoth) != 1 ||
19  sscanf(argv[5],"%d",&seed) != 1)
20  fatal("usage: genWalls n pLeft pTop pBoth seed");
21 
22  srand(seed);
23  for (int i = 0; i < n; i++) {
24  for (int j = 0; j < n; j++) {
25  double p = randfrac();
26  char c;
27  if (p < pLeft) c = '|';
28  else if (p < pLeft+pTop) c = '-';
29  else if (p < pLeft+pTop+pBoth) c = '+';
30  else c = ' ';
31  cout << c;
32  }
33  cout << endl;
34  }
35 }