Code Monkey home page Code Monkey logo

ruby-warrior's Introduction

Ruby Warrior

This is a game designed to teach the Ruby language in a fun and interactive way.

You play as a warrior climbing a tall tower to reach the precious Ruby at the top level. On each floor you need to write a Ruby script to instruct the warrior to battle enemies, rescue captives, and reach the stairs. You have some idea of what each floor contains, but you never know for certain what will happen. You must give the Warrior enough artificial intelligence up-front to find his own way.

Note: The player directory structure changed on July 18, 2009. If you have an old profile using the level-00* structure then move the contents of the last level into the parent directory.

Getting Started

First install the gem.

gem install rubywarrior

As of version 0.2.0, this gem has been updated to work with Ruby 3.3. If you have difficulty running it in an older version of Ruby, try using an older version of the gem.

Then run the rubywarrior command to setup your profile. This will create a rubywarrior directory in your current location where you will find a player.rb file in your profile's directory containing this:

class Player
  def play_turn(warrior)
    # your code goes here
  end
end

Your objective is to fill this play_turn method with commands to instruct the warrior what to do. With each level your abilities will grow along with the difficulty. See the README in your profile's directory for details on what abilities your warrior has available on the current level.

Here is a simple example which will instruct the warrior to attack if he feels an enemy, otherwise he will walk forward.

class Player
  def play_turn(warrior)
    if warrior.feel.enemy?
      warrior.attack!
    else
      warrior.walk!
    end
  end
end

Once you are done editing player.rb, save the file and run the rubywarrior command again to start playing the level. The play happens through a series of turns. On each one, your play_turn method is called along with any enemy's.

You cannot change your code in the middle of a level. You must take into account everything that may happen on that level and give your warrior the proper instructions from the start.

Losing all of your health will cause you to fail the level. You are not punished by this, you simply need to go back to your player.rb, improve your code, and try again.

Once you pass a level (by reaching the stairs), the profile README will be updated for the next level. Alter the player.rb file and run rubywarrior again to play the next level.

Scoring

Your objective is to not only reach the stairs, but to get the highest score you can. There are many ways you can earn points on a level.

  • defeat an enemy to add his max health to your score
  • rescue a captive to earn 20 points
  • pass the level within the bonus time to earn the amount of bonus time remaining
  • defeat all enemies and rescue all captives to receive a 20% overall bonus

A total score is kept as you progress through the levels. When you pass a level, that score is added to your total.

Don't be too concerned about scoring perfectly in the beginning. After you reach the top of the tower you will be able to re-run the tower and fine-tune your warrior to get the highest score. See the Epic Mode below for details.

Perspective

Even though this is a text-based game, think of it as two-dimensional where you are viewing from overhead. Each level is always rectangular in shape and is made up of a number of squares. Only one unit can be on a given square at a time, and your objective is to find the square with the stairs. Here is an example level map and key.

 ----
|C s>|
| S s|
|C @ |
 ----

> = Stairs
@ = Warrior (20 HP)
s = Sludge (12 HP)
S = Thick Sludge (24 HP)
C = Captive (1 HP)

Commanding the Warrior

When you first start, your warrior will only have a few abilities, but with each level your abilities will grow. A warrior has two kinds of abilities: actions and senses.

An action is something that effects the game in some way. You can easily tell an action because it ends in an exclamation mark. Only one action can be performed per turn, so choose wisely. Here are some examples of actions.

warrior.walk!
  Move in given direction (forward by default).

warrior.attack!
  Attack the unit in given direction (forward by default).

warrior.rest!
  Gain 10% of max health back, but do nothing more.

warrior.bind!
  Bind unit in given direction to keep him from moving (forward by default).

warrior.rescue!
  Rescue a captive from his chains (earning 20 points) in given direction (forward by default).

A sense is something which gathers information about the floor. You can perform senses as often as you want per turn to gather information about your surroundings and to aid you in choosing the proper action. Senses do NOT end in an exclamation mark.

warrior.feel
  Returns a Space for the given direction (forward by default).

warrior.health
  Returns an integer representing your health.

warrior.distance
  Returns the number of spaces the stairs are away.

