// File: arisKoutsou[P]oopproj/./src/game_utils.cpp
// Function: generateMap()
void generateMap() {
  cout << endl;
  cout << "A Map/Grid is a 2d array of Tiles." << endl;
  cout << "with <rows> rows and <cols> columns." << endl;
  cout << "Each Tile can have a probability to have a Market (m)." << endl;
  cout << "A probability to be non Accessible (x)." << endl;
  cout << "And a probabilty to be common (c)." << endl;
  cout << "Probability is a number in the interval [0, 1]." << endl;
  cout << "Please enter dimensions and probabilities in the following order:" << endl;
  cout << "<rows> <cols> <m> <x> <c>\t\t(i.e : 4  5  0.1  0.3  0.03 )" << endl;
  cout << endl;
  cout << "> ";

  int rows, columns;
  double pMarket, pNonAccessible, pCommon;
  cin >> rows >> columns
      >> pMarket >> pNonAccessible >> pCommon;

  Random rng;
  ofstream newMap("input/map.txt");
  newMap << "# Map goes as follows: Each line has information about a tile" << endl
	 << "# First value (true|false) is about nonAccessible" << endl
	 << "# Second value (true|false) is about common" << endl
	 << "# Third value (true|false) is about market. If it's true "
	 << "then an in is given which is the capacity of the market" << endl
	 << "# First line has the dimensions of the grid (row, col)" << endl
	 << "# The delimiter is ','" << endl << endl;
  newMap << rows << "," << columns << "," << endl << endl;
  newMap << "false,false,false," << endl; /* That's the first tile. That's where our heroes spawn */
  for (size_t i = 2U; i != rows*columns*2; i += 2) {
    bool non_accessible = rng.boolean(pNonAccessible);
    bool common = rng.boolean(pCommon);
    bool market = rng.boolean(pMarket);
    if (non_accessible) {
      newMap << "true,";
      common = false;
      market = false;
    } else newMap << "false,";
    if (common) {
      newMap << "true,";
      market = false;
    } else newMap << "false,";
    if (market) {
      newMap << "true,";
      int cap = rng.fromMintoMax(5, 15);
      newMap << cap << ",";
    } else newMap << "false,";
    newMap << endl;
  }
  newMap.close();

  cout << endl << "Map generated !" << endl;

  string answer;
  while (answer != "Y" && answer != "y") {
    cout << endl << "Exit to Main Menu?(Y/n) : ";
    cin >> answer;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq 0x3372e(%rip), %rdi     # 0x3ffc0
movq %rdi, -0x280(%rbp)
movq 0x33700(%rip), %rsi     # 0x3ffa0
movq %rsi, -0x288(%rbp)
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21b7e(%rip), %rsi     # 0x2e438
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21b7f(%rip), %rsi     # 0x2e45b
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21b82(%rip), %rsi     # 0x2e480
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21b97(%rip), %rsi     # 0x2e4b7
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21b9d(%rip), %rsi     # 0x2e4df
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21b9e(%rip), %rsi     # 0x2e502
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21bac(%rip), %rsi     # 0x2e532
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x21bcc(%rip), %rsi     # 0x2e574
callq 0x52f0
movq -0x288(%rbp), %rsi
movq %rax, %rdi
callq 0x5330
movq -0x288(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0x5330
movq -0x280(%rbp), %rdi
leaq 0x2165f(%rip), %rsi     # 0x2e03c
callq 0x52f0
movq 0x335ef(%rip), %rdi     # 0x3ffd8
leaq -0x4(%rbp), %rsi
callq 0x51b0
movq %rax, %rdi
leaq -0x8(%rbp), %rsi
callq 0x51b0
movq %rax, %rdi
leaq -0x10(%rbp), %rsi
callq 0x5260
movq %rax, %rdi
leaq -0x18(%rbp), %rsi
callq 0x5260
movq %rax, %rdi
leaq -0x20(%rbp), %rsi
callq 0x5260
leaq -0x21(%rbp), %rdi
xorl %esi, %esi
callq 0x5f80
leaq 0x21b79(%rip), %rsi     # 0x2e5ad
leaq -0x228(%rbp), %rdi
movq %rdi, -0x278(%rbp)
movl $0x10, %edx
callq 0x5360
movq -0x278(%rbp), %rdi
leaq 0x21b61(%rip), %rsi     # 0x2e5bb
callq 0x52f0
movq %rax, -0x270(%rbp)
jmp 0xca68
movq -0x270(%rbp), %rdi
movq 0x3352a(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x290(%rbp)
jmp 0xca84
movq -0x290(%rbp), %rdi
leaq 0x21b67(%rip), %rsi     # 0x2e5f9
callq 0x52f0
movq %rax, -0x298(%rbp)
jmp 0xcaa0
movq -0x298(%rbp), %rdi
movq 0x334f2(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x2a0(%rbp)
jmp 0xcabc
movq -0x2a0(%rbp), %rdi
leaq 0x21b61(%rip), %rsi     # 0x2e62b
callq 0x52f0
movq %rax, -0x2a8(%rbp)
jmp 0xcad8
movq -0x2a8(%rbp), %rdi
movq 0x334ba(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x2b0(%rbp)
jmp 0xcaf4
movq -0x2b0(%rbp), %rdi
leaq 0x21b55(%rip), %rsi     # 0x2e657
callq 0x52f0
movq %rax, -0x2b8(%rbp)
jmp 0xcb10
movq -0x2b8(%rbp), %rdi
leaq 0x21b73(%rip), %rsi     # 0x2e691
callq 0x52f0
movq %rax, -0x2c0(%rbp)
jmp 0xcb2c
movq -0x2c0(%rbp), %rdi
movq 0x33466(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x2c8(%rbp)
jmp 0xcb48
movq -0x2c8(%rbp), %rdi
leaq 0x21b73(%rip), %rsi     # 0x2e6c9
callq 0x52f0
movq %rax, -0x2d0(%rbp)
jmp 0xcb64
movq -0x2d0(%rbp), %rdi
movq 0x3342e(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x2d8(%rbp)
jmp 0xcb80
movq -0x2d8(%rbp), %rdi
leaq 0x21b72(%rip), %rsi     # 0x2e700
callq 0x52f0
movq %rax, -0x2e0(%rbp)
jmp 0xcb9c
movq -0x2e0(%rbp), %rdi
movq 0x333f6(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x2e8(%rbp)
jmp 0xcbb8
movq -0x2e8(%rbp), %rdi
movq 0x333da(%rip), %rsi     # 0x3ffa0
callq 0x5330
jmp 0xcbcd
movl -0x4(%rbp), %esi
leaq -0x228(%rbp), %rdi
callq 0x5540
movq %rax, -0x2f0(%rbp)
jmp 0xcbe5
movq -0x2f0(%rbp), %rdi
leaq 0x21b35(%rip), %rsi     # 0x2e728
callq 0x52f0
movq %rax, -0x2f8(%rbp)
jmp 0xcc01
movq -0x2f8(%rbp), %rdi
movl -0x8(%rbp), %esi
callq 0x5540
movq %rax, -0x300(%rbp)
jmp 0xcc19
movq -0x300(%rbp), %rdi
leaq 0x21b01(%rip), %rsi     # 0x2e728
callq 0x52f0
movq %rax, -0x308(%rbp)
jmp 0xcc35
movq -0x308(%rbp), %rdi
movq 0x3335d(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x310(%rbp)
jmp 0xcc51
movq -0x310(%rbp), %rdi
movq 0x33341(%rip), %rsi     # 0x3ffa0
callq 0x5330
jmp 0xcc66
leaq 0x21aaa(%rip), %rsi     # 0x2e717
leaq -0x228(%rbp), %rdi
callq 0x52f0
movq %rax, -0x318(%rbp)
jmp 0xcc82
movq -0x318(%rbp), %rdi
movq 0x33310(%rip), %rsi     # 0x3ffa0
callq 0x5330
jmp 0xcc97
movq $0x2, -0x240(%rbp)
movq -0x240(%rbp), %rax
movl -0x4(%rbp), %ecx
imull -0x8(%rbp), %ecx
shll %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
je 0xce70
movsd -0x18(%rbp), %xmm0
callq 0x5fe0
movb %al, -0x319(%rbp)
jmp 0xccd0
movb -0x319(%rbp), %al
andb $0x1, %al
movb %al, -0x241(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x5fe0
movb %al, -0x31a(%rbp)
jmp 0xccf0
movb -0x31a(%rbp), %al
andb $0x1, %al
movb %al, -0x242(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x5fe0
movb %al, -0x31b(%rbp)
jmp 0xcd10
movb -0x31b(%rbp), %al
andb $0x1, %al
movb %al, -0x243(%rbp)
testb $0x1, -0x241(%rbp)
je 0xcd63
leaq 0x219fc(%rip), %rsi     # 0x2e72a
leaq -0x228(%rbp), %rdi
callq 0x52f0
jmp 0xcd3c
movb $0x0, -0x242(%rbp)
movb $0x0, -0x243(%rbp)
jmp 0xcd7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0xcfc8
leaq 0x219b9(%rip), %rsi     # 0x2e723
leaq -0x228(%rbp), %rdi
callq 0x52f0
jmp 0xcd78
jmp 0xcd7a
testb $0x1, -0x242(%rbp)
je 0xcda1
leaq 0x219a0(%rip), %rsi     # 0x2e72a
leaq -0x228(%rbp), %rdi
callq 0x52f0
jmp 0xcd98
movb $0x0, -0x243(%rbp)
jmp 0xcdb8
leaq 0x2197b(%rip), %rsi     # 0x2e723
leaq -0x228(%rbp), %rdi
callq 0x52f0
jmp 0xcdb6
jmp 0xcdb8
testb $0x1, -0x243(%rbp)
je 0xce2b
leaq 0x21962(%rip), %rsi     # 0x2e72a
leaq -0x228(%rbp), %rdi
callq 0x52f0
jmp 0xcdd6
movl $0x5, %edi
movl $0xf, %esi
callq 0x6040
movl %eax, -0x320(%rbp)
jmp 0xcded
movl -0x320(%rbp), %eax
movl %eax, -0x248(%rbp)
movl -0x248(%rbp), %esi
leaq -0x228(%rbp), %rdi
callq 0x5540
movq %rax, -0x328(%rbp)
jmp 0xce14
movq -0x328(%rbp), %rdi
leaq 0x21906(%rip), %rsi     # 0x2e728
callq 0x52f0
jmp 0xce29
jmp 0xce42
leaq 0x218f1(%rip), %rsi     # 0x2e723
leaq -0x228(%rbp), %rdi
callq 0x52f0
jmp 0xce40
jmp 0xce42
movq 0x33157(%rip), %rsi     # 0x3ffa0
leaq -0x228(%rbp), %rdi
callq 0x5330
jmp 0xce57
jmp 0xce59
movq -0x240(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x240(%rbp)
jmp 0xcca2
leaq -0x228(%rbp), %rdi
callq 0x5470
jmp 0xce7e
movq 0x3313b(%rip), %rdi     # 0x3ffc0
movq 0x33114(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x330(%rbp)
jmp 0xce9a
movq -0x330(%rbp), %rdi
leaq 0x21888(%rip), %rsi     # 0x2e730
callq 0x52f0
movq %rax, -0x338(%rbp)
jmp 0xceb6
movq -0x338(%rbp), %rdi
movq 0x330dc(%rip), %rsi     # 0x3ffa0
callq 0x5330
jmp 0xcecb
leaq -0x268(%rbp), %rdi
callq 0x5460
leaq 0x21ea8(%rip), %rsi     # 0x2ed86
leaq -0x268(%rbp), %rdi
callq 0x7f10
movb %al, -0x339(%rbp)
jmp 0xcef2
movb -0x339(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x33a(%rbp)
jne 0xcf07
jmp 0xcf30
leaq 0x2121d(%rip), %rsi     # 0x2e12b
leaq -0x268(%rbp), %rdi
callq 0x7f10
movb %al, -0x33b(%rbp)
jmp 0xcf22
movb -0x33b(%rbp), %al
movb %al, -0x33a(%rbp)
jmp 0xcf30
movb -0x33a(%rbp), %al
testb $0x1, %al
jne 0xcf3c
jmp 0xcfa7
movq 0x3307d(%rip), %rdi     # 0x3ffc0
movq 0x33056(%rip), %rsi     # 0x3ffa0
callq 0x5330
movq %rax, -0x348(%rbp)
jmp 0xcf58
movq -0x348(%rbp), %rdi
leaq 0x2134c(%rip), %rsi     # 0x2e2b2
callq 0x52f0
jmp 0xcf6d
movq 0x33064(%rip), %rdi     # 0x3ffd8
leaq -0x268(%rbp), %rsi
callq 0x5410
jmp 0xcf82
jmp 0xced7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x55d0
jmp 0xcfc8
leaq -0x268(%rbp), %rdi
callq 0x55d0
leaq -0x228(%rbp), %rdi
callq 0x5490
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
leaq -0x228(%rbp), %rdi
callq 0x5490
movq -0x230(%rbp), %rdi
callq 0x5550