-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AI' into menu-reconfiguration
- Loading branch information
Showing
12 changed files
with
176 additions
and
160 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
OdysseyNow/Assets/Scripts/BOTbehavior.meta → OdysseyNow/Assets/Scripts/AI.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
96 changes: 48 additions & 48 deletions
96
.../Scripts/BOTbehavior/BOTCubeController.cs → ...ets/Scripts/AI/card1/BOTCubeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using d = CardDirection.Director; | ||
|
||
namespace BOT | ||
{ | ||
/// <summary> | ||
/// This is basically a copy of PlayerCubeController. It's bad and you shouldn't use any of it. | ||
/// </summary> | ||
public class BOTCubeController : MonoBehaviour | ||
{ | ||
|
||
private Vector3 newPos; | ||
public GameObject tgt; | ||
static public int lagfactor = 5; | ||
static private float offset = 0; | ||
|
||
|
||
// Use this for initialization | ||
void Start() | ||
{ | ||
} | ||
|
||
// Update is called once per frame | ||
void FixedUpdate() | ||
{ | ||
if (!d.instance.paused) | ||
{ | ||
float tgtx = tgt.transform.position.x; | ||
float tgty = tgt.transform.position.y; | ||
|
||
// Goes 1/8 of the distance to the target (hopefully will have some lag) | ||
// Also if the target distance is pretty close, stop moving. Close enough counts in horseshoes, hand grenades, and the Magnavox Odyssey | ||
float oldx = gameObject.transform.position.x; | ||
float destx = (tgtx - oldx) / lagfactor + gameObject.transform.position.x; | ||
if (Mathf.Abs(oldx - destx) < 0.05) destx = oldx; | ||
|
||
float oldy = gameObject.transform.position.y; | ||
float desty = (tgty - oldy) / lagfactor + gameObject.transform.position.y; | ||
if (Mathf.Abs(oldy - desty) < 0.05) desty = oldy; | ||
newPos = new Vector3(destx, desty + offset, gameObject.transform.position.z); | ||
gameObject.transform.SetPositionAndRotation(newPos, gameObject.transform.rotation); | ||
} | ||
} | ||
|
||
} | ||
} | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using d = CardDirection.Director; | ||
|
||
namespace BOT | ||
{ | ||
/// <summary> | ||
/// This is basically a copy of PlayerCubeController. It's bad and you shouldn't use any of it. | ||
/// </summary> | ||
public class BOTCubeController : MonoBehaviour | ||
{ | ||
|
||
private Vector3 newPos; | ||
public GameObject tgt; | ||
static public int lagfactor = 5; | ||
static private float offset = 0; | ||
|
||
|
||
// Use this for initialization | ||
void Start() | ||
{ | ||
} | ||
|
||
// Update is called once per frame | ||
void FixedUpdate() | ||
{ | ||
if (!d.instance.paused) | ||
{ | ||
float tgtx = tgt.transform.position.x; | ||
float tgty = tgt.transform.position.y; | ||
|
||
// Goes 1/8 of the distance to the target (hopefully will have some lag) | ||
// Also if the target distance is pretty close, stop moving. Close enough counts in horseshoes, hand grenades, and the Magnavox Odyssey | ||
float oldx = gameObject.transform.position.x; | ||
float destx = (tgtx - oldx) / lagfactor + gameObject.transform.position.x; | ||
if (Mathf.Abs(oldx - destx) < 0.05) destx = oldx; | ||
|
||
float oldy = gameObject.transform.position.y; | ||
float desty = (tgty - oldy) / lagfactor + gameObject.transform.position.y; | ||
if (Mathf.Abs(oldy - desty) < 0.05) desty = oldy; | ||
newPos = new Vector3(destx, desty + offset, gameObject.transform.position.z); | ||
gameObject.transform.SetPositionAndRotation(newPos, gameObject.transform.rotation); | ||
} | ||
} | ||
|
||
} | ||
} |
File renamed without changes.
102 changes: 51 additions & 51 deletions
102
...cripts/BOTbehavior/BOTEngTargetControl.cs → ...s/Scripts/AI/card1/BOTEngTargetControl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace BOT | ||
{ | ||
/// <summary> | ||
/// This is from the original AI demo. It is bad and you should not use it. | ||
/// </summary> | ||
public class BOTEngTargetControl : MonoBehaviour | ||
{ | ||
|
||
public float startx, starty; | ||
static float targetY; | ||
public float speed = 10; | ||
public GameObject opponent; | ||
public GameObject ball; | ||
|
||
void Start() | ||
{ | ||
gameObject.transform.position = new Vector3(startx, starty, 0); | ||
targetY = 0; | ||
StartCoroutine(RandomEng()); | ||
} | ||
|
||
void Update() | ||
{ | ||
//smoothly move the target | ||
if (targetY - gameObject.transform.position.y > 0.1) | ||
{ | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + speed * Time.deltaTime, 0); | ||
} | ||
else if (targetY - gameObject.transform.position.y < -0.1) | ||
{ | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y - speed * Time.deltaTime, 0); | ||
} | ||
} | ||
|
||
//Randomly select a spot every 0.2 sec | ||
IEnumerator RandomEng() | ||
{ | ||
while (true) | ||
{ | ||
//no ridiculous movement | ||
targetY = Random.Range(-8, 8); | ||
yield return new WaitForSeconds(0.4f); | ||
} | ||
} | ||
|
||
} | ||
} | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace BOT | ||
{ | ||
/// <summary> | ||
/// This is from the original AI demo. It is bad and you should not use it. | ||
/// </summary> | ||
public class BOTEngTargetControl : MonoBehaviour | ||
{ | ||
|
||
public float startx, starty; | ||
static float targetY; | ||
public float speed = 10; | ||
public GameObject opponent; | ||
public GameObject ball; | ||
|
||
void Start() | ||
{ | ||
gameObject.transform.position = new Vector3(startx, starty, 0); | ||
targetY = 0; | ||
StartCoroutine(RandomEng()); | ||
} | ||
|
||
void Update() | ||
{ | ||
//smoothly move the target | ||
if (targetY - gameObject.transform.position.y > 0.1) | ||
{ | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y + speed * Time.deltaTime, 0); | ||
} | ||
else if (targetY - gameObject.transform.position.y < -0.1) | ||
{ | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y - speed * Time.deltaTime, 0); | ||
} | ||
} | ||
|
||
//Randomly select a spot every 0.2 sec | ||
IEnumerator RandomEng() | ||
{ | ||
while (true) | ||
{ | ||
//no ridiculous movement | ||
targetY = Random.Range(-8, 8); | ||
yield return new WaitForSeconds(0.4f); | ||
} | ||
} | ||
|
||
} | ||
} |
File renamed without changes.
118 changes: 59 additions & 59 deletions
118
...s/Scripts/BOTbehavior/BOTTargetControl.cs → ...sets/Scripts/AI/card1/BOTTargetControl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace BOT | ||
{ | ||
/// <summary> | ||
/// This is from the original AI demo. It is bad and you should not use it. | ||
/// If one is to make an AI to play one of these games, you should ONLY need a script like this that controls the player target, since the player target (and english target) are the only things players impact. | ||
/// We need at least one target controller script for every game AI. | ||
/// </summary> | ||
public class BOTTargetControl : MonoBehaviour | ||
{ | ||
public float startx, starty; | ||
public GameObject ball; | ||
private float randomy, lagf; | ||
|
||
void Start() | ||
{ | ||
gameObject.transform.position = new Vector3(startx, starty, 0); | ||
StartCoroutine(RandomPos()); StartCoroutine(RandomSpeed()); | ||
} | ||
|
||
void Update() | ||
{ | ||
float y; | ||
if (ball.transform.position.x > 0) | ||
{ | ||
//Always follows the ball(LagFactor reduced to allow the AI catch up to the ball) | ||
BOTCubeController.lagfactor = (int)lagf; | ||
y = ball.transform.position.y; | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, y, gameObject.transform.position.z); | ||
} | ||
else | ||
{ | ||
BOTCubeController.lagfactor = 20; | ||
y = randomy; | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, y, gameObject.transform.position.z); | ||
} | ||
} | ||
|
||
IEnumerator RandomSpeed() | ||
{ | ||
while (true) | ||
{ | ||
lagf = Random.Range(4, 10); | ||
yield return new WaitForSeconds(0.5f); | ||
} | ||
} | ||
|
||
IEnumerator RandomPos() | ||
{ | ||
while (true) | ||
{ | ||
randomy = Random.Range(-4, 4); | ||
yield return new WaitForSeconds(0.5f); | ||
} | ||
} | ||
} | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace BOT | ||
{ | ||
/// <summary> | ||
/// This is from the original AI demo. It is bad and you should not use it. | ||
/// If one is to make an AI to play one of these games, you should ONLY need a script like this that controls the player target, since the player target (and english target) are the only things players impact. | ||
/// We need at least one target controller script for every game AI. | ||
/// </summary> | ||
public class BOTTargetControl : MonoBehaviour | ||
{ | ||
public float startx, starty; | ||
public GameObject ball; | ||
private float randomy, lagf; | ||
|
||
void Start() | ||
{ | ||
gameObject.transform.position = new Vector3(startx, starty, 0); | ||
StartCoroutine(RandomPos()); StartCoroutine(RandomSpeed()); | ||
} | ||
|
||
void Update() | ||
{ | ||
float y; | ||
if (ball.transform.position.x > 0) | ||
{ | ||
//Always follows the ball(LagFactor reduced to allow the AI catch up to the ball) | ||
BOTCubeController.lagfactor = (int)lagf; | ||
y = ball.transform.position.y; | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, y, gameObject.transform.position.z); | ||
} | ||
else | ||
{ | ||
BOTCubeController.lagfactor = 20; | ||
y = randomy; | ||
gameObject.transform.position = new Vector3(gameObject.transform.position.x, y, gameObject.transform.position.z); | ||
} | ||
} | ||
|
||
IEnumerator RandomSpeed() | ||
{ | ||
while (true) | ||
{ | ||
lagf = Random.Range(4, 10); | ||
yield return new WaitForSeconds(0.5f); | ||
} | ||
} | ||
|
||
IEnumerator RandomPos() | ||
{ | ||
while (true) | ||
{ | ||
randomy = Random.Range(-4, 4); | ||
yield return new WaitForSeconds(0.5f); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
m_EditorVersion: 2019.3.0f6 | ||
m_EditorVersionWithRevision: 2019.3.0f6 (27ab2135bccf) | ||
m_EditorVersionWithRevision: 2019.3.0f6 (27ab2135bccf) |