warrior.listen
  Returns an array of all spaces which have units in them.

Since what you sense will change each turn, you should record what information you gather for use on the next turn. For example, you can determine if you are being attacked if your health has gone down since the last turn.

Spaces

Whenever you sense an area, often one or multiple spaces (in an array) will be returned. A space is an object representing a square in the level. You can call methods on a space to gather information about what is there. Here are the various methods you can call on a space.

space.empty?
  If true, this means that nothing (except maybe stairs) is at this location and you can walk here.

space.stairs?
  Determine if stairs are at that location

space.enemy?
  Determine if an enemy unit is at this location.

space.captive?
  Determine if a captive is at this location.

space.wall?
  Returns true if this is the edge of the level. You can't walk here.

space.ticking?
  Returns true if this space contains a bomb which will explode in time.

space.golem?
  Returns true if a golem is occupying this space.

You will often call these methods directly after a sense. For example, the feel sense returns one space. You can call captive? on this to determine if a captive is in front of you.

warrior.feel.captive?

Golem

Along your journey you may discover the ability to create a golem. This is a separate unit which you also control. The turn handling is done through a block. Here is an example.

warrior.form! do |golem|
  golem.attack! if golem.feel.enemy?
end

Complex logic can be placed in this block just like in the player turn method. You may want to move the logic into its own class or create multiple classes for different types of golems. You can create multiple golems in a level, but each one will take half of the warrior's health.

Epic Mode

Once you reach the top of the tower, you will enter epic mode. When running rubywarrior again it will run your current player.rb through all levels in the tower without stopping.

Your warrior will most likely not succeed the first time around, so use the -l option on levels you are having difficulty or want to fine-tune the scoring.

rubywarrior -l 3

Once your warrior reaches the top again you will receive an average grade, along with a grade for each level. The grades from best to worst are S, A, B, C, D and F. Try to get S on each level for the ultimate score.

Note: I'm in the process of fine-tuning the grading system. If you find the S grade to be too easy or too difficult to achieve on a given level, please add an issue for this on GitHub.

Tips

If you ever get stuck on a level, review the README documentation and be sure you're trying each ability out. If you can't keep your health up, be sure to rest when no enemy is around (while keeping an eye on your health). Also, try to use far-ranged weapons whenever possible (such as the bow).

Remember, you're working in Ruby here. Don't simply fill up the play_turn method with a lot of code. Organize it with methods and classes. The player directory is set up as a load path so you can include other ruby files from your player.rb file.

Senses are cheap, so use them liberally. Store the sensed information to help you better determine what actions to take in the future.

Running rubywarrior while you are in your profile directory will auto-select that profile so you don't have to each time.

If you're aiming for points, remember to sweep the area. Even if you're close to the stairs, don't go in until you've gotten everything (if you have the health). Use far-ranged senses (such as look and listen) to determine if there are any enemies left.

Make sure to try the different options you can pass to the rubywarrior command. Run rubywarrior --help to see them all.

ruby-warrior's People

Contributors

amalloy avatar bobbungee avatar dcki avatar enriquevidal avatar fpsvogel avatar jameskbride avatar kathanshukla avatar kenny-evitt avatar pejuko avatar rlqualls avatar ryanb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-warrior's Issues

Turn into gem

The game is maturing enough for now. Time to turn it into a gem so it is easily installable.

Incompatible marshal file format

/home/hemanth/.rvm/gems/ruby-1.9.2-p290/gems/rubywarrior-0.1.3/lib/ruby_warrior/profile.rb:31:in `load': incompatible marshal file format (can't be read) (TypeError)
    format version 4.8 required; 254.154 given
    from /home/hemanth/.rvm/gems/ruby-1.9.2-p290/gems/rubywarrior-0.1.3/lib/ruby_warrior/profile.rb:31:in `decode'
    from /home/hemanth/.rvm/gems/ruby-1.9.2-p290/gems/rubywarrior-0.1.3/lib/ruby_warrior/profile.rb:35:in `load'
    from /home/hemanth/.rvm/gems/ruby-1.9.2-p290/gems/rubywarrior-0.1.3/lib/ruby_warrior/game.rb:8:in `start'
    from /home/hemanth/.rvm/gems/ruby-1.9.2-p290/gems/rubywarrior-0.1.3/lib/ruby_warrior/runner.rb:17:in `run'
    from /home/hemanth/.rvm/gems/ruby-1.9.2-p290/gems/rubywarrior-0.1.3/bin/rubywarrior:5:in `<top (required)>'
    from /home/hemanth/.rvm/gems/ruby-1.9.2-p290/bin/rubywarrior:19:in `load'
    from /home/hemanth/.rvm/gems/ruby-1.9.2-p290/bin/rubywarrior:19:in `<main>'

