Exemple #1
0
 public void setStats(string _name, int _MaxHP, moves _move1, moves _move2, moves _move3, moves _move4, bool _isShiny, int _dex, string _dexSuffix, int _pp1, int _pp2, int _pp3, int _pp4, bool _isFemale, bool _hasSprite)
 {
     attackAffinity  = new int[18];
     defenseAffinity = new int[18];
     MaxHP           = _MaxHP;
     HP               = MaxHP;
     name             = _name;
     move1            = _move1;
     move2            = _move2;
     move3            = _move3;
     move4            = _move4;
     PP_move1         = _pp1;
     PP_move2         = _pp2;
     PP_move3         = _pp3;
     PP_move4         = _pp4;
     PP_move1_current = PP_move1;
     PP_move2_current = PP_move2;
     PP_move3_current = PP_move3;
     PP_move4_current = PP_move4;
     isShiny          = _isShiny;
     pokedex          = _dex;
     pokedexSuffix    = _dexSuffix;
     isFemale         = _isFemale;
     hasFemaleSprite  = _hasSprite;
     totalAffinity    = 0;
     currentMoveIndex = 0;
 }
Exemple #2
0
        public double resultOfMove(moves move)
        {
            int       distanceBefore = distanceToFood();
            int       scoreBefore    = score;
            moves     closestMove    = moves.Forward;
            SnakeGame temp           = (SnakeGame)this.Clone();

            temp.moveHead(move);
            int scoreAfter = temp.score;

            if (temp.gameOver == true)
            {
                return(-1.00);
            }
            if (scoreAfter > scoreBefore)
            {
                return(5.00);
            }
            if (temp.distanceToFood() < distanceBefore)
            {
                return(1.00);
            }

            return(0);
        }
        public async void enemyStrike()
        {
            updateStuff();
            await sleeper(3);

            bool didStrike = false;

            for (int i = 0; i < noobFighter.possibleMoves.Count(); i++)
            {
                int   index = rand.Next(0, noobFighter.possibleMoves.Count());
                moves move  = noobFighter.possibleMoves[index];
                if (noobFighter.energy - move.cost > -1)
                {
                    EnemyImgBox.Source = new BitmapImage(new Uri(move.spriteLocation));
                    char1.health       = char1.health - move.damage;
                    noobFighter.energy = noobFighter.energy - move.cost;
                    ChatBox.AppendText(noobFighter.name + " used " + move.name + "." + Environment.NewLine);
                    ChatBox.ScrollToEnd();
                    didStrike     = true;
                    userCanStrike = true;
                    break;
                }
                updateStuff();
                await sleeper(2);

                EnemyImgBox.Source = new BitmapImage(new Uri("../CodeDay/Amish ginger.png", UriKind.Relative));
            }
            if (didStrike == false)
            {
                winLose(true);
            }

            updateStuff();
        }
        public bool checkEnemyStats()
        {
            bool  okayorno = false;
            moves winner   = new moves();

            for (int i = 0; i < noobFighter.possibleMoves.Count(); i++)
            {
                if (i == 0)
                {
                    winner = noobFighter.possibleMoves[i];
                }
                else
                {
                    if (noobFighter.possibleMoves[i].cost <= winner.cost)
                    {
                        winner = noobFighter.possibleMoves[i];
                    }
                }
            }
            if (noobFighter.energy <= winner.cost)
            {
                okayorno = true;
            }
            if (noobFighter.health > 0)
            {
                okayorno = true;
            }

            if (noobFighter.energy == 0)
            {
                SkipButton.Visibility = System.Windows.Visibility.Visible;
            }
            return(okayorno);
        }
Exemple #5
0
    void ChangeCurrentMove()
    {
        if (currentMove == moves.place)
        {
            currentMove = moves.flip;
        }
        else if (currentMove == moves.flip)
        {
            currentMove = moves.move;
        }
        else if (currentMove == moves.move)
        {
            currentMove = moves.place;
        }

        UpdateActionSprite();
    }
