Ejemplo n.º 1
0
    private int GetNewTargetX(int myX, int myType)
    {
        List <distXData> res = new List <distXData>();

        for (int x = 0; x < enemyBoard.width; x++)
        {
            if (beats(myType, enemyBoard.GetTopValueAtX(x)))
            {
                res.Add(new distXData(x, GetDistanceBetweenPoints(myX, enemyBoard.width - 1 - x)));
            }
        }
        if (res.Count == 0)
        {
            return(-1);
        }
        res.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx)));
        distXData chosenOne = res[Random.Range(0, Mathf.FloorToInt(paddingForPathetic * res.Count))];

        return(enemyBoard.width - 1 - chosenOne.x);
    }
Ejemplo n.º 2
0
    private AIAction s0_0()       // SEE IF ANYTHING EXISTING WORKS
    {
        if (repeats0++ > repeatTheshold)
        {
            state = 3;
            return(s0_3());
        }
        List <typeDepthData> acceptableTypes = GetAcceptableTypesAndTheirMinimumDepths();
        List <columnData>    res             = new List <columnData>();
        int cx = c.getX();

        for (int x = 0; x < myBoard.width; x++)
        {
            int topYAtX = myBoard.GetHighestYAtX(x);
            if (topYAtX <= 0)
            {
                continue;
            }
            int typeAtPos = myBoard.GetValueAtXY(x, topYAtX).GetColorVal();
            int height    = 1;
            for (int y = topYAtX - 1; y >= 0; y--)
            {
                if (myBoard.GetValueAtXY(x, y).GetColorVal() != typeAtPos)
                {
                    break;
                }
                height++;
            }
            if (height == 1)
            {
                continue;
            }
            columnData cda = new columnData(x, typeAtPos, height, GetDistanceBetweenPoints(cx, x));
            if (CanHitOpponentWithThis(acceptableTypes, cda))
            {
                res.Add(cda);
            }
        }
        if (res.Count == 0)
        {
            state = 3;
            return(s0_3());
        }
        state = 1;
        res.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx)));
        int choice                 = Random.Range(0, Mathf.FloorToInt(paddingForPathetic * res.Count));
        int chances                = 0;
        List <distXData> res2      = new List <distXData>();
        columnData       chosenOne = res[choice];

        yourX    = chosenOne.x;
        yourType = chosenOne.type;
        while (chances++ < 3 && choice < res.Count)
        {
            res2.Clear();
            for (int x = 0; x < acceptableTypes.Count; x++)
            {
                if (!beats(yourType, acceptableTypes[x].type))
                {
                    continue;
                }
                res2.Add(new distXData(x, GetDistanceBetweenPoints(chosenOne.x, myBoard.width - 1 - x)));
            }
            if (res2.Count != 0)
            {
                break;
            }
        }
        if (res2.Count == 0)
        {
            state = 3;
            return(s0_3());
        }
        res2.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx)));
        distXData chosenOne2 = res2[Random.Range(0, Mathf.FloorToInt(paddingForPathetic * res2.Count))];

        theirInvertedX = myBoard.width - 1 - chosenOne2.x;
        theirType      = whatIsBeatenWhat(yourType);
        dxdir          = chosenOne.dx == 0 ? 0 : chosenOne.dx / Mathf.Abs(chosenOne.dx);
        shiftdir       = chosenOne2.dx == 0 ? 0 : chosenOne2.dx / Mathf.Abs(chosenOne2.dx);
        return(s0_1(yourX, theirInvertedX, yourType, theirType, dxdir, shiftdir));
    }
Ejemplo n.º 3
0
    private AIAction s2_5(int typeM, int xdir)       // LINE UP TILES
    {
        int cx = c.getX(), cy = c.getY();

        if (myBoard.GetValueAtXY(cx, cy).GetColorVal() != typeM)
        {
            if (repeats25++ > 4)
            {
                state = 1;
                return(s1());
            }
            if (xdir == 0)
            {
                List <distXData> res = new List <distXData>();
                for (int x = 0; x < myBoard.width; x++)
                {
                    if (myBoard.GetValueAtXY(x, cy).GetColorVal() == typeM)
                    {
                        res.Add(new distXData(x, GetDistanceBetweenPoints(cx, x)));
                    }
                }
                if (res.Count == 0)
                {
                    state = 999;
                    return(sOhFuckLetsGoRandom());
                }
                res.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx)));
                distXData chosenOne = res[Random.Range(0, Mathf.FloorToInt(paddingForPathetic * res.Count))];
                dxdir = chosenOne.dx / Mathf.FloorToInt(chosenOne.dx);
                xdir  = dxdir;
            }
            return(new AIAction(0, 0, xdir));
        }
        else
        {
            int depth = 0;
            for (int y = myBoard.height - myBoard.topoffset; y >= 0; y--)
            {
                int t = myBoard.GetValueAtXY(cx, y).GetColorVal();
                if (t == myBoard.deathTile)
                {
                    continue;
                }
                if (t != typeM)
                {
                    break;
                }
                depth++;
            }
            if (depth < 2)
            {
                if (cy == 0)
                {
                    state = 999;
                    return(sOhFuckLetsGoRandom());
                }
                else
                {
                    xdir     = 0;
                    shiftdir = 0;
                    return(new AIAction(0, -1));
                }
            }
            List <typeDepthData> acceptableTypes = GetAcceptableTypesAndTheirMinimumDepths();
            List <distXData>     res2            = new List <distXData>();
            for (int x = 0; x < acceptableTypes.Count; x++)
            {
                if (!beats(yourType, acceptableTypes[x].type) || depth < acceptableTypes[x].depth)
                {
                    continue;
                }
                res2.Add(new distXData(x, GetDistanceBetweenPoints(cx, enemyBoard.width - 1 - x)));
            }
            if (res2.Count == 0)
            {
                if (cy == 0)
                {
                    state = 999;
                    return(sOhFuckLetsGoRandom());
                }
                else
                {
                    xdir     = 0;
                    shiftdir = 0;
                    return(new AIAction(0, -1));
                }
            }
            res2.Sort((a, b) => Mathf.Abs(a.dx).CompareTo(Mathf.Abs(b.dx)));
            distXData chosenOne = res2[Random.Range(0, Mathf.FloorToInt(paddingForPathetic * res2.Count))];
            theirInvertedX = myBoard.width - 1 - chosenOne.x;
            theirType      = whatIsBeatenWhat(yourType);
            shiftdir       = chosenOne.dx == 0 ? 0 : -chosenOne.dx / Mathf.Abs(chosenOne.dx);
            state          = 2;
            return(new AIAction(0, 0));
        }
    }