$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]

$ uname -a
Linux hemanth-OptiPlex-755 2.6.35-32-generic #65-Ubuntu SMP Tue Jan 24 13:48:14 UTC 2012 i686 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.10
Release:    10.10
Codename:   maverick

Running `rspec`, `rake spec`, and `rake rspec` all fail

Here's the output of rspec:

stefan@stefan-lap:~/code/ruby-warrior$ rspec
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mocha/standalone (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/mocking/with_mocha.rb:23:in `rescue in <top (required)>'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/mocking/with_mocha.rb:14:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:343:in `mock_with'
    from /home/stefan/code/ruby-warrior/spec/spec_helper.rb:6:in `block in <top (required)>'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core.rb:107:in `configure'
    from /home/stefan/code/ruby-warrior/spec/spec_helper.rb:5:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/stefan/code/ruby-warrior/spec/ruby_warrior/abilities/attack_spec.rb:1:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

Here's the output of rake spec:

stefan@stefan-lap:~/code/ruby-warrior$ rake spec
rake aborted!
cannot load such file -- rspec
/home/stefan/code/ruby-warrior/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)

Here's the output of rake rspec:

stefan@stefan-lap:~/code/ruby-warrior$ rake rspec
rake aborted!
cannot load such file -- rspec
/home/stefan/code/ruby-warrior/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)

how to run the specs ?

bundle exec rake spec

