Ad
  • Custom User Avatar

    Here's an explanation of this Kata:

    This Kata has far more information than necessary in order to solve it, and is fairly simple once you understand what you are supposed to do. Your task is to complete the AI() function to create a very simplistic "AI" that plays a game.

    The AI() function has one parameter, which is named "game" by default. There are two different methods you can use on this parameter to get information about the game, inspectTG() and status(). Both of these methods return objects.

    inspectTG() returns an object of the form:

    {
      lives: integer,
      currentLevel: integer,
      objects: [Object, Object, ...]
    }
    

    The objects in the objects array are of the following form:

    {
      type: string,
      location: [float, float],
      height: float
    }
    

    In this array, you will find an object with a type of "goal". The location array contains two float values which tell you the left and right borders of the "goal" object. Negative values indicate that the goal is to the left of your player, and positive values indicate it is to the right. Your objective is to navigate to this object through the use of the press() method. Arguments passed to the press() method should contain at least one of the following commands, with each command followed by a number:

    Command Result
    "←" or "<" Move left
    "→" or ">" Move right
    "X" or "x" Attempt to complete level

    Each of the commands should be followed by either an integer or a float that indicates how long the "movement button" should be pushed in seconds. Each second will move the player 10 units in whichever direction is indicated, or if the command is an "X" or an "x", the "button" needs to be pressed for a minimum of 1 second when the player is located within the bounds of the "goal" in order to complete the level. Multiple commands can be strung together and passed as a single parameter in the form of a string, and the game will process them in the order they appear. Each command has two options that can be used interchangeably. There is no difference.

    Example:

    game.press("←3.5>4x1");
    

    The first part, "←3.5" will cause the player to first move to the left for 3.5 seconds, at a speed of 10 units per second, so the player will move a total of 350 units left. Then the player will move right for 4 seconds (">4"), again at a speed of 10 units per second, so the player will move a total of 400 units right (ending up 50 units to the right of their original position). The level complete button will then be pushed for one second ("x1"). If the level complete button is pushed when the player is not within the bounds of the goal, the player will die. If the button is pushed when the player is within the bounds of the goal, then the player will proceed to the next level, unless they are on the final level, in which case they will win the game.

    The AI() function must guide the player through every level successfully in order to pass this Kata. In order to determine how many levels remain, you can make use of the status() function mentioned earlier which will return an object of the form:

    {
      lives: integer,
      currentLevel: integer,
      level_status: [boolean, boolean, ...]
      // true means the level was cleared, false means it wasn't
    }
    

    You can either use this method, or the fact that both the inspectTG() method and the push() method will return "All Cleared!" when you have completed all of the levels in order to determine whether there are more levels remaining.

  • Custom User Avatar

    I don't want to be too hard on the creator of this Kata, because I get the impression that they put a fair amount of work into creating this, and I know it is an extra challenge to write instructions in a second language, because it's very clear that English is not their first language, but after reading over the instructions several times I still have absolutely no idea what I'm supposed to be doing. I guess I'll come back to this Kata eventually for the sake of completion and figure it out through trial and error, but simply interpreting the instructions alone feels like a challenge worthy of a 1 KYU-ranked Kata, and I don't have the motivation for that right now.

  • Custom User Avatar

    very short way. it's great.

  • Custom User Avatar

    This kata should be retired or limit raised to 50 chars.
    As in order to solve it, one has to use deprecated language features (and it is the ONLY solution to the kata).

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    The entire solution must be less than 30 characters, that includes function declaration.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    stranded at 55. tough kata

  • Custom User Avatar

    This one is completely crazy... for a 5 kyu (less than 30 completions in 6 years)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Try solving the "least solved" 7 kyu's ... many are like this

  • Custom User Avatar
  • Custom User Avatar

    No comments ... I guess everyone else understands what we are supposed to do here o_O

  • Custom User Avatar

    Would you help updating it to Node 18.x?

    It might be as simple as requiring chai before nuking require, and changing tests from Test to chai.

  • Custom User Avatar

    This kata needs updating from Node 10.x. It is one of the very last in that Node version, preventing complete removal of that version.

  • Loading more items...