// File: Doug0855[P]TigerZone/Game.cpp
// Function: Game::meepleAi[abi:cxx11](int, int)
std::string Game::meepleAi(int i, int j)
{
  Adapter adapter;
  std::string tiger;
	// always place at a den if you can
	if (gameboard.m_board[i][j]->getCenter().getType() == "den")
	{
		gameboard.placeMeeple(i, j, std::pair<int,int> (1,1));
		tiger = " TIGER 5";
		return tiger;
	}
	// if there wasn't a den in the middle then get all the structures in the current tile
	std::vector<Structure> structures = gameboard.getStructures(i, j);
	// if you found structures
	if (structures.size() > 0)
	{
		int mostPoints = 0;
		int bestStruct = structures.size();
		// find the first structure that doesn't have a meeple
		for (size_t ii = 0; ii < structures.size(); ii++)
		{
			if (!structures[ii].hasMeeple)
			{
				bestStruct = ii;
				break;
			}
		}
		// for all the strucutres that don't have meeples count up the point values
		for (size_t ii = bestStruct; ii < structures.size(); ii++)
		{
			if (!structures[ii].hasMeeple)
			{
				int points = structurePoints(structures[ii]);
				// select the one with the highest point values
				if (points > mostPoints)
				{
					mostPoints = points;
					bestStruct = ii;
				}
			}
		}
		// as long as you found a stucutre without a meeple place the meele at the one with the highest points
		if (bestStruct != structures.size())
		{
		  gameboard.placeMeeple(i, j, structures[bestStruct].startingBlock);
		  std::string temp = std::to_string(adapter.convertZone(structures[bestStruct].startingBlock));
		  tiger = " TIGER " + temp;
		  return tiger;
		}
	}
	tiger = " NONE";
	return tiger;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x270(%rbp)
movq %rdi, %rax
movq %rax, -0x278(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x268(%rbp)
leaq -0x110(%rbp), %rdi
callq 0xe260
movq -0x270(%rbp), %rdi
movb $0x0, -0x111(%rbp)
callq 0x33c0
movq -0x268(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x81d0
movq %rax, %rdi
movslq -0x18(%rbp), %rsi
callq 0x8230
movq (%rax), %rsi
leaq -0x160(%rbp), %rdi
callq 0x15430
jmp 0x14a51
leaq -0x138(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x15490
jmp 0x14a66
leaq 0x14c25(%rip), %rsi     # 0x29692
leaq -0x138(%rbp), %rdi
callq 0x85b0
movb %al, -0x279(%rbp)
jmp 0x14a81
leaq -0x138(%rbp), %rdi
callq 0x3210
leaq -0x160(%rbp), %rdi
callq 0x28420
movb -0x279(%rbp), %al
testb $0x1, %al
jne 0x14aa8
jmp 0x14b9e
movq -0x268(%rbp), %rax
movq %rax, -0x290(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x284(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x280(%rbp)
movl $0x1, -0x178(%rbp)
movl $0x1, -0x17c(%rbp)
leaq -0x174(%rbp), %rdi
leaq -0x178(%rbp), %rsi
leaq -0x17c(%rbp), %rdx
callq 0x89e0
jmp 0x14af8
movl -0x280(%rbp), %edx
movl -0x284(%rbp), %esi
movq -0x290(%rbp), %rdi
movq -0x174(%rbp), %rcx
callq 0x1c690
jmp 0x14b19
movq -0x270(%rbp), %rdi
leaq 0x14b6f(%rip), %rsi     # 0x29696
callq 0x33a0
jmp 0x14b2e
movb $0x1, -0x111(%rbp)
movl $0x1, -0x180(%rbp)
jmp 0x14f13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
jmp 0x14f44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
jmp 0x14b8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x3210
leaq -0x160(%rbp), %rdi
callq 0x28420
jmp 0x14f44
movq -0x268(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq -0x198(%rbp), %rdi
callq 0x1c080
jmp 0x14bb9
leaq -0x198(%rbp), %rdi
callq 0x154c0
cmpq $0x0, %rax
jbe 0x14ed1
movl $0x0, -0x19c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x154c0
movl %eax, -0x1a0(%rbp)
movq $0x0, -0x1a8(%rbp)
movq -0x1a8(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x154c0
movq %rax, %rcx
movq -0x298(%rbp), %rax
cmpq %rcx, %rax
jae 0x14c5d
movq -0x1a8(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x154f0
testb $0x1, 0x50(%rax)
jne 0x14c47
movq -0x1a8(%rbp), %rax
movl %eax, -0x1a0(%rbp)
jmp 0x14c5d
jmp 0x14c49
movq -0x1a8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1a8(%rbp)
jmp 0x14bf6
movslq -0x1a0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x154c0
movq %rax, %rcx
movq -0x2a0(%rbp), %rax
cmpq %rcx, %rax
jae 0x14d8a
movq -0x1b0(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x154f0
testb $0x1, 0x50(%rax)
jne 0x14d71
movq -0x1b0(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x154f0
movq %rax, %rsi
leaq -0x210(%rbp), %rdi
callq 0x15510
jmp 0x14cd9
movq -0x268(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x14f70
movl %eax, -0x2a4(%rbp)
jmp 0x14cf4
leaq -0x210(%rbp), %rdi
callq 0x28730
movl -0x2a4(%rbp), %eax
movl %eax, -0x1b4(%rbp)
movl -0x1b4(%rbp), %eax
cmpl -0x19c(%rbp), %eax
jle 0x14d6f
movl -0x1b4(%rbp), %eax
movl %eax, -0x19c(%rbp)
movq -0x1b0(%rbp), %rax
movl %eax, -0x1a0(%rbp)
jmp 0x14d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
jmp 0x14f05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x28730
jmp 0x14f05
jmp 0x14d71
jmp 0x14d73
movq -0x1b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1b0(%rbp)
jmp 0x14c6b
movslq -0x1a0(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x154c0
movq %rax, %rcx
movq -0x2b0(%rbp), %rax
cmpq %rcx, %rax
je 0x14ecf
movl -0x14(%rbp), %eax
movl %eax, -0x2b8(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x2b4(%rbp)
movslq -0x1a0(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x154f0
movq -0x268(%rbp), %rdi
movl -0x2b8(%rbp), %esi
movl -0x2b4(%rbp), %edx
movq 0x20(%rax), %rax
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rcx
callq 0x1c690
jmp 0x14e08
movslq -0x1a0(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x154f0
movq 0x20(%rax), %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0xfc80
movl %eax, -0x2bc(%rbp)
jmp 0x14e41
movl -0x2bc(%rbp), %esi
leaq -0x238(%rbp), %rdi
callq 0x8b80
jmp 0x14e55
leaq 0x14843(%rip), %rsi     # 0x2969f
leaq -0x260(%rbp), %rdi
leaq -0x238(%rbp), %rdx
callq 0x8d10
jmp 0x14e71
movq -0x270(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x3360
leaq -0x260(%rbp), %rdi
callq 0x3210
movb $0x1, -0x111(%rbp)
movl $0x1, -0x180(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3210
jmp 0x14ef7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3210
jmp 0x14f05
jmp 0x14ed1
movq -0x270(%rbp), %rdi
leaq 0x14778(%rip), %rsi     # 0x29657
callq 0x33a0
jmp 0x14ee6
movb $0x1, -0x111(%rbp)
movl $0x1, -0x180(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x155a0
jmp 0x14f13
leaq -0x198(%rbp), %rdi
callq 0x155a0
jmp 0x14f44
testb $0x1, -0x111(%rbp)
jne 0x14f28
movq -0x270(%rbp), %rdi
callq 0x3210
leaq -0x110(%rbp), %rdi
callq 0xe2f0
movq -0x278(%rbp), %rax
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
movq -0x270(%rbp), %rdi
callq 0x3210
leaq -0x110(%rbp), %rdi
callq 0xe2f0
movq -0x168(%rbp), %rdi
callq 0x34f0
nopl (%rax,%rax)