-=-
ruby-warrior$ bundle exec rake spec
spec/ruby_warrior/units/captive_spec.rb:1:in `require': no such file to load -- spec/ruby_warrior/units/../../spec_helper (LoadError)

Update readme

The README file should be updated to reflect the current warrior available actions and senses. It should also have a better explanation of how the space object works.

Add skip option

Passing a -s option into the rubywarrior command should skip any questions which aren't of importance (such as the final question for the hint). This way one can pass the rubywarrior command into a tail output and see the outcome instantly.

rubywarrior -s -t 0 | tail

The -t being zero time so it's instant.

Unknown Entities

It would be interesting to have creatures that could be friendly or agressive. This way the player needs to watch to see what happens before deciding to attack or ignore a specific monster. If there are multiple creatures of this type on one level, they will not all nessisary share the same attitude.

Perhaps also aggresive creatures that are too powerful and need to be avoided might make this interesting

Multiplayer

It would be nice to play this multiplayer, or to control more than one characeter (cooperation mode) for example warrior and priest.. Priest heals, warrior kills ;)

error message on a fresh install

Hi

I just installed ruby and rubygems on a Ubuntu 11.10

sudo aptitude install ruby rubygems
sudo gem install rubywarrior

now when i run "rubywarrior" i get the following error message:

Welcome to Ruby Warrior
/var/lib/gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/profile.rb:31:in load': incompatible marshal file format (can't be read) (TypeError) format version 4.8 required; 254.154 given from /var/lib/gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/profile.rb:31:indecode'
from /var/lib/gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/profile.rb:35:in load' from /var/lib/gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/game.rb:8:instart'
from /var/lib/gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/runner.rb:17:in run' from /var/lib/gems/1.8/gems/rubywarrior-0.1.2/bin/rubywarrior:5 from /usr/local/bin/rubywarrior:19:inload'
from /usr/local/bin/rubywarrior:19

i'm trying to learn ruby, so it's maybe a bit early to debug this problem, is there someone who can help?

regards
Andi

Support 3rd party towers

One should be able to create their own gem for adding additional towers to ruby-warrior. When the user runs the rubywarrior command it will look through the gems and add any towers mentioned.

Third party towers should be able to extend the units and abilities as well.

Labyrinth Tower

One interesting tower idea is that of a labyrinth. Currently the levels are only rectangular in shape and the walls are only on the outside. What if inner walls existed? It would allow maze like passages like this.

 ------
|      |
| --- -|
|@|   >|
 ------

One may be required to remember previously taken paths in order to navigate the maze. One can navigate using senses such as look and feel. Other senses may be necessary to add as well to aid in navigation.

Instead of walls, spikes may be a better option. This way other abilities can easily be applied such as listen, distance_of, and direction_of without causing much confusion.

Practice levels in epic

If a profile is in epic mode, one should be able to specify which level they would like to try running. This way they can fine tune a level and focus on that without having to run every other one.

rubywarrior -l 8

warrior.look returns wall for stairs?

Maybe I don't understand the grander dynamics yet of the game, but, shouldn't our warrior be able to see stairs? He can warrior.feel stairs, and the stairs are a distinct icon on the map like everything else, but he can't see them? I'm a little puzzled by that.

Bug after dying slug in level 2

Hi, I got a problem in level 2. Here is my player:

class player
DIRECTIONS = [:forward, :right, :left, :backwards]
MAX_HEALTH = 20

def play_turn(warrior)
@warrior = warrior
if injured? and in_peace?
warrior.rest!
elsif in_peace?
warrior.walk!(warrior.direction_of_stairs)
else
warrior.attack!(enemy_direction)
end
end

def enemy_direction
DIRECTIONS.first { |d| @warrior.feel(d).enemy? }
end

def injured?
@warrior.health < MAX_HEALTH
end

def in_peace?
DIRECTIONS.all? { |d| not @warrior.feel(d).enemy? }
end
end

And here is my whole output, I hope that helps:

Welcome to Ruby Warrior
Starting Level 2

  • turn 1 -

    |@s |
    | sS>|

    Bombana attacks Sludge
    Sludge takes 5 damage, 7 health power left
    Sludge attacks Bombana
    Bombana takes 3 damage, 17 health power left
  • turn 2 -

    |@s |
    | sS>|

    Bombana attacks Sludge
    Sludge takes 5 damage, 2 health power left
    Sludge attacks Bombana
    Bombana takes 3 damage, 14 health power left
  • turn 3 -

    |@s |
    | sS>|

    Bombana attacks Sludge
    Sludge takes 5 damage, -3 health power left
    Sludge dies
    Bombana earns 12 points
  • turn 4 -

    |@ |
    | sS>|

    /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/base.rb:16:in offset': undefined methodmap' for nil:NilClass (NoMethodError)
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/base.rb:20:in space' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/feel.rb:9:inperform'
    from (eval):2:in feel' from ./player.rb:25:inin_peace?'
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/turn.rb:30:in all?' from ./player.rb:25:ineach'
    from ./player.rb:25:in all?' from ./player.rb:25:inin_peace?'
    from ./player.rb:7:in play_turn' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/units/warrior.rb:12:inplay_turn'
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/units/base.rb:72:in prepare_turn' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:50:inplay'
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:50:in each' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:50:inplay'
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:46:in times' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:46:inplay'
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:72:in play_current_level' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:63:inplay_normal_mode'
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:23:in start' from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/runner.rb:17:inrun'
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/bin/rubywarrior:5
    from /var/lib/gems/1.8/bin/rubywarrior:19:in `load'
    from /var/lib/gems/1.8/bin/rubywarrior:19

Warrior cannot differentiate between monsters (patch prototype inside)

a_slime_draws_near.png

In playing with my own Warrior I decided I wanted to teach him how to recognize individual monsters and remember them from turn to turn. I checked the RubyWarrior source and discovered that the monster objects persist from turn to turn but that they don't offer #hash methods to remember them by. I monkeypatched Unit and Space and it had the desired effect. I'd like to submit a pull request to add this functionality (with specs) but before I do I'd like confirmation from a maintainer that this won't violate the spirit of the game. Sample monkey patches are below

Thanks!

require 'securerandom'

module RubyWarrior
  module Units
    class Base
      def unique_id
        @uuid ||= SecureRandom.uuid
      end

      def eql?(other_unit)
        self.hash == other_unit.hash
      end

      def hash
        self.unique_id.hash
      end
    end
  end

  class Space
    def unique_id
      @uuid ||= SecureRandom.uuid
    end

    def eql?(other_space)
      self.hash == other_space.hash
    end

    # Not sure about this part but my code didn't work when 
    # I tried to only put the monster hashes on the units themselves.
    #
    def hash
      self.unit.hash || self.unique_id.hash
    end
  end
end

Wrap clues text

Some of the clues are long and currently don't wrap well in the terminal. Add hard wrapping for these. Maybe wrap at 80 chars.

Add --help option

Running rubywarrior --help should display a description of how the command works along with a list of all options that one can pass to it.

Golem

One interesting ability would be "warrior.golem!" which would spawn a separate character in front of the warrior. It would be weaker than a warrior and have fewer abilities. This would be a good use for a block in Ruby to control the golem's actions each turn.

warrior.golem! do |golem|
  golem.walk!
  #...
end

Likely only one golem could be made at a time. Also maybe it should have some bad consequences like cut the warrior's health in half?

What do you think of this idea? Would it be too confusing? What would be the best way to express which abilities the golem has?

Add distance_of ability

The warrior should be able to tell the distance of a given unit. This will help in bomb throwing to tell if a captive or ticking unit will be effected by the bomb.

captives = warrior.listen.map { |s| s.captive? }
warrior.throw! unless captives.any? { |s| warrior.distance_of(s) == 3 }

Ruby Warrior fails to launch if another program has created a file called .profile

Ruby Warrior is giving me an error when I attempt to launch it. Here's the error:

Welcome to Ruby Warrior /Library/Ruby/Gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/profile.rb:31:in load': incompatible marshal file format (can't be read) (TypeError)
format version 4.8 required; 98.139 given
from /Library/Ruby/Gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/profile.rb:31:in decode' from /Library/Ruby/Gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/profile.rb:35:in load'
from /Library/Ruby/Gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/game.rb:8:in start' from /Library/Ruby/Gems/1.8/gems/rubywarrior-0.1.2/lib/ruby_warrior/runner.rb:17:in run'
from /Library/Ruby/Gems/1.8/gems/rubywarrior-0.1.2/bin/rubywarrior:5
from /usr/bin/rubywarrior:19:in load' from /usr/bin/rubywarrior:19

I'm using Ruby 1.8.7 on Mac OS X 10.6.7. I installed Ruby Warrior from RubyGems 1.8.2.

Error if custom directory doesn't exist

If I want to use non-existent custom directory for rubywarrior data using -d parameter, game offers me to create rubywarrior subdirectory under it and then crashes because the custom directory doesn't exist.

Example:

rubywarrior -dnodir
No rubywarrior directory found, would you like to create one? [yn] y
lib/ruby_warrior/game.rb:29:in `mkdir': No such file or directory - nodir/rubywarrior (Errno::ENOENT)

IMHO game should offer to create custom directory before creating rubywarrior directory.

Running ruby-warrior in Windows doesn't work by default

Using the 1.8.7-p302 on Windows 7 x86, running ruby-warrior after extracting doesn't work out of the box.

The issue here is that the script to run ruby is the same name as the directory in which the player files are stored. Changing the 'rubywarrior' file in /bin/ to 'rubywarrior.rb' solves this on windows and it can run normally.

    C:\Users\jjusr\Downloads\ryanb-ruby-warrior-2dd76f6\rubywarrior\bin>ruby rubywarrior
    Welcome to Ruby Warrior
    [1] beginner
    [2] intermediate
    Choose tower by typing the number: 1
    Enter a name for your warrior: mark
    C:/Ruby/lib/ruby/1.8/fileutils.rb:244:in `mkdir': File exists - ./rubywarrior (Errno::EEXIST)
    from C:/Ruby/lib/ruby/1.8/fileutils.rb:244:in `fu_mkdir'
    from C:/Ruby/lib/ruby/1.8/fileutils.rb:217:in `mkdir_p'
    from C:/Ruby/lib/ruby/1.8/fileutils.rb:215:in `reverse_each'
    from C:/Ruby/lib/ruby/1.8/fileutils.rb:215:in `mkdir_p'
    from C:/Ruby/lib/ruby/1.8/fileutils.rb:201:in `each'
    from C:/Ruby/lib/ruby/1.8/fileutils.rb:201:in `mkdir_p'
    from ./../lib/ruby_warrior/player_generator.rb:23:in `generate'
    from ./../lib/ruby_warrior/level.rb:41:in `generate_player_files'
    from ./../lib/ruby_warrior/game.rb:111:in `prepare_next_level'
    from ./../lib/ruby_warrior/game.rb:60:in `play_normal_mode'
    from ./../lib/ruby_warrior/game.rb:23:in `start'
    from ./../lib/ruby_warrior/runner.rb:17:in `run'
    from rubywarrior:5

After changing the file:

    C:\Users\jjusr\Downloads\ryanb-ruby-warrior-2dd76f6\rubywarrior\bin>ruby rubywarrior.rb
    Welcome to Ruby Warrior
    No rubywarrior directory found, would you like to create one? [yn] y
    [1] beginner
    [2] intermediate
    Choose tower by typing the number: 1
    Enter a name for your warrior: mark
    First level has been generated. See the rubywarrior/mark-beginner/README for instructions.

Online leader board

Add a leader board to http://rubywarrior.com. Provide a documented way to submit the code to the site to be run, perhaps with a post-commit hook URL one can use in github to frequently re-run the code when levels/player is updated. It can record user's current progress through the levels and their score.

One challenge is how to run the code in a protected environment. We don't want any arbitrary ruby code to run, especially code that effects the file system or executes system commands. Look into _why's sandbox gem for this?

Can't Take second turn on level 6

At first I though this was caused by an error in my code but I stripped it down to walk forward on turn one then walk backward on turn two and the same error appears.

the error:

/var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/base.rb:16:in `offset': undefined method `map' for nil:NilClass (NoMethodError)
    from /var/lib/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/abilities/base.rb:20:in `space'

Ruby Version: @ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]@
Ruby Warrior Version: latest gem

not quite sure why this error appears

Rerun tower levels at top

Once the warrior reaches the top level, re-run all levels using the latest player file (and all abilities) to determine a separate special master score. The speed can be a little faster on the final run.

This will encourage people to continue to improve their player after they beat the tower to improve their score.

Add throw ability

I would like to add a throw bomb ability to the intermediate tower. A bomb explodes on the second square in the given thrown direction giving 10 damage. It slightly damages the other 4 squares around it as well.

If there is a ticking explosive coming from any of the 5 spaces it will detonate that as well.

`rake` scenario and step failures

One scenario and one step fail. See below.

stefan@stefan-lap:~/code/ruby-warrior$ rake
/usr/local/bin/ruby -S rspec spec/ruby_warrior/abilities/attack_spec.rb spec/ruby_warrior/abilities/base_spec.rb spec/ruby_warrior/abilities/bind_spec.rb spec/ruby_warrior/abilities/direction_of_spec.rb spec/ruby_warrior/abilities/direction_of_stairs_spec.rb spec/ruby_warrior/abilities/distance_of_spec.rb spec/ruby_warrior/abilities/explode_spec.rb spec/ruby_warrior/abilities/feel_spec.rb spec/ruby_warrior/abilities/form_spec.rb spec/ruby_warrior/abilities/health_spec.rb spec/ruby_warrior/abilities/listen_spec.rb spec/ruby_warrior/abilities/look_spec.rb spec/ruby_warrior/abilities/pivot_spec.rb spec/ruby_warrior/abilities/rescue_spec.rb spec/ruby_warrior/abilities/rest_spec.rb spec/ruby_warrior/abilities/shoot_spec.rb spec/ruby_warrior/abilities/throw_spec.rb spec/ruby_warrior/abilities/walk_spec.rb spec/ruby_warrior/core_additions_spec.rb spec/ruby_warrior/floor_spec.rb spec/ruby_warrior/game_spec.rb spec/ruby_warrior/level_loader_spec.rb spec/ruby_warrior/level_spec.rb spec/ruby_warrior/player_generator_spec.rb spec/ruby_warrior/position_spec.rb spec/ruby_warrior/profile_spec.rb spec/ruby_warrior/space_spec.rb spec/ruby_warrior/tower_spec.rb spec/ruby_warrior/turn_spec.rb spec/ruby_warrior/ui_spec.rb spec/ruby_warrior/units/archer_spec.rb spec/ruby_warrior/units/base_spec.rb spec/ruby_warrior/units/captive_spec.rb spec/ruby_warrior/units/golem_spec.rb spec/ruby_warrior/units/sludge_spec.rb spec/ruby_warrior/units/thick_sludge_spec.rb spec/ruby_warrior/units/warrior_spec.rb spec/ruby_warrior/units/wizard_spec.rb
.........................................................................................................................................................................................................................................................

Finished in 0.15536 seconds
249 examples, 0 failures
/usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/2.0.0/gems/cucumber-1.3.4/lib:lib" "/usr/local/lib/ruby/gems/2.0.0/gems/cucumber-1.3.4/bin/cucumber" features --format progress
.........................................................................F---.......................................................................

(::) failed steps (::)

Unable to find choice Bill - short - first score 34 - epic score 34 in Welcome to Ruby Warrior
[1] Bill - short - first score 34 - epic score 0
[2] New Profile
Choose profile by typing the number:  (RuntimeError)
./features/step_definitions/interaction_steps.rb:51:in `/^I choose "([^\"]*)" for "([^\"]*)"$/'
features/levels.feature:47:in `And I choose "Bill - short - first score 34 - epic score 34" for "profile"'

Failing Scenarios:
cucumber features/levels.feature:31 # Scenario: Replay levels as epic when finishing last level with grades

14 scenarios (1 failed, 13 passed)
144 steps (1 failed, 3 skipped, 140 passed)
0m1.777s

Include directions in actions

If a warrior or some unit is performing an action it would be helpful to always include the direction of the action. Such as "attacks forward" or "shoots left".

Run profile in current directory

If the rubywarrior command is run inside of a profile directory then it should auto-select that profile during running. This way one doesn't have to select their profile every time.

suggestion: using a web interface to play

ryan,

rails.desktop ?
it can be very funny to create a railscast episode : how to use rails for dealing with desktop applications.

desktop.mvc ?
how will u re-model this(or any other) desktop game to fit to rails design ?
how does a desktop application can benefit from the beauty of rails structure ?

online.multiplayer ?
it will be interesting to c how easy it actually is (when u do it - it seems sooo.. easy!)
to implement an online multiplayer game (maybe by using the faye gem) which lies upon Ruby-Warrior.
i meant to say ryan: "Let the Robots Dance !"

thanks ;)

Rank epic score

Give users something to shoot for by ranking each epic score. What if each level had its own Ace Score which one tries to achieve? This way we can rank the overall epic score by averaging the grades.

Here's a key for the grades and percentages:

100+ A
80+ B
60+ C
40+ D
others F

The grade can be displayed after each level and a summary of ones to work on after completing the tower.

Your average grade for this tower is: C

Here are some levels you should practice on.

Level 2: B
Level 5: D
Level 6: C

To practice a level, use the -l option:

  rubywarrior -l 3

This way the player has some idea of what levels to focus on and this goes hand-in-hand with the practice option.

The grade should be saved and appear next to the epic score in the player's profile.

[1] Joe - beginner - first score 300 - epic score 564 (C)

array returned by warrior.look is string?

I'm not sure if this is an issue or a quirk or nothing. The supporting code looks right as far as i can tell.

warrior.look.to_s returns something like [nothing, Wizard, nothing] while ["nothing", "nothing", "nothing"] .to_s returns ["nothing", "nothing", "nothing"]

was trying to do array comparison with 'eql?' and kept getting false returns. though what I don't understand is warrior.look[1] returns the correct item.

I had to create my array like "[nothing, Wizard, nothing]" in order to compare.

So, from what i can tell, isn't the array returned by warrior.look invalid in some way?

Cant enter Intermediate Level 6

When I finished the Intermediate Level 5, it can't enter to Level 6. Here is the log:

- turn 51 -
 -----
|     |
| >@  |
 -----

"current_state: walk"
"current_health: 17"
Yuyan walks backward
Success! You have found the stairs.
Level Score: 68
Time Bonus: 0
Clear Bonus: 14
Total Score: 201 + 82 = 283
Would you like to continue on to the next level? [yn] y
/localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:31:in `load_level': undefined method `time=' for # (NoMethodError)
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level_loader.rb:41:in `unit'
        from (eval):20:in `load_level'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/level.rb:40:in `generate_player_files'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:111:in `prepare_next_level'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:99:in `request_next_level'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:84:in `play_current_level'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:63:in `play_normal_mode'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/game.rb:23:in `start'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/lib/ruby_warrior/runner.rb:17:in `run'
        from /localdisk/data/ruby/lib/ruby/gems/1.8/gems/rubywarrior-0.1.1/bin/rubywarrior:5
        from /localdisk/data/ruby/bin/rubywarrior:19:in `load'
        from /localdisk/data/ruby/bin/rubywarrior:19

Keep single player.rb file

It is easy to accidentally edit the older player.rb file instead of the newer one when changing levels. It would be better to keep the player file the same and change the README file directly.

Is anyone concerned about losing the previous player files? One could keep it under version control if so. Alternatively I could copy a backup of each file when moving to the next level, but that might be messy.

I'm not sure how best to keep this backwards compatible so it upgrades smoothly. Need to investigate.

Proxy objects for Turn and Space

All objects passed to a Player should be proxy objects which only contain methods that I want a player to use. This will make it more difficult to "cheat" by accessing the Space#unit and similar methods which provide more information than I want to make available.

This won't entirely prevent this kind of cheating but at least it will add a layer of difficulty. If one is smart enough to view the source and see how the proxying works then perhaps they deserve to have access to it. ;)

Configure current directory path

The rubywarrior command should support an option for changing the current directory (or the directory rubywarrior is run under and looks for profiles under).

rubywarrior -d path/to/ruby-warrior

error running tests/specs

how can i run the specs?

  1. it run OK when i run:
    $ spec ./spec/*_/__spec.rb

  2. it fails running:
    $ rake spec
    internal:lib/rubygems/custom_require:29:in require': no such file to load -- spec/ruby_warrior/../spec_helper (LoadError) from <internal:lib/rubygems/custom_require>:29:inrequire'
    from spec/ruby_warrior/ui_spec.rb:1:in `<top (required)>'

