{
  "format": "tokbit",
  "version": 1,
  "name": "Guess in 7 tries",
  "main": [
    {
      "id": "u1",
      "kind": "declare",
      "name": "secret",
      "type": "int",
      "init": "randint(1, 100)"
    },
    {
      "id": "u2",
      "kind": "declare",
      "name": "guess",
      "type": "int",
      "init": "0"
    },
    {
      "id": "u3",
      "kind": "declare",
      "name": "tries",
      "type": "int",
      "init": "0"
    },
    {
      "id": "u4",
      "kind": "output",
      "values": "\"I'm thinking of a number from 1 to 100.\""
    },
    {
      "id": "u5",
      "kind": "while",
      "condition": "guess != secret and tries < 7",
      "body": [
        {
          "id": "u6",
          "kind": "input",
          "target": "guess",
          "prompt": "Your guess:"
        },
        {
          "id": "u7",
          "kind": "assign",
          "target": "tries",
          "value": "tries + 1"
        },
        {
          "id": "u8",
          "kind": "if",
          "condition": "guess < secret",
          "then": [
            {
              "id": "u9",
              "kind": "output",
              "values": "\"Higher.\""
            }
          ],
          "else": [
            {
              "id": "u10",
              "kind": "if",
              "condition": "guess > secret",
              "then": [
                {
                  "id": "u11",
                  "kind": "output",
                  "values": "\"Lower.\""
                }
              ],
              "else": []
            }
          ]
        }
      ],
      "comment": "Repeats until the guess is right; we do not know how many rounds."
    },
    {
      "id": "u12",
      "kind": "if",
      "condition": "guess == secret",
      "then": [
        {
          "id": "u13",
          "kind": "output",
          "values": "\"You got it! Guesses:\", tries"
        }
      ],
      "else": [
        {
          "id": "u14",
          "kind": "output",
          "values": "\"Out of guesses. I was thinking of\", secret"
        }
      ]
    }
  ],
  "functions": [],
  "comment": "Solution to the task “Only seven guesses”: The player has only 7 guesses. If they miss, the program tells the number. (The task from the Lesson with Tokbit.)",
  "screen": "fit"
}
