This workshop integrates many of our past learnings with AI techniques.
-
You may use any techniques you wish to use.
-
My recommendation is to pair program and follow the TDD workflow (fail test, write minimum code required to pass, pass test, refactor).
-
Before writing code, discuss strategies based on your observations.
-
Each time you pass, you have the option to progress to the next level.
-
You develop skills and abilities as you progress, so RTFR!
-
You may find debugging and introspection to be powerful techniques.
Q. What is AI (artificial intelligence)?
A. It is the science and engineering of making intelligent machines, especially intelligent computer programs. It is related to the similar task of using computers to understand human intelligence, but AI does not have to confine itself to methods that are biologically observable.
Q. Yes, but what is intelligence?
A. Intelligence is the computational part of the ability to achieve goals in the world. Varying kinds and degrees of intelligence occur in people, many animals and some machines.
Q. Isn't AI about simulating human intelligence?
A. Sometimes, but not always. On the one hand, we can learn something about how to make machines solve problems by observing other people or just by observing our own methods. On the other hand, most work in AI involves studying the problems the world presents to intelligence rather than studying people or animals. AI researchers are free to use methods that are not observed in people or that involve much more computing than people can do.
Q. Does AI aim to put the human mind into the computer?
A. Some researchers say they have that objective, but they are probably using the phrase metaphorically. The human mind has a lot of peculiarities, and I'm not sure anyone is serious about imitating all of them.
Q. What is AI?
A. AI is the ability of a machine (usually software) to achieve goals through decision-making.
% mkdir ruby-warrior
% cd !$
IMPORTANT: Ruby must be < 2.2!
If you’re using Rbenv, run:
% echo 2.1.7 > .rbenv-version
% echo rubywarrior > .rbenv-gemsets
% gem install rubywarrior-i18n
If you’re using Rbenv, run:
% rbenv rehash
% rubywarrior
- create a new directory with a “beginner” tower
- name your warrior
If you don’t do this, it will ask you which profile toplay each time:
% cd <TAB><TAB>
We will do several iterations of the following process. Follow it carefully to ensure success!
IMPORTANT: Actually do this step as it provides important hints and tips (the README file updates every time you progress to the next level)
% cat README.rdoc
% rubywarrior
(failure)
- Discuss this with your pair
% rubywarrior
(working)
- Answer “n” to the final question
% rubywarrior
(working)
- Answer “y” to the final question
You see before yourself a long hallway with stairs at the end. There is nothing in the way.
Tip: Call warrior.walk!
to walk forward in the Player#play_turn
method.
--------
|@ >|
--------
> = Stairs
@ = Frodo (20 HP)
warrior.walk!
Move in the given direction (forward by default).
- Follow the TDD workflow.
It is too dark to see anything, but you smell sludge nearby.
Tip: Use warrior.feel.empty?
to see if there is anything in front of you, and warrior.attack!
to fight it. Remember, you can only do one action (ending in !) per turn.
--------
|@ s >|
--------
> = Stairs
@ = Frodo (20 HP)
s = Sludge (12 HP)
warrior.feel
Returns a Space for the given direction (forward by default).
warrior.attack!
Attacks a unit in given direction (forward by default).
warrior.walk!
Move in the given direction (forward by default).
-
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. -
If you ever get stuck on a level, review the
README
documentation and be sure you're trying each ability out. -
Make sure to try the different options you can pass to the rubywarrior command. Run
rubywarrior –help
to see them all. -
To run with no delay between steps:
% rubywarrior -t 0
- POWER TIP: The Space object returned by Warrior#feel can answer some interesting questions!
The air feels thicker than before. There must be a horde of sludge.
Tip: Be careful not to die! Use warrior.health
to keep an eye on your health, and warrior.rest!
to earn 10% of max health back.
---------
|@ s ss s>|
---------
> = Stairs
@ = Frodo (20 HP)
s = Sludge (12 HP)
warrior.health
Returns an integer representing your health.
warrior.rest!
Gain 10% of max health back, but do nothing more.
warrior.feel
Returns a Space for the given direction (forward by default).
warrior.attack!
Attacks a unit in given direction (forward by default).
warrior.walk!
Move in the given direction (forward by default).
-
If you get low on health be sure to
rest!
when no enemy is near. -
Sludges do 3 HP damage per round.
-
warrior.walk!
can take a direction! -
POWER TIP: Use a debugger to develop code fast
% gem install byebug
insert
require ‘byebug’
at top of player.rb
insertbyebug
at point of importance
% gem install pry-byebug
insert
require ‘pry-byebug’
at top of player.rb
insertbinding.pry
at point of importance
You can hear bow strings being stretched.
Tip: No new abilities this time, but you must be careful not to rest while taking damage. Save a @health
instance variable and compare it on each turn to see if you're taking damage.
-------
|@ Sa S>|
-------
> = Stairs
@ = Frodo (20 HP)
S = Thick sludge (24 HP)
a = Archer (7 HP)
warrior.health
Returns an integer representing your health.
warrior.rest!
Gain 10% of max health back, but do nothing more.
warrior.feel
Returns a Space for the given direction (forward by default).
warrior.attack!
Attacks a unit in given direction (forward by default).
warrior.walk!
Move in the given direction (forward by default).
-
Try to use far-ranged weapons whenever possible (such as the bow).
-
Senses are cheap, so use them liberally. Store the sensed information to help you better determine what actions to take in the future.
-
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.