<commit_before>#!/usr/bin/ruby

class ElGame
  def send(msg)
    # Send the text to the sockets
    response = $telnet.send_and_rec(msg)

    print response if !$config.opt["vt102_debug"]

    # Parse the message
    $vt102.process(response)

    response = $vt102.row_text(0)

    # Check to see if we overflowed to the next line.
    if $vt102.y == 1 && $vt102.x == $vt102.row_text(1).sub(/\s*/, "").length && $vt102.row_text(1) =~ / --More-- \s* $ /x
      response += $vt102.row_text(1)
    end

    # If we see a --More-- or a (# of #) message, we send spaces and grab the whole message as a large chunk to return.
    if response.sub!(/ --More--       \s* $ /x, "") or 
       response.sub!(/ \(\d+ of \d+\) \s* $ /x, "")
      response += send(" ")
    end

    # For simplicity, collapse all consecutive whitespace into one space.
    response.sub!(/\s+/, " ")

    return response
  end

  def check_botl()
    bota = $vt102.row_text(22)
    botb = $vt102.row_text(23)

    if not bota =~ /
                     St:(\d+) \s+
                     Dx:(\d+) \s+
                     Co:(\d+) \s+
                     In:(\d+) \s+
                     Wi:(\d+) \s+
                     Ch:(\d+) \s+
                     (Lawful|Neutral|Chaotic) \s+
                     (S:(\d+))?
                   /x
      raise "Unable to parse the following bota: " + bota
    end

    @str = $1
    @dex = $2
    @con = $3
    @int = $4
    @wis = $5
    @cha = $6
    # @align = $7
    @score = $9 if $8

    if not botb =~ /
                     (
                       Dlvl:\d+      \s+
                       |
                       Home \s+ \d+  \s+
                       |
                       End \s+ Game  \s+
                     )
                     $:(\d+)         \s+
                     HP:(\d+)\(\d+\) \s+
                     Pw:(\d+)\(\d+\) \s+
                     AC:(-?\d+)      \s+
                     (
                       Xp:\d+\/\d+   \s+
                       |
                       Exp:\d+       \s+
                     )
                     (T:(\d+))?
                   /x
      raise "Unable to parse the following botb: " + botb
    end

     dlvl  = $1
    @gold  = $2
    @curhp = $3
    @maxhp = $4
    @curpw = $5
    @maxpw = $6
    @ac    = $7
     exp   = $8
    @turn  = $10 if $9

    if not dlvl =~ /
                     Dlvl:(\d+)     \s+
                     |
                     Home \s+ (\d+) \s+
                     |
                     End \s+ Game   \s+
                   /x
      raise "Unable to parse the following dlvl string: " + dlvl
    end

    if    $1
      @dl = $1
    elsif $2
      @dl = @level["QuestPortal"] + $1
    else
      @dl = nil
    end

    if not exp =~ /
                    Xp:(\d+)\/(\d+) \s+
                    |
                    Exp:(\d+)     \s+
                  /x
      raise "Unable to parse the following exp string: " + exp
    end

    if $1 and $2
      @xl  = $1
      @exp = $2
    else
      @xl  = $3
      @exp = nil
    end
  
end

if __FILE__ == $0
  require "../utils/assert.rb"

  puts "unit test succeeded"
end
<commit_msg>Add an "end" which now lets EliteBot run again.<commit_after>#!/usr/bin/ruby

class ElGame
  def send(msg)
    # Send the text to the sockets
    response = $telnet.send_and_rec(msg)

    print response if !$config.opt["vt102_debug"]

    # Parse the message
    $vt102.process(response)

    response = $vt102.row_text(0)

    # Check to see if we overflowed to the next line.
    if $vt102.y == 1 && $vt102.x == $vt102.row_text(1).sub(/\s*/, "").length && $vt102.row_text(1) =~ / --More-- \s* $ /x
      response += $vt102.row_text(1)
    end

    # If we see a --More-- or a (# of #) message, we send spaces and grab the whole message as a large chunk to return.
    if response.sub!(/ --More--       \s* $ /x, "") or 
       response.sub!(/ \(\d+ of \d+\) \s* $ /x, "")
      response += send(" ")
    end

    # For simplicity, collapse all consecutive whitespace into one space.
    response.sub!(/\s+/, " ")

    return response
  end

  def check_botl()
    bota = $vt102.row_text(22)
    botb = $vt102.row_text(23)

    if not bota =~ /
                     St:(\d+) \s+
                     Dx:(\d+) \s+
                     Co:(\d+) \s+
                     In:(\d+) \s+
                     Wi:(\d+) \s+
                     Ch:(\d+) \s+
                     (Lawful|Neutral|Chaotic) \s+
                     (S:(\d+))?
                   /x
      raise "Unable to parse the following bota: " + bota
    end

    @str = $1
    @dex = $2
    @con = $3
    @int = $4
    @wis = $5
    @cha = $6
    # @align = $7
    @score = $9 if $8

    if not botb =~ /
                     (
                       Dlvl:\d+      \s+
                       |
                       Home \s+ \d+  \s+
                       |
                       End \s+ Game  \s+
                     )
                     $:(\d+)         \s+
                     HP:(\d+)\(\d+\) \s+
                     Pw:(\d+)\(\d+\) \s+
                     AC:(-?\d+)      \s+
                     (
                       Xp:\d+\/\d+   \s+
                       |
                       Exp:\d+       \s+
                     )
                     (T:(\d+))?
                   /x
      raise "Unable to parse the following botb: " + botb
    end

     dlvl  = $1
    @gold  = $2
    @curhp = $3
    @maxhp = $4
    @curpw = $5
    @maxpw = $6
    @ac    = $7
     exp   = $8
    @turn  = $10 if $9

    if not dlvl =~ /
                     Dlvl:(\d+)     \s+
                     |
                     Home \s+ (\d+) \s+
                     |
                     End \s+ Game   \s+
                   /x
      raise "Unable to parse the following dlvl string: " + dlvl
    end

    if    $1
      @dl = $1
    elsif $2
      @dl = @level["QuestPortal"] + $1
    else
      @dl = nil
    end

    if not exp =~ /
                    Xp:(\d+)\/(\d+) \s+
                    |
                    Exp:(\d+)     \s+
                  /x
      raise "Unable to parse the following exp string: " + exp
    end

    if $1 and $2
      @xl  = $1
      @exp = $2
    else
      @xl  = $3
      @exp = nil
    end
  end
end

if __FILE__ == $0
  require "../utils/assert.rb"

  puts "unit test succeeded"
end

{'fraction_non_alphanumeric': 0.14981806676158835, 'fraction_numerical': 0.021831988609397248, 'mean_word_length': 0.9180825242718447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4072639', 'n_tokens_mistral': 2288, 'n_tokens_neox': 2086, 'n_words': 579}