Пример #1
0
        //basicly rewritten by AISmartScan(1) - kept for nostalsia sake
        private void AISimplePlanMove()
        {
            Point    newDir   = new Point(0, 0);
            GameSlot fuelSlot = GetFuelSlot();

            if (fuelSlot.X > playerSlot.X)
            {
                newDir.X = 1;
            }
            else if (fuelSlot.X < playerSlot.X)
            {
                newDir.X = -1;
            }
            else if (fuelSlot.Y > playerSlot.Y)
            {
                newDir.Y = 1;
            }
            else if (fuelSlot.Y < playerSlot.Y)
            {
                newDir.Y = -1;
            }

            playerSlot.Child.facingDirection.X = newDir.X;
            playerSlot.Child.facingDirection.Y = newDir.Y;

            GameSlot newSlot = GetNextGameSlot();

            if (!newSlot.IsSafeToWalkOn())//fire in front
            {
                playerSlot.Child.facingDirection = RotateSimpleVector(playerSlot.Child.facingDirection, 3);
                newSlot = GetNextGameSlot();
                if (!newSlot.IsSafeToWalkOn())// fire to left
                {
                    playerSlot.Child.facingDirection = RotateSimpleVector(playerSlot.Child.facingDirection, 2);
                    newSlot = GetNextGameSlot();
                    if (!newSlot.IsSafeToWalkOn())// fire to right - check backwards
                    {
                        //check  straight
                        playerSlot.Child.facingDirection = RotateSimpleVector(playerSlot.Child.facingDirection, 1);
                        newSlot = GetNextGameSlot();
                        if (!newSlot.IsSafeToWalkOn())// fire to right - check backwards
                        {
                            //crash straight
                            playerSlot.Child.facingDirection.X = lastMoveDirection.X;
                            playerSlot.Child.facingDirection.Y = lastMoveDirection.Y;
                        }
                    }
                }
            }
        }
Пример #2
0
        private int AIScoreMove(Point startPoint, Point dir, Point correctDirectionToGoal, int movesInFuture)
        {
            GameSlot option = GetGameSlot(startPoint, dir.X, dir.Y);

            int score = 0;

            if (!option.IsSafeToWalkOn(movesInFuture))
            {
                score = Int32.MinValue;//death here
            }
            else
            {
                int scoreFactorX = 1;
                int scoreFactorY = 1;
                if (aiZigZag)
                {
                    scoreFactorX = Math.Abs(correctDirectionToGoal.X) + dir.X;
                    scoreFactorY = Math.Abs(correctDirectionToGoal.Y) + dir.Y;
                }
                //calc score X score + Y score
                score = 0;
                if (dir.X == correctDirectionToGoal.X && dir.X == 0)//stright line
                {
                    if (option.Contents == GameSlotStatus.Fuel)
                    {
                        score += 3;
                    }
                    else
                    {
                        score += 2 * scoreFactorX;
                    }
                }
                else if ((dir.X < 0 && correctDirectionToGoal.X < 0) || (dir.X > 0 && correctDirectionToGoal.X > 0))//correct direction
                {
                    score += 1 * scoreFactorX;
                }
                else if ((dir.X < 0 && correctDirectionToGoal.X > 0) || (dir.X > 0 && correctDirectionToGoal.X < 0))//oposite dir
                {
                    score += -1 * scoreFactorX;
                }

                if (dir.Y == correctDirectionToGoal.Y && dir.Y == 0)//stright line
                {
                    if (option.Contents == GameSlotStatus.Fuel)
                    {
                        score += 3;
                    }
                    else
                    {
                        score += 2 * scoreFactorY;
                    }
                }
                else if ((dir.Y < 0 && correctDirectionToGoal.Y < 0) || (dir.Y > 0 && correctDirectionToGoal.Y > 0))//correct direction
                {
                    score += 1 * scoreFactorY;
                }
                else if ((dir.Y < 0 && correctDirectionToGoal.Y > 0) || (dir.Y > 0 && correctDirectionToGoal.Y < 0))//oposite dir
                {
                    score += -1 * scoreFactorY;
                }
            }
            return(score);
        }