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

public class SetUpForAttack : MonoBehaviour
{

  public GameObject agent;
  public Vector3 goalPosition;
  public Vector3 goalForward;
  public float preferredShootingDistanceFromPlayer = 10.0f;
  public float preferredShootAngleFromPlayer = 90.0f;

  void Start()
  {
    agent = this.gameObject.transform.parent.gameObject;
  }

  void Update()
  {

  }

  void OnCollisionStay(Collision collisionInfo)
  {
    foreach (Collision col in collisionInfo)
    {
      GameObject obj = col.collider.gameObject;
      if (obj.tag == "Player")
      {
        this.goalPosition = MakeGoalPositionFromPlayerPosition(obj.transform.position, obj.transform.forward);
        this.goalForward = MakeGoalForwardFromPlayerPosition(obj.transform.position, obj.transform.forward);
        break;
      }
    }
  }

  Vector3 MakeGoalPositionFromPlayerPosition(Vector3 playerPosition, Vector3 playerForward)
  {
    Vector3 v = Vector3.zero;
    return v;
  }

  Vector3 MakeGoalForwardFromPlayerPosition(Vector3 playerPosition, Vector3 playerForward)
  {
    Vector3 v = Vector3.zero;
    return v;
  }

}<commit_msg>AI moving code<commit_after>﻿using UnityEngine;
using System.Collections;

public class SetUpForAttack : MonoBehaviour
{

  public GameObject agent;
  public Vector3 goalPosition;
  public Vector3 goalForward;
  public float preferredShootingDistanceFromPlayer = 10.0f;
  public float preferredShootAngleFromPlayer = 90.0f;

  void Start()
  {
    agent = this.gameObject.transform.parent.gameObject;
  }

  void Update()
  {

  }

  void OnCollisionStay(Collision collisionInfo)
  {
    foreach (Collision col in collisionInfo)
    {
      GameObject obj = col.collider.gameObject;
      if (obj.tag == "Player")
      {
        this.goalPosition = MakeGoalPositionFromPlayerPosition(obj.transform.position);
        this.goalForward = MakeGoalForwardFromPlayerPosition(obj.transform.position);
        break;
      }
    }
  }

  Vector3 MakeGoalPositionFromPlayerPosition(Vector3 playerPosition)
  {
	Vector3 diff = playerPosition - this.gameObject.transform.position;
	if (diff.magnitude < 25) {
		return this.gameObject.transform.position;
	} else {
		Vector3 goal = playerPosition + diff.normalized * (diff.magnitude - 25);
		return goal;
	}
  }

  Vector3 MakeGoalForwardFromPlayerPosition(Vector3 playerPosition)
  {
	float rotation_x = 0;
	float rotation_y = 0;
	float rotation_z = 0;
	Vector3 diff = playerPosition - this.goalPosition;
	float cosphi = Vector3.Dot (this.gameObject.transform.up,diff.normalized, diff.normalized);
	float costheta = Vector3.Dot (this.gameObject.transform.forward,diff.normalized);
	if (Math.Abs (cosphi) > .5) {
		bool right = diff.z > 0;
		if (cosphi > 0 ){
			rotation_x = Mathf.PI/3 - Mathf.Acos(cosphi);
		}
		else{
			rotation_x = Mathf.PI/3*2 - Mathf.Acos(cosphi);
		}
		if (right){
			rotation_x = -rotation_x;
		}
	}
	if (Math.Abs (costheta) > .5) {
		bool right = diff.z > 0;
		if (costheta > 0 ){
			rotation_y = Mathf.PI/3 - Mathf.Acos(costheta);
		}
		else{
			rotation_y = Mathf.PI/3*2 - Mathf.Acos(costheta);
		}
		if (!right){
			rotation_y = -rotation_y;
		}
	}
	Vector3 v = new Vector3 (rotation_x*180/Mathf.PI,rotation_y*180/Mathf.PI,rotation_z*180/Mathf.PI);
    return v;
  }

}
{'fraction_non_alphanumeric': 0.10139225181598063, 'fraction_numerical': 0.01967312348668281, 'mean_word_length': 3.564917127071823, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, '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': '4919784', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1084, 'n_words': 221}