From 4be7aa1a69280959b521c631cd076ad39b4c6ebf Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 10:16:17 -0700 Subject: [PATCH 01/10] implement basic game functionality --- word-guess-game.rb | 123 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 word-guess-game.rb diff --git a/word-guess-game.rb b/word-guess-game.rb new file mode 100644 index 0000000..64c9472 --- /dev/null +++ b/word-guess-game.rb @@ -0,0 +1,123 @@ +# Word Guess Game by Jennie +require 'random_word_generator' +# Gem dependency: gem install random-word-generator +# from https://rubygems.org/gems/random-word-generator/versions/0.0.1 + +# Define constant variables +MAX_ERRORS = 6 + +GAME_WIN = :win +GAME_LOSE = :lose +PLAYING = :playing + +# The game class includes the game logic +# Compare the guess to the word +# Keep track of the number of guesses + +class Game + attr_reader :secret_word, :guesses, :letters_matched, :errors + + def initialize + # Create random word using random word generator + @secret_word = RandomWordGenerator.of_length(8).downcase + # Array of the guesses so far + @guesses = [] + # Array of which letters have been correctly guessed in word + @letters_matched = ["-"] * @secret_word.length + # Number of errors + @errors = 0 + end + + # The method will determine which letters in the secret word match the guess + def find_matches(guess) + # Add the guess to the array of guesses + @guesses.push(guess) + num_matches = 0 + word_copy = @secret_word.split("") + while word_copy.include?(guess) do + match_index = word_copy.index(guess) + @letters_matched[match_index + num_matches] = guess + word_copy.slice!(match_index) + num_matches += 1 + end + # Returns the number of matches + # If there are no matches then add 1 to the number of errors + if num_matches == 0 + @errors += 1 + return false # Indicates there was no match + end + return true # Indicates there was a match + end + + def find_outcome + if @errors == MAX_ERRORS + return GAME_LOSE + elsif !@letters_matched.include?("-") + return GAME_WIN + end + return PLAYING + end + +end + +# The Gameboard class does everything related to output +class Gameboard + def initialize(game) + @game = game + end + + def print_gameboard + # Print how many errors are left in the form of Xes + print " x " * (MAX_ERRORS - @game.errors) + puts + # Print out the matched letters + @game.letters_matched.each do |letter| + print letter + " " + end + puts + # Print out the guesses so far + print "Your guesses so far: " + @game.guesses.each do |letter| + print letter + " " + end + puts + + end +end + + +# This method should set up the game +def play_word_guess + game = Game.new() + gameboard = Gameboard.new(game) + outcome = PLAYING + + while outcome != GAME_WIN && outcome != GAME_LOSE + gameboard.print_gameboard + # Get a new guess + print "Enter your letter guess: " + guess = gets.chomp.downcase + puts "The guess is #{guess}" + game.find_matches(guess) + outcome = game.find_outcome + if outcome == GAME_LOSE + puts "Sorry, you ran out of turns." + puts "The secret word was #{game.secret_word}" + elsif outcome == GAME_WIN + puts "You correctly guessed the secret word!" + end + end + + puts "Do you want to play again?" + response = gets.chomp.upcase + case response + when "1", "Y", "YES" + play_word_guess + else + puts "Thanks for playing Word Guess!" + exit + end +end + +# Start the game! +play_word_guess From 524fa276dc8123ccba40fb4705ec9130e02d6018 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 10:29:08 -0700 Subject: [PATCH 02/10] validate user input --- word-guess-game.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index 64c9472..567c4f5 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -97,14 +97,20 @@ def play_word_guess # Get a new guess print "Enter your letter guess: " guess = gets.chomp.downcase - puts "The guess is #{guess}" - game.find_matches(guess) - outcome = game.find_outcome - if outcome == GAME_LOSE - puts "Sorry, you ran out of turns." - puts "The secret word was #{game.secret_word}" - elsif outcome == GAME_WIN - puts "You correctly guessed the secret word!" + # Validate guess as input + if game.guesses.include?(guess) + puts "You have already entered that guess!" + elsif !('a'..'z').include?(guess) + puts "Invalid guess. Guesses must be a letter from a to z." + else + game.find_matches(guess) + outcome = game.find_outcome + if outcome == GAME_LOSE + puts "Sorry, you ran out of turns." + puts "The secret word was #{game.secret_word}" + elsif outcome == GAME_WIN + puts "You correctly guessed the secret word: #{game.secret_word.upcase}!" + end end end From 1b21db156224b6d130384438bc046a93135cfc3c Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 10:56:45 -0700 Subject: [PATCH 03/10] add birthday cake ascii art --- word-guess-game.rb | 124 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index 567c4f5..d86227c 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -62,13 +62,134 @@ def find_outcome # The Gameboard class does everything related to output class Gameboard + attr_reader :cakes def initialize(game) @game = game + # Array of birthday cake ascii art + @cakes = [""" + 0 0 + | | + ____|___|____ + 0 |~ ~ ~ ~ ~ ~| 0 + | | | | + ___|__|___________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + 0 | H a p p y | 0 + | |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| | + __|___|_______________________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | | + | B i r t h d a y! ! ! | + | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | + |___________________________________|""", + + """ + 0 + | + ________|____ + 0 |~ ~ ~ ~ ~ ~| 0 + | | | | + ___|__|___________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + 0 | H a p p y | 0 + | |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| | + __|___|_______________________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | | + | B i r t h d a y! ! ! | + | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | + |___________________________________|""", + + """ + + + _____________ + 0 |~ ~ ~ ~ ~ ~| 0 + | | | | + ___|__|___________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + 0 | H a p p y | 0 + | |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| | + __|___|_______________________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | | + | B i r t h d a y! ! ! | + | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | + |___________________________________|""", + + """ + + + _____________ + |~ ~ ~ ~ ~ ~| 0 + | | | + ______|___________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + 0 | H a p p y | 0 + | |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| | + __|___|_______________________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | | + | B i r t h d a y! ! ! | + | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | + |___________________________________|""", + """ + + + _____________ + |~ ~ ~ ~ ~ ~| + | | + ______|___________|______ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + 0 | H a p p y | 0 + | |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| | + __|___|_______________________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | | + | B i r t h d a y! ! ! | + | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | + |___________________________________|""", + + """ + + + _____________ + |~ ~ ~ ~ ~ ~| + | | + ______|___________|______ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | H a p p y | 0 + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| | + ______|_______________________|___|__ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | | + | B i r t h d a y! ! ! | + | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | + |___________________________________|""", + + """ + + + _____________ + |~ ~ ~ ~ ~ ~| + | | + ______|___________|______ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | W O R S T | + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + ______|_______________________|______ + |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| + | B i r t h d a y | + | E V E R! ! ! | + | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | + |___________________________________|""", + ] end def print_gameboard # Print how many errors are left in the form of Xes - print " x " * (MAX_ERRORS - @game.errors) + puts @cakes[@game.errors] +# print " x " * (MAX_ERRORS - @game.errors) puts # Print out the matched letters @game.letters_matched.each do |letter| @@ -106,6 +227,7 @@ def play_word_guess game.find_matches(guess) outcome = game.find_outcome if outcome == GAME_LOSE + puts gameboard.cakes[6] puts "Sorry, you ran out of turns." puts "The secret word was #{game.secret_word}" elsif outcome == GAME_WIN From 12df40f4abb870488d4395b7611b9f12bea9b6d0 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 11:38:03 -0700 Subject: [PATCH 04/10] add colors to output --- word-guess-game.rb | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index d86227c..7a0a850 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -2,6 +2,9 @@ require 'random_word_generator' # Gem dependency: gem install random-word-generator # from https://rubygems.org/gems/random-word-generator/versions/0.0.1 +require 'colorize' +# Gem dependency: gem install colorize +# from https://github.com/fazibear/colorize # Define constant variables MAX_ERRORS = 6 @@ -66,6 +69,7 @@ class Gameboard def initialize(game) @game = game # Array of birthday cake ascii art + # Original cake from http://www.myhairyass.com/ASCII/Art/?ID=20 @cakes = [""" 0 0 | | @@ -187,56 +191,63 @@ def initialize(game) end def print_gameboard - # Print how many errors are left in the form of Xes + # Print how many errors are left in the form of birthday cake ascii art puts @cakes[@game.errors] -# print " x " * (MAX_ERRORS - @game.errors) puts # Print out the matched letters + print "Secret word: ".colorize(:blue) @game.letters_matched.each do |letter| print letter + " " end puts + puts # Print out the guesses so far - print "Your guesses so far: " + print "Guesses so far: ".colorize(:blue) @game.guesses.each do |letter| print letter + " " end puts - + puts end end # This method should set up the game def play_word_guess + def clear_screen + print %x{clear} + end game = Game.new() gameboard = Gameboard.new(game) outcome = PLAYING - while outcome != GAME_WIN && outcome != GAME_LOSE + clear_screen gameboard.print_gameboard # Get a new guess - print "Enter your letter guess: " + print "Enter your guess: ".colorize(:blue) guess = gets.chomp.downcase # Validate guess as input if game.guesses.include?(guess) puts "You have already entered that guess!" + gets elsif !('a'..'z').include?(guess) puts "Invalid guess. Guesses must be a letter from a to z." + gets else game.find_matches(guess) outcome = game.find_outcome if outcome == GAME_LOSE + clear_screen puts gameboard.cakes[6] - puts "Sorry, you ran out of turns." - puts "The secret word was #{game.secret_word}" + puts "Sorry, you ran out of turns.".colorize(:red) + puts "The secret word was #{game.secret_word}".colorize(:blue) elsif outcome == GAME_WIN - puts "You correctly guessed the secret word: #{game.secret_word.upcase}!" + puts "You correctly guessed the secret word: #{game.secret_word.upcase}!".colorize(:blue) end end end - puts "Do you want to play again?" + puts "Do you want to play again?".colorize(:green) response = gets.chomp.upcase case response when "1", "Y", "YES" @@ -248,4 +259,9 @@ def play_word_guess end # Start the game! +clear_screen +puts "Welcome to the Birthday Cake Word Guess Game!".colorize(:red) +puts "For each incorrect guess, you lose a candle.".colorize(:red) +puts "When you run out of candles, your birthday is ruined.".colorize(:red) +gets play_word_guess From 055394f0d024d20a28eed3a8f025124d2f661a07 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 11:50:05 -0700 Subject: [PATCH 05/10] more aesthetics formatting --- word-guess-game.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index 7a0a850..24d15c3 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -47,9 +47,7 @@ def find_matches(guess) # If there are no matches then add 1 to the number of errors if num_matches == 0 @errors += 1 - return false # Indicates there was no match end - return true # Indicates there was a match end def find_outcome @@ -184,7 +182,7 @@ def initialize(game) ______|_______________________|______ |/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/| | B i r t h d a y | - | E V E R! ! ! | + | E V E R!!! | | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |___________________________________|""", ] @@ -214,14 +212,12 @@ def print_gameboard # This method should set up the game def play_word_guess - def clear_screen - print %x{clear} - end + print %x{clear} # Clears the terminal screen game = Game.new() gameboard = Gameboard.new(game) outcome = PLAYING while outcome != GAME_WIN && outcome != GAME_LOSE - clear_screen + print %x{clear} # Clears the terminal screen gameboard.print_gameboard # Get a new guess print "Enter your guess: ".colorize(:blue) @@ -237,10 +233,11 @@ def clear_screen game.find_matches(guess) outcome = game.find_outcome if outcome == GAME_LOSE - clear_screen + print %x{clear} # Clears the terminal screen puts gameboard.cakes[6] + puts puts "Sorry, you ran out of turns.".colorize(:red) - puts "The secret word was #{game.secret_word}".colorize(:blue) + puts "The secret word was ".colorize(:red) + "#{game.secret_word.upcase}".colorize(:blue) elsif outcome == GAME_WIN puts "You correctly guessed the secret word: #{game.secret_word.upcase}!".colorize(:blue) end @@ -259,7 +256,7 @@ def clear_screen end # Start the game! -clear_screen +print %x{clear} # Clears the terminal screen puts "Welcome to the Birthday Cake Word Guess Game!".colorize(:red) puts "For each incorrect guess, you lose a candle.".colorize(:red) puts "When you run out of candles, your birthday is ruined.".colorize(:red) From b1ddf17d548253a99f505d4b8c654ab092620863 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 12:00:51 -0700 Subject: [PATCH 06/10] add levels of difficulty --- word-guess-game.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index 24d15c3..1df102a 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -20,9 +20,9 @@ class Game attr_reader :secret_word, :guesses, :letters_matched, :errors - def initialize + def initialize(word_length) # Create random word using random word generator - @secret_word = RandomWordGenerator.of_length(8).downcase + @secret_word = RandomWordGenerator.of_length(word_length).downcase # Array of the guesses so far @guesses = [] # Array of which letters have been correctly guessed in word @@ -212,8 +212,24 @@ def print_gameboard # This method should set up the game def play_word_guess + level = 'foo' + while !['easy', 'medium', 'hard'].include?(level) + puts "What level would you like to play? [EASY, MEDIUM, HARD]".colorize(:green) + level = gets.chomp.downcase + if !['easy', 'medium', 'hard'].include?(level) + puts "Invalid level type." + end + end + case level + when "easy" + word_length = 12 + when "medium" + word_length = 9 + when "hard" + word_length = 6 + end print %x{clear} # Clears the terminal screen - game = Game.new() + game = Game.new(word_length) gameboard = Gameboard.new(game) outcome = PLAYING while outcome != GAME_WIN && outcome != GAME_LOSE @@ -260,5 +276,4 @@ def play_word_guess puts "Welcome to the Birthday Cake Word Guess Game!".colorize(:red) puts "For each incorrect guess, you lose a candle.".colorize(:red) puts "When you run out of candles, your birthday is ruined.".colorize(:red) -gets play_word_guess From 7b5b5cba62609a5daad5a3586d374f25ac36eb43 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 13:40:40 -0700 Subject: [PATCH 07/10] add feature: user can guess the whole world --- word-guess-game.rb | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index 1df102a..60e20d0 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -50,6 +50,15 @@ def find_matches(guess) end end + def check_guess(guess) + if guess == @secret_word + return GAME_WIN + else + @errors += 1 + return PLAYING + end + end + def find_outcome if @errors == MAX_ERRORS return GAME_LOSE @@ -205,7 +214,6 @@ def print_gameboard print letter + " " end puts - puts end end @@ -236,27 +244,35 @@ def play_word_guess print %x{clear} # Clears the terminal screen gameboard.print_gameboard # Get a new guess - print "Enter your guess: ".colorize(:blue) + puts "Enter a letter or type \"guess\" to guess the full word.".colorize(:blue) + print "Your guess: ".colorize(:blue) guess = gets.chomp.downcase # Validate guess as input if game.guesses.include?(guess) puts "You have already entered that guess!" gets + # Allow user to guess the full word + elsif guess == "guess" + print "Type in your guess for the full word: ".colorize(:blue) + guess = gets.downcase.strip + outcome = game.check_guess(guess) + # Check if guess is a letter from a to z elsif !('a'..'z').include?(guess) puts "Invalid guess. Guesses must be a letter from a to z." gets else game.find_matches(guess) outcome = game.find_outcome - if outcome == GAME_LOSE - print %x{clear} # Clears the terminal screen - puts gameboard.cakes[6] - puts - puts "Sorry, you ran out of turns.".colorize(:red) - puts "The secret word was ".colorize(:red) + "#{game.secret_word.upcase}".colorize(:blue) - elsif outcome == GAME_WIN - puts "You correctly guessed the secret word: #{game.secret_word.upcase}!".colorize(:blue) - end + end + # Check outcome of the round => GAME_LOSE, GAME_WIN, or PLAYING + if outcome == GAME_LOSE + print %x{clear} # Clears the terminal screen + puts gameboard.cakes[6] + puts + puts "Sorry, you ran out of turns.".colorize(:red) + puts "The secret word was ".colorize(:red) + "#{game.secret_word.upcase}".colorize(:blue) + elsif outcome == GAME_WIN + puts "You correctly guessed the secret word: #{game.secret_word.upcase}!".colorize(:blue) end end From 656a189e45bc65468418d69760afaed79a709d05 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 13:46:57 -0700 Subject: [PATCH 08/10] final edits: --- word-guess-game.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index 60e20d0..bcafb56 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -272,7 +272,7 @@ def play_word_guess puts "Sorry, you ran out of turns.".colorize(:red) puts "The secret word was ".colorize(:red) + "#{game.secret_word.upcase}".colorize(:blue) elsif outcome == GAME_WIN - puts "You correctly guessed the secret word: #{game.secret_word.upcase}!".colorize(:blue) + puts "You correctly guessed the secret word:".colorize(:red) + " #{game.secret_word.upcase}!".colorize(:blue) end end From aa04d4c9a71d361950c1033b68cbe6a4e28b75b5 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 14:31:56 -0700 Subject: [PATCH 09/10] add some comments to make code clearer --- word-guess-game.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index bcafb56..4229a75 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -50,6 +50,7 @@ def find_matches(guess) end end + # When the user tries to guess the entire word, this method checks the guess def check_guess(guess) if guess == @secret_word return GAME_WIN @@ -59,6 +60,7 @@ def check_guess(guess) end end + # At the end of each turn, this method checks whether there is win/loss def find_outcome if @errors == MAX_ERRORS return GAME_LOSE @@ -217,10 +219,10 @@ def print_gameboard end end - -# This method should set up the game +# This method sets up the game def play_word_guess level = 'foo' + # User chooses the level with input validation while !['easy', 'medium', 'hard'].include?(level) puts "What level would you like to play? [EASY, MEDIUM, HARD]".colorize(:green) level = gets.chomp.downcase @@ -228,6 +230,7 @@ def play_word_guess puts "Invalid level type." end end + # Length of the secret word depends on the level chosen case level when "easy" word_length = 12 @@ -261,6 +264,7 @@ def play_word_guess puts "Invalid guess. Guesses must be a letter from a to z." gets else + # In the case of a valid input: check matches, report the win/loss outcome game.find_matches(guess) outcome = game.find_outcome end From b57dfde018ddf2542b635ec9357a8ebc7af977e9 Mon Sep 17 00:00:00 2001 From: Jennie Buechner Date: Fri, 2 Oct 2015 14:41:31 -0700 Subject: [PATCH 10/10] bug fix when guessing word in last turn --- word-guess-game.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/word-guess-game.rb b/word-guess-game.rb index 4229a75..b72c661 100644 --- a/word-guess-game.rb +++ b/word-guess-game.rb @@ -56,7 +56,7 @@ def check_guess(guess) return GAME_WIN else @errors += 1 - return PLAYING + return find_outcome end end