<commit_before>﻿using UnityEngine;
using System.Collections;

/// <summary>
/// Represents a general NPC that wanders around the city or gets in 
/// line at stores, reacting to events happening around them
/// </summary>
public class Citizen : Character 
{
	// Max money a citizen can start with
	public float MAX_MONEY = 1000.0f;

	// Least amount of money a citizen can have before 
	// they need to visit a bank
	public float LOW_MONEY = 50.0f;

	/// <summary>
	/// Characters start of wandering about the city
	/// </summary>
	override protected void Start () 
	{
		type = STEERING_TYPE.NONE;
		base.Start ();

		money = MAX_MONEY * Random.value;
		Decide ();
	}

	/// <summary>
	/// When an action finishes, give them something new to do
	/// </summary>
	override protected void Update () 
	{
		base.Update ();

		if (this.actionQueue.Count == 0) 
		{
			Decide ();
		}
	}

	/// <summary>
	/// Tells the citizen to decide what to do next
	/// under normal circumstances. 
	/// </summary>
	private void Decide() 
	{
		// Out of money causes them to go to a bank
		if (money < LOW_MONEY) 
		{
			GameObject bank = City.GetNearest(City.banks, gameObject);
			QueueAction(new Seek(bank, 10));
			QueueAction(new Shop(bank.GetComponent<Building>()));
		} 
		else 
		{
			// Randomly goes to a shop or wanders around looking
			// for something to do
			if (Random.value < 0.7)
			{
				QueueAction(new Wander(4));
				QueueAction(new Idle(2));
			}
			else 
			{
				GameObject shop = City.GetRandom(City.shops);
				QueueAction(new Seek(shop, 10));
				QueueAction(new Shop(shop.GetComponent<Building>()));
			}
		}
	}
}<commit_msg>Touched up Citizen logic a bit<commit_after>﻿using UnityEngine;
using System.Collections;

/// <summary>
/// Represents a general NPC that wanders around the city or gets in 
/// line at stores, reacting to events happening around them
/// </summary>
public class Citizen : Character 
{
	// Max money a citizen can start with
	public float MAX_MONEY = 1000.0f;

	/// <summary>
	/// Characters start of wandering about the city
	/// </summary>
	override protected void Start () 
	{
		type = STEERING_TYPE.NONE;
		base.Start ();

		money = MAX_MONEY * Random.value;
		Decide ();
	}

	/// <summary>
	/// When an action finishes, give them something new to do
	/// </summary>
	override protected void Update () 
	{
		base.Update ();

		if (this.actionQueue.Count == 0) 
		{
			Decide ();
		}
	}

	/// <summary>
	/// Tells the citizen to decide what to do next
	/// under normal circumstances. 
	/// </summary>
	private void Decide() 
	{
		// Wander around the city looking for something to do
		if (Random.value < 0.7)
		{
			QueueAction(new Wander(4));
			QueueAction(new Idle(2));
		}

		// Look for a shop to buy from
		else 
		{
			GameObject shop = City.GetRandom(City.shops);
			Building script = shop.GetComponent<Building>();

			// Need to go to a bank if does not have enough money to
			// buy from the desired shop
			if (money < script.MONEY_AMOUNT)
			{
				GameObject bank = City.GetRandom(City.banks);
				QueueAction(new Seek(bank, 10));
				QueueAction(new Shop(bank.GetComponent<Building>()));
			}

			// Move to and then get in line at the shop
			QueueAction(new Seek(shop, 10));
			QueueAction(new Shop(script));
		}
	}
}
{'fraction_non_alphanumeric': 0.12431276725717777, 'fraction_numerical': 0.009468540012217471, 'mean_word_length': 2.812572759022119, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 23, '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': '1669998', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1037, 'n_words': 350}