// File: /workspace/github_cpp_makefile_star2_O3/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 0xd267
xorl %r15d, %r15d
leaq -0x1a0(%rbp), %rbx
movq 0x121db(%rip), %r13     # 0x1efc8
leaq -0x70(%rbp), %r12
imulq $0xe8, %r15, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x89fc
testb $0x1, %r15b
jne 0xd064
leaq -0x370(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x89fc
leaq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %r14, %rdx
callq 0xf4f8
movq %r14, %rdi
callq 0x16758
movl $0xa, %edx
movq %r13, %rdi
leaq 0xb85a(%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 0xb83a(%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 0xcf47
xorl %r14d, %r14d
movq %r13, %rdi
movl %r14d, %esi
callq 0x33c0
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0xb803(%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 0xceae
movq 0x12092(%rip), %rdi     # 0x1efe0
leaq -0x4c(%rbp), %rsi
callq 0x3160
movl $0xe, %edx
movq %r13, %rdi
leaq 0xb76b(%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 %r12, %rdi
xorl %esi, %esi
callq 0xf052
movl $0xe8, %edi
callq 0x3220
movq %rax, %rbx
movl -0x19c(%rbp), %esi
movq %rax, %rdi
callq 0x15560
leaq -0xa0(%rbp), %rdi
movq %r12, %rsi
callq 0xea30
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
leaq -0xa0(%rbp), %rdx
callq 0x10440
movq %rax, %r14
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0xd016
callq 0x3200
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x11218
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 0xd217
callq 0x3200
jmp 0xd217
movl $0xd, %edx
movq %r13, %rdi
leaq 0xb66d(%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 0x89fc
leaq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq 0xf4f8
movq %rbx, %rdi
callq 0x16758
movl $0xe8, %edi
callq 0x3220
movq %rax, %rbx
movl -0x19c(%rbp), %esi
movq %rax, %rdi
callq 0x15560
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0xd1db
leaq -0x88(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xea30
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
leaq -0x88(%rbp), %rdx
callq 0x10440
movq %rax, %r14
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xd12e
callq 0x3200
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x11218
movl $0x1d, %edx
movq %r13, %rdi
leaq 0xb5a2(%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 0xb590(%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 0xd217
movl $0x40, %edx
movq %r13, %rdi
leaq 0xb530(%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
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xd225
callq 0x3200
leaq -0x1a0(%rbp), %rbx
movq %rbx, %rdi
callq 0x16758
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 0xcdf1
leaq -0xb8(%rbp), %rbx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0xee66
movq %rbx, %rsi
callq 0xd350
leaq -0xb8(%rbp), %rdi
callq 0xf4ee
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 0xf4ee
jmp 0xd348
movq %rax, %r14
movq -0x88(%rbp), %rdi
jmp 0xd319
jmp 0xd312
movq %rax, %r14
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
jne 0xd2db
jmp 0xd315
jmp 0xd312
movq %rax, %r14
movq %rbx, %rdi
callq 0x3200
jmp 0xd315
jmp 0xd30d
movq %rax, %r14
movq %rbx, %rdi
jmp 0xd31e
movq %rax, %r14
leaq -0x370(%rbp), %rdi
jmp 0xd302
movq %rax, %r14
leaq -0x288(%rbp), %rdi
callq 0x16758
jmp 0xd33c
jmp 0xd30d
jmp 0xd32b
movq %rax, %r14
jmp 0xd33c
movq %rax, %r14
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0xd32e
callq 0x3200
jmp 0xd32e
jmp 0xd32b
jmp 0xd32b
jmp 0xd32b
movq %rax, %r14
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xd33c
callq 0x3200
leaq -0x1a0(%rbp), %rdi
callq 0x16758
movq %r14, %rdi
callq 0x33f0