Exemple #6
0
        private async void OriginButton_Click(object sender, RoutedEventArgs e)
        {
            if (userCanStrike == true)
            {
                if (MovesList.SelectedIndex != -1)
                {
                    moves currentMove = char1.possibleMoves[MovesList.SelectedIndex];
                    if (char1.energy - currentMove.cost > -1)
                    {
                        CharImgBox.Source = new BitmapImage(new Uri(currentMove.spriteLocation, UriKind.Relative));

                        noobFighter.health = noobFighter.health - currentMove.damage;
                        char1.energy       = char1.energy - currentMove.cost;
                        userCanStrike      = false;
                    }
                    else
                    {
                        MoveDescriptionBlock.Text = "YOU DON'T HAVE ENOUGH ENERGY!!!";
                    }
                }

                /*
                 * if (checkEnemyStats() == false)
                 * {
                 *  winLose(true);
                 * }
                 */


                if (userCanStrike == false)
                {
                    enemyStrike();
                }
            }
            else
            {
                MoveDescriptionBlock.Text = "Not your turn!";
            }

            updateStuff();
            await sleeper(2);

            CharImgBox.Source = new BitmapImage(new Uri("../CodeDay/Character/character.png", UriKind.Relative));
        }
Exemple #7
0
        public static wonDrawLost Beats(moves move1, moves move2)
        {
            var KeyBeatsValue = new Dictionary <moves, moves>
            {
                { moves.rock, moves.scissors },
                { moves.scissors, moves.paper },
                { moves.paper, moves.rock }
            };

            if (KeyBeatsValue[move1] == move2)
            {
                return(wonDrawLost.won);
            }
            if (KeyBeatsValue[move2] == move1)
            {
                return(wonDrawLost.lost);
            }
            return(wonDrawLost.draw);
        }
Exemple #8
0
 void move()
 {
     if (Input.GetAxisRaw("Horizontal") != 0)
     {
         if (Input.GetAxisRaw("Horizontal") > 0)
         {
             if (!coliding)
             {
                 GetComponent <Transform>().Translate(Vector2.right * Time.deltaTime * step);
                 last_move = moves.RIGHT;
             }
         }
         else
         {
             if (!coliding)
             {
                 GetComponent <Transform>().Translate(Vector2.left * Time.deltaTime * step);
                 last_move = moves.LEFT;
             }
         }
     }
     if (Input.GetAxisRaw("Vertical") != 0)
     {
         if (Input.GetAxisRaw("Vertical") > 0)
         {
             if (GetComponent <Transform>().position.y < max_y.position.y)
             {
                 transform.Translate(Vector2.up * Time.deltaTime * step);
             }
         }
         else
         {
             if (GetComponent <Transform>().position.y > min_y.position.y)
             {
                 transform.Translate(Vector2.down * Time.deltaTime * step);
             }
         }
     }
 }
        public bool checkUserStats()
        {
            bool okayorno = false;

            if (char1.health > 0)
            {
                okayorno = true;
            }
            moves winner = new moves();

            for (int i = 0; i < char1.possibleMoves.Count(); i++)
            {
                if (i == 0)
                {
                    winner = char1.possibleMoves[i];
                }
                else
                {
                    if (char1.possibleMoves[i].cost <= winner.cost)
                    {
                        winner = char1.possibleMoves[i];
                    }
                }
            }

            if (char1.energy < winner.cost)
            {
                okayorno = true;
                SkipButton.Visibility = System.Windows.Visibility.Visible;
            }
            if (char1.energy == 0)
            {
                SkipButton.Visibility = System.Windows.Visibility.Visible;
            }
            return(okayorno);
        }
Exemple #10
0
 public Round(moves inUserMove, moves inCpuMove)
 {
     this._userMove = inUserMove;
      this._cpuMove = inCpuMove;
 }
Exemple #11
0
 var(moves, len) = BitBoardUtils.GetAllMovesetIndecies(board, colour, out ChessPiece[] ids);
