Skip to content

Instantly share code, notes, and snippets.

@tra38
Last active November 7, 2015 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tra38/0064c227a298d7f51c11 to your computer and use it in GitHub Desktop.
Save tra38/0064c227a298d7f51c11 to your computer and use it in GitHub Desktop.
This does not actually simulate the conflicted commerce and trading patterns of a city, but would you be able to tell the difference?
#This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# For more information, please refer to <http://unlicense.org/>
require 'faker'
f = File.open('text.md', 'w')
# ###Reference: https://www.ruby-forum.com/topic/2298391. Point is to log output to a text file
# #for debugging purposes.
old_out = $stdout
$stdout = f
###
non_betrayal_action = {
"eat a hamburger" => "produce the best hamburger known to man",
"learn Haskell" => "teach him Haskell",
"build a house" => "come up with a blueprint for the house",
"hack into a super-computer mainframe" => "sell Zero-Day vulnerabilities",
"buy a book" => "give a list of all the best books in the city",
"understand the meaning of the Golden Falcon" => "produce a peer-reviewed paper showing the history of the Golden Falcon"
}
betrayal_action = {
"murder" => "kill the victim and make it look like an accident",
"blackmail" => "gather evidence on the victim",
"steal money from" => "break into the victim's house and steal the valuables"
}
def did_wrong_thing
["'gave me a counterfeit, worthless Falcon'", "'did not thank me for my valuable service'","'forced me to write ugly code'"].sample
end
past_person = "#{Faker::Name.name}"
current_person = "#{Faker::Name.name}"
next_person = "#{Faker::Name.name}"
action = nil
past_action = nil
counter = 0
puts "One day, #{past_person} decided to send his/her best friend, #{current_person}, a gift. #{current_person} received a Golden Falcon."
while counter <= 10
personality = rand(1..2)
if personality == 1 #does not want to betray his friend
until action != past_action
action = non_betrayal_action.keys.sample
end
puts "#{current_person} desired to #{action}."
puts "#{current_person} knew of a person (#{next_person}) who would #{non_betrayal_action[action]}."
else #wants to betray his best friend
until action != past_action
action = betrayal_action.keys.sample
end
puts "#{current_person} wanted to #{action} #{past_person} because #{past_person} #{did_wrong_thing}."
puts "#{current_person} knew of a person (#{next_person}) who would #{betrayal_action[action]}."
end
puts "#{current_person} decided to trade the Golden Falcon for this valuable service.\n"
past_person = current_person
current_person = next_person
past_action = action
next_person = "#{Faker::Name.name}"
counter += 1
end
puts "#{current_person} was hungry. #{current_person} decided to eat the Golden Falcon."
##Reference: https://www.ruby-forum.com/topic/2298391, point is to close the File once you have
##finished logging everything you want to log.
f.close
$stdout = old_out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment