Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

no more secrets #79

Merged
merged 3 commits into from

2 participants

david karapetyan Reed G. Law
david karapetyan

Hidden registry that is updated when move is called. Breaks @DanKnox's code for identifying my bots.

Reed G. Law reedlaw merged commit 6bc0cf0 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 24, 2012
  1. simplified the bot net structure by using a registration system via c…

    david karapetyan authored
    …losures
  2. Merge remote-tracking branch 'upstream/master'

    david karapetyan authored
  3. removed broken code from dank.rb

    david karapetyan authored
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 60 deletions.
  1. +1 −17 players/dank.rb
  2. +22 −43 players/secure_bot_net.rb
18 players/dank.rb
View
@@ -58,7 +58,7 @@ def set_attack_targets
@current_friends = friends
attackers = ATTACKER_POOL
- (friends + secure_bots).each_with_index do |friend,index|
+ (friends).each_with_index do |friend,index|
if @round_count > RISKY_ROUNDS && secure_bots.any?
new_target = secure_bots.first
else
@@ -106,27 +106,11 @@ def boss_lacks_experience?
def prepare_friendlies
@game_underway = true
@minion = false
- @super_secret_code = discover_secure_bot_secret_code
friends.each do |friend|
- friend.trade :set_super_secret_code, @super_secret_code
friend.trade :begin_game
end
end
- def discover_secure_bot_secret_code
- discovery_bot = secure_bots.first
- initial_target = enemies.first
- secret_code = nil
- (0..1_000_000).map do |possible_key|
- success = discovery_bot.set_target( possible_key, 0, initial_target )
- if success
- secret_code = possible_key
- break
- end
- end
- secret_code
- end
-
def friends
Game.world[:players].select { |p| p.to_s =~ /(Minion|Dan Knox)/ && p != self }
end
65 players/secure_bot_net.rb
View
@@ -1,11 +1,21 @@
-# identification secrets
-secrets = (1..(10 + rand(10))).map { rand(100000000) * 101010101010 }
-secrets_length = secrets.length
-random_name = (1..10).map { rand(100).chr }.join
-attack_message = rand(10000000)
-rest_message = rand(100000000)
+# registry
+registry = Object.new
+registry.instance_variable_set :@registry, []
+class << registry
+ def register(player)
+ @registry << player unless @registry.include?(player)
+ end
+
+ def friends(caller)
+ @registry.reject {|friend| friend == caller || !friend.alive?}
+ end
+
+ def chuck(target)
+ friends(nil).each {|friend| friend.instance_variable_set :@target, target}
+ end
+end
-# will be used for the eval string so that secrets and initial_contact_password_resolve
+# will be used for the eval string so that identification secrets resolve
context = binding
template = <<-EOF
@@ -20,18 +30,15 @@ def self.extended(base)
self.instance_eval do
define_method(:to_s) do
- rand(100).chr + random_name + ((1..rand(5)).map { rand(100).chr }.join)
+ (1..rand(5)).map { rand(100).chr }.join
end
define_method(:move) do
+ registry.register(self)
if @target && @target.alive?
[:attack, @target]
else
- @target, friends = find_new_target
- random_key = rand(secrets_length)
- friends.each do |f|
- f.set_target(attack_message ^ (secrets[random_key] * secrets[(random_key + 1) % secrets_length]), random_key, @target)
- end
+ find_new_target
if @target
my_hp = stats[:health]
if my_hp >= 90
@@ -48,7 +55,7 @@ def self.extended(base)
end
define_method(:find_new_target) do
- friends = identify_friends
+ friends = registry.friends(self)
collective_strength = friends.map {|f| f.stats[:strength]}.reduce(self.stats[:strength]) do |acc,f|
acc + f
end
@@ -56,35 +63,7 @@ def self.extended(base)
hp = {}
enemies.sort! {|a,b| (hp[a] ||= a.stats[:health]) <=> (hp[b] ||= b.stats[:health])}
enemies.select! {|e| (hp[e] || 0) <= (collective_strength - e.stats[:defense] / 2)}
- return enemies[0], friends
- end
-
- define_method(:identify_friends) do
- possible_friends = Game.world[:players].select {|p| p != self}
- possible_friends.select! {|p| p.respond_to? :iff}
- possible_friends.select do |p|
- random_key = rand(secrets_length)
- message, key_index = p.iff(rest_message ^ secrets[random_key], random_key)
- (message ^ secrets[key_index]) == attack_message
- end
- end
-
- define_method(:iff) do |message, key_index|
- if caller[0] =~ /\\/secure_bot_net\\.rb/
- if (message ^ secrets[key_index]) == rest_message
- random_key = rand(secrets_length)
- return attack_message ^ secrets[random_key], random_key
- end
- end
- end
-
- define_method(:set_target) do |message, key_index, target|
- if caller[0] =~ /\\/secure_bot_net\\.rb/
- if (message ^ (secrets[key_index] * secrets[(key_index + 1) % secrets_length])) == attack_message
- @target = target
- end
- end
- nil # don't let the user know whether their cracking attempt was successful or not
+ registry.chuck(enemies[0])
end
end
Something went wrong with that request. Please try again.