Exemple #12
0
    IEnumerator MakeAIMove(tile chosenTile, List <tile> sortedTiles, int moveChoiceIndex = 0)
    {
        if (state != states.ending)
        {
            Debug.Log("AI aiming to go to " + chosenTile.tilePos.x + ", " + chosenTile.tilePos.y);
            float defaultWait = 0.2f;
            state = states.transitioning;
            yield return(new WaitForSeconds(defaultWait));

            // is current tile the right tile?
            bool targetReached = false;
            while (!targetReached)
            {
                if (chosenTile.tilePos == selectorPos)
                {
                    Debug.Log("AI target tile reached");
                    targetReached = true;
                    // in the right tile, so make the right move
                    yield return(new WaitForSeconds(defaultWait));

                    currentMove = chosenTile.moveType[player - 1];
                    UpdateActionSprite();
                    yield return(new WaitForSeconds(defaultWait));

                    if (currentMove != moves.move)
                    {
                        if (DoAction(selectorPos))
                        {
                            Debug.Log("AI " + player + " move made");
                        }
                        else
                        {
                            // for some reason, this move was invalid - so choose the next move
                            targetReached = false;
                            moveChoiceIndex++;
                            chosenTile = sortedTiles[moveChoiceIndex];
                        }
                    }
                    else if (currentMove == moves.move)
                    {
                        // Do something clever for actually moving stacks...
                        if (MoveStack(selectorPos))
                        {
                            state = states.moving;
                        }
                    }
                }
                else
                {
                    // figure out x and y differences
                    int xDiff = (int)(selectorPos.x - chosenTile.tilePos.x);
                    int yDiff = (int)(selectorPos.y - chosenTile.tilePos.y);
                    Debug.Log("xDiff " + xDiff + ", yDiff " + yDiff);

                    // make appropriate move and then wait
                    Debug.Log("AI " + player + " making move...");
                    if (xDiff < 0)
                    {
                        MakeMove(new Vector2(1, 0));
                    }
                    else if (xDiff > 0)
                    {
                        MakeMove(new Vector2(-1, 0));
                    }
                    else if (yDiff < 0)
                    {
                        MakeMove(new Vector2(0, 1));
                    }
                    else if (yDiff > 0)
                    {
                        MakeMove(new Vector2(0, -1));
                    }

                    yield return(new WaitForSeconds(defaultWait));
                }
            }
            StartCoroutine("FinishTurn");
        }
    }
Exemple #13
0
        //Call this method with the appropraite move and it will do all the heavy lifting :)
        public void moveHead(moves move)
        {
            int[] headPos = snakeBody[0];
            headPosY = headPos[0];
            headPosX = headPos[1];
            int[]     tailPos      = snakeBody[snakeBody.Count - 1];
            Direction newDirection = curDirection;

            switch (curDirection)
            {
            case Direction.Up:

                if (move == moves.Forward)
                {
                    newDirection = curDirection;
                }
                if (move == moves.Right)
                {
                    newDirection = Direction.Right;
                }
                if (move == moves.Left)
                {
                    newDirection = Direction.Left;
                }
                break;

            case Direction.Down:

                if (move == moves.Forward)
                {
                    newDirection = Direction.Down;
                }
                if (move == moves.Right)
                {
                    newDirection = Direction.Left;
                }
                if (move == moves.Left)
                {
                    newDirection = Direction.Right;
                }
                break;

            case Direction.Right:


                if (move == moves.Forward)
                {
                    newDirection = curDirection;
                }
                if (move == moves.Right)
                {
                    newDirection = Direction.Down;
                }
                if (move == moves.Left)
                {
                    newDirection = Direction.Up;
                }
                break;

            case Direction.Left:

                if (move == moves.Forward)
                {
                    newDirection = curDirection;
                }
                if (move == moves.Right)
                {
                    newDirection = Direction.Up;
                }
                if (move == moves.Left)
                {
                    newDirection = Direction.Down;
                }
                break;
            }
            MakeMove(newDirection);
            setAreaAroundHead();
        }
Exemple #14
0
 void SetTileMove(int playerIndex, tile t, int moveWeight, moves move)
 {
     t.moveWeights[playerIndex] = moveWeight;
     t.moveType[playerIndex]    = move;
 }
Exemple #15
0
        //Adjust difficulty based on map difficulty
        public void adjustDifficulty()
        {
            LevelUp levelUp = new LevelUp();
            int     sum     = 0;

            for (int x = 0; x < difficulty * 20; x++)
            {
                newPokemon.attackAffinity[rng.Next(0, 17) + 1]++;
                newPokemon.defenseAffinity[rng.Next(0, 17) + 1]++;
            }
            foreach (int x in newPokemon.attackAffinity)
            {
                sum += x;
            }
            foreach (int x in newPokemon.defenseAffinity)
            {
                sum += x;
            }
            for (int x = 0; x < difficulty; x++)
            {
                switch (rng.Next(0, 7) + 1)
                {
                case 1:
                    newPokemon.atk++;
                    break;

                case 2:
                    newPokemon.satk++;
                    break;

                case 3:
                    newPokemon.def++;
                    break;

                case 4:
                    newPokemon.sdef++;
                    break;

                case 5:
                    newPokemon.MaxHP++;
                    newPokemon.HP++;
                    break;

                case 6:
                    newPokemon.spd++;
                    break;

                case 7:
                    newPokemon.evade++;
                    break;

                default:
                    Console.WriteLine("WTF stat are you trying to improve?");
                    break;
                }
                moves moveToLearn = levelUp.moveCheck(newPokemon.startAffinity - sum, newPokemon.pokedex, newPokemon.currentMoveIndex);
                if (moveToLearn.name != "blank")
                {
                    if (newPokemon.move3.name != "NONE")
                    {
                        if (newPokemon.move4.name != "NONE")
                        {
                            newPokemon.move1 = newPokemon.move2;
                            newPokemon.move2 = newPokemon.move3;
                            newPokemon.move3 = newPokemon.move4;
                            newPokemon.move4 = moveToLearn;
                        }
                        else
                        {
                            newPokemon.move4 = moveToLearn;
                        }
                    }
                    else
                    {
                        newPokemon.move3 = moveToLearn;
                    }
                    newPokemon.currentMoveIndex++;
                }
            }
        }
