Created
August 30, 2013 02:42
-
-
Save artfoundry/6385837 to your computer and use it in GitHub Desktop.
Boggle, unfinished
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BoggleBoard | |
def initialize | |
@board = Array.new(4) {Array.new(4, Hash.new)} | |
@dice = Hash.new { | |
"die0" => "AAEEGN", | |
"die1" => "ELRTTY", | |
"die2" => "AOOTTW", | |
"die3" => "ABBJOO", | |
"die4" => "EHRTVW", | |
"die5" => "CIMOTU", | |
"die6" => "DISTTY", | |
"die7" => "EIOSST", | |
"die8" => "DELRVY", | |
"die9" => "ACHOPS", | |
"die10" => "HIMNQU", | |
"die11" => "EEINSU", | |
"die12" => "EEGHNW", | |
"die13" => "AFFKPS", | |
"die14" => "HLNNRZ", | |
"die15" => "DEILRX"} | |
end | |
def shake! | |
4.each do |row| | |
4.each do |col| | |
die_is_used = TRUE | |
while die_is_used | |
key = "die" + rand(16).to_s | |
if this key is not already used in a previous cell | |
die_is_used = FALSE | |
end | |
end | |
@board[row][col] = @dice.select(key)] | |
# looking_for_die = TRUE | |
# while looking_for_die | |
# 4.each do |rowchk| | |
# 4.each do |colchk| | |
# if board[rowchk][colchk].include?(key) | |
end | |
# Defining to_s on an object controls how the object is | |
# represented as a string, e.g., when you pass it to puts | |
# | |
# Override this to print out a sensible board format so | |
# you can write code like: | |
# | |
# board = BoggleBoard.new | |
# board.shake! | |
# puts board | |
def to_s | |
"omg what is this? try printing me." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment