// File: /workspace/github_cpp_makefile_star2_O1/Doug0855[P]TigerZone/Game.cpp
// Function: Game::play()
void Game::play() {
	for(int i = 0; i <  tileStack.tiles.size(); i++) {
		Tile currentTile = tileStack.tiles[i];
		if(i % 2 == 0) {

			std::vector<std::pair<int,int> > availableLocations = gameboard.display_positions(currentTile);
			std::cout<<"There are "<<availableLocations.size()<<" available locations for this tile"<<std::endl;
			for(int k = 0; k < availableLocations.size(); k++) {
				std::cout<<k<<") "<<availableLocations[k].first<<' '<<availableLocations[k].second<<std::endl;
			}
			// Take in where the user would like to place the tile
			int placementSelection;
			std::cin >> placementSelection;
			std::cout<<"Select option "<<placementSelection<<std::endl;
			// Create vector of that pair to pass to optimalLocation(), need to keep as param vector bc this is specific scenario where we know exact coordinates
			std::vector< std::pair<int,int> > placementLocation;
			placementLocation.push_back(availableLocations[placementSelection]);
			// Create a new pointer to a new tile of the same type as the currentTile
			Tile *tmpTile = new Tile(currentTile.getNum());
			// Properly rotate the tile so it may be placed
			std::pair<int, int> optimalLocation = gameboard.getOptimalPlacement(*tmpTile, placementLocation);
			// Place the new tile
			gameboard.place_tile(optimalLocation, *tmpTile);

			// printToTextFile(gameboard);
			std::cout<<std::endl;
		}
		else {
			std::cout<<"COMPUTER TURN"<<std::endl;
			// computer turn for solo play, player2 turn for tournament play
			std::vector<std::pair<int,int> > availableLocations = gameboard.display_positions(currentTile);
			Tile *tmpTile = new Tile(currentTile.getNum());
			if(availableLocations.size() > 0) {
				std::pair<int, int> optimalLocation = gameboard.getOptimalPlacement(*tmpTile, availableLocations);
				gameboard.place_tile(optimalLocation, *tmpTile);
				std::cout<<"Computer placed tile of type "<<currentTile.getType()<<" at location "<<optimalLocation.first<<' '<<optimalLocation.second<<std::endl;
			}
			else {
				// Need to implement the 3 functions for unplayable tiles
				std::cout<<"Unplayable tile. You may PASS, PICK UP A TIGER, OR PLACE A TIGER"<<std::endl;
			}

			// printToTextFile(gameboard);
		}
	}
	printToTextFile(gameboard);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movq 0x80(%rdi), %rax
movq %rdi, -0x30(%rbp)
cmpq %rax, 0x88(%rdi)
je 0xd365
xorl %r15d, %r15d
leaq -0x1a0(%rbp), %rbx
movq 0x120f7(%rip), %r13     # 0x1efc8
leaq -0x70(%rbp), %r12
imulq $0xe8, %r15, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x8b34
testb $0x1, %r15b
jne 0xd0bc
leaq -0x370(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8b34
leaq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %r14, %rdx
callq 0xf5fc
movq %r14, %rdi
callq 0x16aa0
movl $0xa, %edx
movq %r13, %rdi
leaq 0xb776(%rip), %rsi      # 0x186a0
callq 0x3280
movq -0x40(%rbp), %rsi
subq -0x48(%rbp), %rsi
sarq $0x3, %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %rbx
movl $0x22, %edx
movq %rax, %rdi
leaq 0xb756(%rip), %rsi      # 0x186ab
callq 0x3280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0xd02b
xorl %r14d, %r14d
movq %r13, %rdi
movl %r14d, %esi
callq 0x33c0
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0xb71f(%rip), %rsi      # 0x186ce
callq 0x3280
movq -0x48(%rbp), %rax
movl (%rax,%r14,8), %esi
movq %rbx, %rdi
callq 0x33c0
movb $0x20, -0x70(%rbp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3280
movq -0x48(%rbp), %rcx
movl 0x4(%rcx,%r14,8), %esi
movq %rax, %rdi
callq 0x33c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
incq %r14
movq -0x40(%rbp), %rax
subq -0x48(%rbp), %rax
sarq $0x3, %rax
cmpq %r14, %rax
ja 0xcf92
movq 0x11fae(%rip), %rdi     # 0x1efe0
leaq -0x4c(%rbp), %rsi
callq 0x3160
movl $0xe, %edx
movq %r13, %rdi
leaq 0xb687(%rip), %rsi      # 0x186d1
callq 0x3280
movl -0x4c(%rbp), %esi
movq %r13, %rdi
callq 0x33c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movslq -0x4c(%rbp), %rdx
shlq $0x3, %rdx
addq -0x48(%rbp), %rdx
movq -0x68(%rbp), %rsi
testq %rsi, %rsi
je 0xd277
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, -0x68(%rbp)
jmp 0xd27f
movl $0xd, %edx
movq %r13, %rdi
leaq 0xb615(%rip), %rsi      # 0x186e0
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
leaq -0x288(%rbp), %rbx
movq %rbx, %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x8b34
leaq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq 0xf5fc
movq %rbx, %rdi
callq 0x16aa0
movl $0xe8, %edi
callq 0x3220
movq %rax, %rbx
movl -0x19c(%rbp), %esi
movq %rax, %rdi
callq 0x158a8
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0xd236
leaq -0x88(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xeb44
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
leaq -0x88(%rbp), %rdx
callq 0x104fa
movq %rax, %r14
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xd186
callq 0x3200
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x112c4
movl $0x1d, %edx
movq %r13, %rdi
leaq 0xb54a(%rip), %rsi      # 0x186ee
callq 0x3280
movb -0x198(%rbp), %al
movb %al, -0x70(%rbp)
movl $0x1, %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0x3280
movq %rax, %rbx
movl $0xd, %edx
movq %rax, %rdi
leaq 0xb538(%rip), %rsi      # 0x1870c
callq 0x3280
movq %rbx, %rdi
movl %r14d, %esi
callq 0x33c0
movb $0x20, -0x70(%rbp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3280
shrq $0x20, %r14
movq %rax, %rdi
movl %r14d, %esi
callq 0x33c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
jmp 0xd315
movl $0x40, %edx
movq %r13, %rdi
leaq 0xb4d5(%rip), %rsi      # 0x1871a
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
jmp 0xd315
movq %r12, %rdi
callq 0xf156
movl $0xe8, %edi
callq 0x3220
movq %rax, %rbx
movl -0x19c(%rbp), %esi
movq %rax, %rdi
callq 0x158a8
leaq -0xa0(%rbp), %rdi
movq %r12, %rsi
callq 0xeb44
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
leaq -0xa0(%rbp), %rdx
callq 0x104fa
movq %rax, %r14
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0xd2d0
callq 0x3200
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x112c4
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3210
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3180
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xd315
callq 0x3200
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xd323
callq 0x3200
leaq -0x1a0(%rbp), %rbx
movq %rbx, %rdi
callq 0x16aa0
incq %r15
movq -0x30(%rbp), %rcx
movq 0x80(%rcx), %rax
movq 0x88(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $0x34f72c234f72c235, %rdx # imm = 0x34F72C234F72C235
imulq %rdx, %rcx
cmpq %r15, %rcx
ja 0xced5
leaq -0xb8(%rbp), %rbx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0xef6a
movq %rbx, %rsi
callq 0xd44e
leaq -0xb8(%rbp), %rdi
callq 0xf5f2
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
callq 0xf5f2
jmp 0xd446
jmp 0xd410
movq %rax, %r14
movq -0x88(%rbp), %rdi
jmp 0xd417
jmp 0xd410
movq %rax, %r14
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
jne 0xd3d9
jmp 0xd413
movq %rax, %r14
movq %rbx, %rdi
callq 0x3200
jmp 0xd413
movq %rax, %r14
leaq -0x288(%rbp), %rdi
jmp 0xd402
jmp 0xd40b
jmp 0xd40b
movq %rax, %r14
movq %rbx, %rdi
jmp 0xd41c
movq %rax, %r14
leaq -0x370(%rbp), %rdi
callq 0x16aa0
jmp 0xd43a
jmp 0xd429
movq %rax, %r14
jmp 0xd43a
movq %rax, %r14
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xd42c
callq 0x3200
jmp 0xd42c
jmp 0xd429
jmp 0xd429
jmp 0xd429
movq %rax, %r14
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xd43a
callq 0x3200
leaq -0x1a0(%rbp), %rdi
callq 0x16aa0
movq %r14, %rdi
callq 0x33f0