Example #1
0
void readStateFile(string filePath)
{
	cout << "Reading state file " << filePath + "\\" + "state.json" << std::endl;
	string fileContent;
	string line;
	ifstream myfile(filePath + "\\" + "state.json");

	Json::Value Root;
	if (myfile.is_open())
	{
		myfile >> Root;
		const Json::Value RegisteredPlayerEntities = Root["RegisteredPlayerEntities"];
		const Json::Value CurrentRound = Root["CurrentRound"];
		const Json::Value PlayerBounty = Root["PlayerBounty"];
		const Json::Value MapHeight = Root["MapHeight"];
		const Json::Value MapWidth = Root["MapWidth"];
		const Json::Value MapSeed = Root["MapSeed"];
		const Json::Value GameBlocksRows = Root["GameBlocks"];

		
		for (int index = 0; index < RegisteredPlayerEntities.size(); ++index)
		{
			const Json::Value Name = RegisteredPlayerEntities[index]["Name"];
			const Json::Value Key = RegisteredPlayerEntities[index]["Key"];
			const Json::Value Points = RegisteredPlayerEntities[index]["Points"];
			const Json::Value Killed = RegisteredPlayerEntities[index]["Killed"];
			const Json::Value BombBag = RegisteredPlayerEntities[index]["BombBag"];
			const Json::Value BombRadius = RegisteredPlayerEntities[index]["BombRadius"];
			const Json::Value Location = RegisteredPlayerEntities[index]["Location"];
			PlayerState Player(Name, Key, Points, Killed, BombBag, BombRadius, Location);
			cout << Player.ToString() << endl;
			vPlayerState.push_back(Player);
		}
		cout << CurrentRound.asString() << endl;
		cout << PlayerBounty.asString() << endl;
		cout << MapHeight.asString() << endl;
		cout << MapWidth.asString() << endl;
		cout << MapSeed.asString() << endl;

		// Iterate over the sequence elements.
		for (int index = 0; index < GameBlocksRows.size(); ++index)
		{
			for (int Blockindex = 0; Blockindex < GameBlocksRows[index].size(); ++Blockindex)
			{
				const Json::Value Block = GameBlocksRows[index][Blockindex];

				const Json::Value EntityType = Block["Entity"];
				const Json::Value Bomb = Block["Bomb"];
				const Json::Value PowerUp = Block["PowerUp"];
				const Json::Value Exploding = Block["Exploding"];
				const Json::Value Location = Block["Location"];
				cBlock CurrentBlock(EntityType, Bomb, PowerUp, Exploding, Location);
				currentMap.m_vMap.push_back(CurrentBlock);
				Log.WriteToLog(CurrentBlock.ToString());
			}
		}
		myfile.close();
	}
Example #2
0
int main(int argc, char* argv[])
{
	string filePath = "";

	cout << "Args: " << argc << std::endl;
	cout << "Player Key: " << argv[1] << std::endl;
	if (argc == 3)
	{
		string Path (argv[2]);
		filePath = Path;
		cout << "File Path: " << filePath << std::endl;
	}
	Log.WriteToLog("Parsed args");


	readStateFile(filePath);
	writeMoveFile(filePath);

	NeuralNetwork NN;
	shared_ptr<Genome> tempGenome = NN.loadGenome(filePath + "\\" + "genome.json");

	return 0;
}