Class: ImpUnit::MainAI

Inherits:
Object
  • Object
show all
Defined in:
lib/ImpUnit.rb

Overview

def self.manual

  end
end

Class Method Summary collapse

Class Method Details

.seedObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ImpUnit.rb', line 18

def self.seed
  number = 0

  options_list = File.read("options/option_list.txt").to_s.split(" ").shuffle

  # Candidate files
  candidate = File.read("candidate/algorithm_candidate.txt").strip.to_s

  # Bases iteration limit on options list size.
  size_limit = options_list.size.to_i

  # Iterate size limit times comparing option with candidate.
  size_limit.times do
    option = options_list[number]

    print "Candidate: #{candidate} Option: #{option} >>"

    if option == candidate
      puts " #{option} matches the candidate #{candidate}."

      # From matching candidate choose this script to write.
      open("exec.sh", "w") { |f|
        f.puts option.tr "V", " "
      }

      # Exit script
      abort
    else
      puts " #{option} does not match the candidate #{candidate}."
    end

    sleep(3)

    number = number + 1
  end
end