// File: 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
subq $0x4c0, %rsp            # imm = 0x4C0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x3a8(%rbp), %rdi
movslq -0xc(%rbp), %rax
movq %rax, -0x3b0(%rbp)
addq $0x80, %rdi
callq 0x8250
movq %rax, %rcx
movq -0x3b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x13ba3
movq -0x3a8(%rbp), %rdi
addq $0x80, %rdi
movslq -0xc(%rbp), %rsi
callq 0x8280
movq %rax, %rsi
leaq -0xf8(%rbp), %rdi
callq 0x82a0
movl -0xc(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1386b
movq -0x3a8(%rbp), %rax
movq %rax, -0x3b8(%rbp)
leaq -0x1f8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x82a0
jmp 0x1345f
movq -0x3b8(%rbp), %rsi
leaq -0x110(%rbp), %rdi
leaq -0x1f8(%rbp), %rdx
callq 0x18760
jmp 0x1347b
leaq -0x1f8(%rbp), %rdi
callq 0x26870
movq 0x23b2a(%rip), %rdi     # 0x36fb8
leaq 0x16107(%rip), %rsi     # 0x2959c
callq 0x32b0
movq %rax, -0x3c0(%rbp)
jmp 0x134a3
leaq -0x110(%rbp), %rdi
callq 0x15160
movq -0x3c0(%rbp), %rdi
movq %rax, %rsi
callq 0x30b0
movq %rax, -0x3c8(%rbp)
jmp 0x134c7
movq -0x3c8(%rbp), %rdi
leaq 0x160d2(%rip), %rsi     # 0x295a7
callq 0x32b0
movq %rax, -0x3d0(%rbp)
jmp 0x134e3
movq -0x3d0(%rbp), %rdi
movq 0x23ab7(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x134f8
movl $0x0, -0x208(%rbp)
movslq -0x208(%rbp), %rax
movq %rax, -0x3d8(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x15160
movq %rax, %rcx
movq -0x3d8(%rbp), %rax
cmpq %rcx, %rax
jae 0x13651
movl -0x208(%rbp), %esi
movq 0x23a7c(%rip), %rdi     # 0x36fb8
callq 0x34c0
movq %rax, -0x3e0(%rbp)
jmp 0x1354a
movq -0x3e0(%rbp), %rdi
leaq 0x16072(%rip), %rsi     # 0x295ca
callq 0x32b0
movq %rax, -0x3e8(%rbp)
jmp 0x13566
movslq -0x208(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x15180
movq -0x3e8(%rbp), %rdi
movl (%rax), %esi
callq 0x34c0
movq %rax, -0x3f0(%rbp)
jmp 0x13590
movq -0x3f0(%rbp), %rdi
movl $0x20, %esi
callq 0x3340
movq %rax, -0x3f8(%rbp)
jmp 0x135aa
movslq -0x208(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x15180
movq -0x3f8(%rbp), %rdi
movl 0x4(%rax), %esi
callq 0x34c0
movq %rax, -0x400(%rbp)
jmp 0x135d5
movq -0x400(%rbp), %rdi
movq 0x239c5(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x135ea
jmp 0x135ec
movl -0x208(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x208(%rbp)
jmp 0x13502
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
jmp 0x13b95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x26870
jmp 0x13b95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
jmp 0x1385a
movq 0x23980(%rip), %rdi     # 0x36fd8
leaq -0x20c(%rbp), %rsi
callq 0x3200
jmp 0x13666
movq 0x2394b(%rip), %rdi     # 0x36fb8
leaq 0x15f59(%rip), %rsi     # 0x295cd
callq 0x32b0
movq %rax, -0x408(%rbp)
jmp 0x13682
movq -0x408(%rbp), %rdi
movl -0x20c(%rbp), %esi
callq 0x34c0
movq %rax, -0x410(%rbp)
jmp 0x1369d
movq -0x410(%rbp), %rdi
movq 0x238fd(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x136b2
leaq -0x228(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x151a0
movslq -0x20c(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x15180
movq -0x418(%rbp), %rdi
movq %rax, %rsi
callq 0x151c0
jmp 0x136e9
movl $0xe8, %edi
callq 0x32c0
movq %rax, -0x420(%rbp)
jmp 0x136fc
leaq -0xf8(%rbp), %rdi
callq 0x15100
movl %eax, -0x424(%rbp)
jmp 0x13710
movl -0x424(%rbp), %esi
movq -0x420(%rbp), %rdi
callq 0x250d0
jmp 0x13724
movq -0x3a8(%rbp), %rax
movq -0x420(%rbp), %rcx
movq %rcx, -0x230(%rbp)
movq %rax, -0x438(%rbp)
movq -0x230(%rbp), %rax
movq %rax, -0x430(%rbp)
leaq -0x250(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x15230
jmp 0x13763
movq -0x430(%rbp), %rsi
movq -0x438(%rbp), %rdi
leaq -0x250(%rbp), %rdx
callq 0x19e60
movq %rax, -0x440(%rbp)
jmp 0x13786
movq -0x440(%rbp), %rax
movq %rax, -0x238(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x15320
movq -0x3a8(%rbp), %rdi
movq -0x238(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x230(%rbp), %rdx
movq -0x258(%rbp), %rsi
callq 0x1b3d0
jmp 0x137ca
movq 0x237e7(%rip), %rdi     # 0x36fb8
movq 0x237d0(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x137df
leaq -0x228(%rbp), %rdi
callq 0x15320
leaq -0x110(%rbp), %rdi
callq 0x15320
jmp 0x13b7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
jmp 0x1384e
movq -0x420(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
callq 0x32a0
jmp 0x1384e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x15320
leaq -0x228(%rbp), %rdi
callq 0x15320
leaq -0x110(%rbp), %rdi
callq 0x15320
jmp 0x13b95
movq 0x23746(%rip), %rdi     # 0x36fb8
leaq 0x15d63(%rip), %rsi     # 0x295dc
callq 0x32b0
movq %rax, -0x448(%rbp)
jmp 0x13887
movq -0x448(%rbp), %rdi
movq 0x23713(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x1389c
movq -0x3a8(%rbp), %rax
movq %rax, -0x450(%rbp)
leaq -0x358(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x82a0
jmp 0x138bf
movq -0x450(%rbp), %rsi
leaq -0x270(%rbp), %rdi
leaq -0x358(%rbp), %rdx
callq 0x18760
jmp 0x138db
leaq -0x358(%rbp), %rdi
callq 0x26870
movl $0xe8, %edi
callq 0x32c0
movq %rax, -0x458(%rbp)
jmp 0x138fa
leaq -0xf8(%rbp), %rdi
callq 0x15100
movl %eax, -0x45c(%rbp)
jmp 0x1390e
movl -0x45c(%rbp), %esi
movq -0x458(%rbp), %rdi
callq 0x250d0
jmp 0x13922
movq -0x458(%rbp), %rax
movq %rax, -0x360(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x15160
cmpq $0x0, %rax
jbe 0x13b2c
movq -0x3a8(%rbp), %rax
movq %rax, -0x470(%rbp)
movq -0x360(%rbp), %rax
movq %rax, -0x468(%rbp)
leaq -0x380(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x15230
jmp 0x13977
movq -0x468(%rbp), %rsi
movq -0x470(%rbp), %rdi
leaq -0x380(%rbp), %rdx
callq 0x19e60
movq %rax, -0x478(%rbp)
jmp 0x1399a
movq -0x478(%rbp), %rax
movq %rax, -0x368(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x15320
movq -0x3a8(%rbp), %rdi
movq -0x368(%rbp), %rax
movq %rax, -0x388(%rbp)
movq -0x360(%rbp), %rdx
movq -0x388(%rbp), %rsi
callq 0x1b3d0
jmp 0x139de
movq 0x235d3(%rip), %rdi     # 0x36fb8
leaq 0x15bfe(%rip), %rsi     # 0x295ea
callq 0x32b0
movq %rax, -0x480(%rbp)
jmp 0x139fa
leaq -0xf8(%rbp), %rdi
callq 0x8140
movb %al, -0x481(%rbp)
jmp 0x13a0e
movq -0x480(%rbp), %rdi
movb -0x481(%rbp), %al
movsbl %al, %esi
callq 0x3340
movq %rax, -0x490(%rbp)
jmp 0x13a2c
movq -0x490(%rbp), %rdi
leaq 0x15bce(%rip), %rsi     # 0x29608
callq 0x32b0
movq %rax, -0x498(%rbp)
jmp 0x13a48
movq -0x498(%rbp), %rdi
movl -0x368(%rbp), %esi
callq 0x34c0
movq %rax, -0x4a0(%rbp)
jmp 0x13a63
movq -0x4a0(%rbp), %rdi
movl $0x20, %esi
callq 0x3340
movq %rax, -0x4a8(%rbp)
jmp 0x13a7d
movq -0x4a8(%rbp), %rdi
movl -0x364(%rbp), %esi
callq 0x34c0
movq %rax, -0x4b0(%rbp)
jmp 0x13a98
movq -0x4b0(%rbp), %rdi
movq 0x23502(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x13aad
jmp 0x13b5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x26870
jmp 0x13b95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
jmp 0x13b6d
movq -0x458(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
callq 0x32a0
jmp 0x13b6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x15320
jmp 0x13b6d
movq 0x23485(%rip), %rdi     # 0x36fb8
leaq 0x15adc(%rip), %rsi     # 0x29616
callq 0x32b0
movq %rax, -0x4b8(%rbp)
jmp 0x13b48
movq -0x4b8(%rbp), %rdi
movq 0x23452(%rip), %rsi     # 0x36fa8
callq 0x32e0
jmp 0x13b5d
jmp 0x13b5f
leaq -0x270(%rbp), %rdi
callq 0x15320
jmp 0x13b7b
leaq -0x270(%rbp), %rdi
callq 0x15320
jmp 0x13b95
leaq -0xf8(%rbp), %rdi
callq 0x26870
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x133d1
leaq -0xf8(%rbp), %rdi
callq 0x26870
jmp 0x13c05
movq -0x3a8(%rbp), %rsi
leaq -0x3a0(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
callq 0x15380
movq -0x3a8(%rbp), %rdi
movq -0x4c0(%rbp), %rsi
callq 0x13c20
jmp 0x13bd2
leaq -0x3a0(%rbp), %rdi
callq 0x18740
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x3a0(%rbp), %rdi
callq 0x18740
movq -0x200(%rbp), %rdi
callq 0x34f0
nopw %cs:(%rax,%rax)