<commit_before>//Author: <NAME>
//Date Created: 7 August 2017
//File Description: c++ code for the king.
//Fun Fact: Simon Kim is now Simon King
#include <iostream>
#include <string>
#include "king.h"

King::King(coord pos, TeamColor color) : Pieces()
{
	type = PieceType::King;
	position = pos;
	team = color;
}

coordList King::calculateMoves(coord boundary, const squareGrid& square) const
{
	coordList validMoves;

	// Create a vector of coords representing the moves of a king.
	// The king can move diagonally and orthogonally.
	coordList moves = {
		// Diagonal unit vectors.
		{ 1, 1 },{ 1, -1 },{ -1, 1 },{ -1, -1 },
		// Orthogonal unit vectors.
		{ 0, 1 },{ 0, -1 },{ 1, 0 },{ -1, 0 },
	};

	for (auto& move : moves)
	{
		coord newPos = position + move;

		validMoves.push_back(newPos);
	}




	return validMoves;

}<commit_msg>updated king move calculation. still need to check if the square is being attacked/going to put the king in check.<commit_after>//Author: <NAME>
//Date Created: 7 August 2017
//File Description: c++ code for the king.
//Fun Fact: Simon Kim is now Simon King
#include <iostream>
#include <string>
#include "king.h"

King::King(coord pos, TeamColor color) : Pieces()
{
	type = PieceType::King;
	position = pos;
	team = color;
}

coordList King::calculateMoves(coord boundary, const squareGrid& square) const
{
	coordList validMoves;
	
	coordList moves = 
	{
		//Diagonal unit vectors
		{ 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1},
		//Orthogonal unit vectors
		{ 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 }
	};

	for ( auto& move : moves )
	{
		coord newPos = position + move;
		//Loop each direction to adjacent sqaure.
		if((newPos.x < boundary.y && newPos.y < boundary.y) && (newPos.x >= 0 && newPos.y >=0))
		{
			if(!square[newPos.x][newPos.y].occupied())
			{
				validMoves.push_back(newPos);
				newPos = newPos + move;
			}
			else
			{
				if(square[newPos.x][newPos.y].pieces.front()->getTeamColor() != team)
				{
					validMoves.push_back(newPos);
				}
			}
		}

	}	



	return validMoves;

}
{'fraction_non_alphanumeric': 0.15520628683693516, 'fraction_numerical': 0.021611001964636542, 'mean_word_length': 3.13184584178499, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1719418', 'n_tokens_mistral': 832, 'n_tokens_neox': 729, 'n_words': 225}