// File: /workspace/github_cpp_makefile_star2_O2/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 $0x358, %rsp            # imm = 0x358
xorl %ebx, %ebx
movq 0xf8bf(%rip), %r13      # 0x18fc0
movq %rdi, -0x30(%rbp)
movq 0x80(%rdi), %rsi
movq 0x88(%rdi), %rax
subq %rsi, %rax
cqto
movl $0xe8, %ecx
idivq %rcx
cmpq %rbx, %rax
jbe 0x9a2c
imulq $0xe8, %rbx, %rax
addq %rax, %rsi
leaq -0x1a8(%rbp), %r14
movq %r14, %rdi
callq 0x60b0
movq %rbx, -0x78(%rbp)
testb $0x1, %bl
jne 0x981e
leaq -0x378(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x60b0
leaq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq 0xb142
movq %rbx, %rdi
callq 0x10e3c
movq %r13, %rdi
leaq 0x8e9d(%rip), %rsi      # 0x12620
callq 0x3200
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x3190
movq %rax, %rdi
leaq 0x8e85(%rip), %rsi      # 0x1262b
callq 0x3200
movq %rax, %rdi
callq 0x3140
xorl %r14d, %r14d
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x3, %rax
cmpq %r14, %rax
jbe 0x992d
movq %r13, %rdi
movl %r14d, %esi
callq 0x3390
movq %rax, %rdi
leaq 0x8e6e(%rip), %rsi      # 0x1264e
callq 0x3200
movq -0x50(%rbp), %rcx
movl (%rcx,%r14,8), %esi
movq %rax, %rdi
callq 0x3390
movq %rax, %rdi
pushq $0x20
popq %rsi
callq 0x3260
movq -0x50(%rbp), %rcx
movl 0x4(%rcx,%r14,8), %esi
movq %rax, %rdi
callq 0x3390
movq %rax, %rdi
callq 0x3140
incq %r14
jmp 0x97b6
movq %r13, %rdi
leaq 0x8e38(%rip), %rsi      # 0x12660
callq 0x3200
movq %rax, %rdi
callq 0x3140
leaq -0x290(%rbp), %rbx
movq %rbx, %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x60b0
leaq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq 0xb142
movq %rbx, %rdi
callq 0x10e3c
movl $0xe8, %edi
callq 0x3210
movq %rax, %rbx
movl -0x1a4(%rbp), %esi
movq %rax, %rdi
callq 0xffb0
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
je 0x99f0
leaq -0xa8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa686
movq -0x30(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq -0xa8(%rbp), %r12
movq %r12, %rdx
callq 0xbd5e
movq %rax, %r14
movq %r12, %rdi
callq 0xaca8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xc856
movq %r13, %rdi
leaq 0x8d96(%rip), %rsi      # 0x1266e
callq 0x3200
movsbl -0x1a0(%rbp), %esi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
leaq 0x8d96(%rip), %rsi      # 0x1268c
callq 0x3200
movq %rax, %rdi
movl %r14d, %esi
callq 0x3390
movq %rax, %rdi
pushq $0x20
popq %rsi
callq 0x3260
shrq $0x20, %r14
movq %rax, %rdi
movl %r14d, %esi
callq 0x3390
movq %rax, %rdi
callq 0x3140
jmp 0x9a07
movq 0xf6ac(%rip), %rdi      # 0x18fe0
leaq -0x34(%rbp), %rsi
callq 0x3180
movq %r13, %rdi
leaq 0x8d0a(%rip), %rsi      # 0x12651
callq 0x3200
movl -0x34(%rbp), %esi
movq %rax, %rdi
callq 0x3390
movq %rax, %rdi
callq 0x3140
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
andq $0x0, -0x60(%rbp)
movslq -0x34(%rbp), %rsi
shlq $0x3, %rsi
addq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0xa662
movl $0xe8, %edi
callq 0x3210
movq %rax, %rbx
movl -0x1a4(%rbp), %esi
movq %rax, %rdi
callq 0xffb0
leaq -0xc0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xa686
movq -0x30(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq -0xc0(%rbp), %r12
movq %r12, %rdx
callq 0xbd5e
movq %rax, %r14
movq %r12, %rdi
callq 0xaca8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xc856
movq %r13, %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
callq 0xaca8
jmp 0x9a07
movq %r13, %rdi
leaq 0x8ca0(%rip), %rsi      # 0x1269a
callq 0x3200
movq %rax, %rdi
callq 0x3140
leaq -0x50(%rbp), %rdi
callq 0xaca8
leaq -0x1a8(%rbp), %rdi
callq 0x10e3c
movq -0x78(%rbp), %rbx
incq %rbx
movq -0x30(%rbp), %rdi
jmp 0x9705
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0xaa4a
movq %rbx, %rsi
callq 0x9b10
leaq -0x90(%rbp), %rdi
callq 0xb138
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x90(%rbp), %rdi
callq 0xb138
jmp 0x9b08
movq %rax, %r14
leaq -0xa8(%rbp), %rdi
jmp 0x9ae3
jmp 0x9adc
jmp 0x9adc
movq %rax, %r14
leaq -0xc0(%rbp), %rdi
callq 0xaca8
jmp 0x9adf
movq %rax, %r14
movq %rbx, %rdi
callq 0x31f0
jmp 0x9adf
jmp 0x9ad7
movq %rax, %r14
movq %rbx, %rdi
callq 0x31f0
jmp 0x9af3
jmp 0x9ad7
movq %rax, %r14
leaq -0x290(%rbp), %rdi
jmp 0x9ace
movq %rax, %r14
leaq -0x378(%rbp), %rdi
callq 0x10e3c
jmp 0x9afc
jmp 0x9af0
movq %rax, %r14
jmp 0x9afc
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0xaca8
jmp 0x9af3
jmp 0x9af0
jmp 0x9af0
jmp 0x9af0
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0xaca8
leaq -0x1a8(%rbp), %rdi
callq 0x10e3c
movq %r14, %rdi
callq 0x33c0