Exemple #16
0
 void Start()
 {
     move = GameObject.FindObjectOfType <moves>();
 }
Exemple #17
0
 public CharacterMoves(moves move, string nameOfAttack, int value)
 {
     this.attackDebuffOrBuff = move;
     this.nameOfAttack       = nameOfAttack;
     this.value = value;
 }
Exemple #18
0
        static void Main(string[] args)
        {
            /*
             * ConsoleKey input;
             * SnakeGame sTest = new SnakeGame(20, 20);
             *
             * SnakeGame snakeyBoi = new SnakeGame((SnakeGame)sTest.Clone());
             * //snakeyBoi = (SnakeGame)sTest.Clone();
             * snakeyBoi.DisplayBoard();
             * snakeyBoi.curDirection = Direction.Right;
             *
             * while (snakeyBoi.gameOver == false)
             * {
             *  moves move = moves.Forward;
             *  Stopwatch timer = new Stopwatch();
             *  timer.Start();
             *  while (timer.Elapsed.TotalMilliseconds < 100)
             *  {
             *      if (Console.KeyAvailable)
             *      {
             *          input = Console.ReadKey().Key;
             *          if (input == ConsoleKey.UpArrow)
             *          {
             *              move = moves.Forward;
             *          }
             *
             *          if (input == ConsoleKey.LeftArrow)
             *          {
             *              move = moves.Left;
             *          }
             *          if (input == ConsoleKey.RightArrow)
             *          {
             *              move = moves.Right;
             *          }
             *      }
             *  }
             *  timer.Stop();
             *  snakeyBoi.moveHead(move);
             *  snakeyBoi.DisplayBoard();
             * }
             * Console.WriteLine("Game OVER!!");
             *
             * Console.ReadLine();
             * Console.Clear();
             * sTest.DisplayBoard();
             * Console.ReadLine();
             */
            SnakeGame snakeyBoi = new SnakeGame(10, 10);

            snakeyBoi.curDirection = Direction.Right;
            while (snakeyBoi.gameOver == false)
            {
                double resultForward = snakeyBoi.resultOfMove(moves.Forward);
                double resultLeft    = snakeyBoi.resultOfMove(moves.Left);
                double resultRight   = snakeyBoi.resultOfMove(moves.Right);
                moves  move          = moves.Right;
                if (resultForward > resultLeft)
                {
                    if (resultForward > resultRight)
                    {
                        move = moves.Forward;
                    }
                }
                else
                {
                    if (resultLeft > resultRight)
                    {
                        move = moves.Left;
                    }
                }
                snakeyBoi.moveHead(move);
                snakeyBoi.DisplayBoard();
                System.Threading.Thread.Sleep(1000);
            }
            snakeyBoi.DisplayBoard();
            Console.WriteLine("Game OVER!!");
            Console.ReadLine();

            /*
             * GAClass ga = new GAClass(snakeyBoi);
             * NeuralNetwork bestnn = ga.population[5];
             * //NeuralNetwork bestnn = ga.bestNN();
             * Stopwatch timer = new Stopwatch();
             * Console.Clear();
             * while (snakeyBoi.gameOver == false)
             * {
             *
             *  moves move = bestnn.calculateDirection(snakeyBoi.getInputs());
             *  snakeyBoi.moveHead(move);
             *  snakeyBoi.DisplayBoard();
             *  System.Threading.Thread.Sleep(1000);
             *
             * }
             *
             * snakeyBoi.DisplayBoard();
             * Console.WriteLine("Game OVER!!");
             * Console.ReadLine();
             */
        }