suggestion: add Gemfile/GemSpec/.rvmrc

No internal way to reset progress / rubywarrior

Once a profile is created, there is no rubywarrior command to reset progress (i.e., revert to a clean version of the project). I propose there should be a way to reset it (like rubywarrior -r or rubywarrior --reset), which would prompt the user to confirm whether (s)he wants to reset.

Quickrun command?

It might be useful to have a mode that skips all of the normal output and tells us how many turns it took, if we missed anything important, if we actually lived, etc.

I figure that we can test our changes quickly, and we can always run it normally if we need to see what's going on.

I envision something like:
prompt$ rubywarrior --quick-run
Success! You have found the stairs after 17 turns.
You missed 1 captive.
Level Score: 38
Time Bonus: 16
Total Score: 285 + 54 = 339
Would you like to continue? [yn]

not an issue

just wanted to say THIS IS REALLY FUCKING COOL. so thank you. i'm a ruby newbie and a github newbie, just found this, and am really freaking excited to give it a whirl.

apologies for posting in the wrong forum - didn't know where else to.

Make UI delay time configurable

The rubywarrior command should support an option which allows one to specify the user-interface message delay time. For example:

rubywarrior -t 0.3

This will set the time to 0.3 seconds between displaying messages in the UI.

Advanced Tower

There's a beginner and intermediate tower. It would be pretty cool if there was an Advanced tower.

Feel and look doesn't recognize stairs

Is this intentional? I just finished the game on beginning level, but had to put some hacks into my code because I couldn't recognize the stairs. Look returns 'nothing' for stairs btw

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.