-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomENGINE.cs
50 lines (47 loc) · 1.13 KB
/
RandomENGINE.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomENGINE : MonoBehaviour {
/// <summary>
/// Returns 1 if passed true or -1 if passed false.
/// </summary>
/// <param name="myBool">Parameter value to pass.</param>
/// <returns>Returns an integer based on the passed value.</returns>
public PieceManager pm;
public int[,] Calc (int[,] input)
{
int index = 0;
//pm.GenerateMatrix();
pm.isLegal(pm.chessboardarray, false);
if(pm.legalMoves.Count > 0)
{
index = Random.Range(0, pm.legalMoves.Count);
}
else
{
if (pm.legalMoves.Count == 0) {
//GenerateMatrix();
if(pm.kinginchecks(pm.blackkingpos, pm.chessboardarray))
{
pm.blackkingincheck = true;
}
else if (pm.kinginchecks(pm.whitekingpos, pm.chessboardarray))
{
pm.whitekingincheck = true;
}
}
if(pm.RinseandRepeat == true)
{
print("no legal moves");
//pm.ResetBoard();
//pm.whitesTurn = true;
return input;
}
else
{
Debug.Break();
}
}
return pm.legalMoves[index];
}
}