WarriorJS: Game written in JavaScript for learning JavaScript and artificial intelligence
WarriorJS とは、インタラクティブな方法で JavaScript と人工知能を楽しく教えるために設計されたゲーム。
WarriorJS is a game designed to teach JavaScript and artificial intelligence in a fun, interactive way.
climbing a tall tower to <insert something that motivates you here> at the top level. On each floor, you need to write JavaScript (with full ES2015 support) to instruct the warrior to battle enemies, rescue captives, and reach the stairs.
directory in your current location, where you will find a Player.js file in your profile's directory containing the Player class. class Player { playTurn(warrior) { // Cool code goes here } }
playTurn 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.
the warrior to attack if he feels an enemy, otherwise he will walk forward: class Player { playTurn(warrior) { if (warrior.feel().isEnemy()) { warrior.attack(); } else { warrior.walk(); } } }
save the file and run the warriorjs command again to start playing the level. The play happens through a series of turns. On each one, your playTurn method is called along with any enemy's.
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.
ྻΛ͢ඞཁ͕͋Γ·͢ɻྫɿwarrior.walk('backward');ɻ Many abilities can be performed in the following directions: forward, backward, left and right. You have to pass a string with the direction as the first argument, e.g. warrior.walk('backward');.
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.
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.
directly after a sense. For example, the feel sense returns one Space. You can call isCaptive() on this to determine if a captive is in front of you: warrior.feel().isCaptive();
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).
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.