├── jta26 ├── CHANGES ├── license │ └── README ├── bin │ ├── telnet │ ├── ssh │ └── terminal ├── html │ ├── users.db │ ├── b2.conf │ ├── simple.conf │ ├── ssh.conf │ └── b1.conf ├── jta.manifest ├── de │ └── mud │ │ ├── jta │ │ ├── Build.java │ │ ├── Version.java │ │ ├── Build.java.tmpl │ │ ├── PluginListener.java │ │ ├── event │ │ │ ├── SoundListener.java │ │ │ ├── EndOfRecordListener.java │ │ │ ├── LocalEchoListener.java │ │ │ ├── WindowSizeListener.java │ │ │ ├── ConfigurationListener.java │ │ │ ├── SetWindowSizeListener.java │ │ │ ├── AppletListener.java │ │ │ ├── OnlineStatusListener.java │ │ │ ├── TerminalTypeListener.java │ │ │ ├── ReturnFocusListener.java │ │ │ ├── TelnetCommandListener.java │ │ │ ├── FocusStatusListener.java │ │ │ ├── SocketListener.java │ │ │ ├── WindowSizeRequest.java │ │ │ ├── AppletRequest.java │ │ │ ├── SoundRequest.java │ │ │ ├── EndOfRecordRequest.java │ │ │ ├── SetWindowSizeRequest.java │ │ │ ├── ReturnFocusRequest.java │ │ │ ├── TerminalTypeRequest.java │ │ │ ├── OnlineStatus.java │ │ │ ├── ConfigurationRequest.java │ │ │ ├── LocalEchoRequest.java │ │ │ ├── TelnetCommandRequest.java │ │ │ ├── FocusStatus.java │ │ │ └── SocketRequest.java │ │ ├── ssh.conf │ │ ├── PluginMessage.java │ │ ├── VisualTransferPlugin.java │ │ ├── VisualPlugin.java │ │ ├── PluginBus.java │ │ ├── plugin │ │ │ └── HandlerPTY.java │ │ ├── FilterPlugin.java │ │ └── Plugin.java │ │ ├── terminal │ │ ├── colorSet.conf │ │ ├── keyCodes.conf │ │ └── VDUDisplay.java │ │ ├── ssh │ │ ├── NONE.java │ │ ├── SshWrapperExample.java │ │ └── Cipher.java │ │ └── telnet │ │ └── ScriptHandler.java ├── jni │ ├── Makefile │ ├── win32 │ │ └── Makefile │ ├── solaris │ │ └── Makefile │ └── linux │ │ └── Makefile ├── doc │ └── plugins │ │ └── keyCodes.at386 ├── JTA.iml └── README ├── doc ├── bothack-API.dia ├── bothack-API.png ├── bothack-comm.dia ├── bothack-comm.png ├── overview.html ├── config.md ├── compiling.md ├── issues.md └── running.md ├── javabots ├── bot-jars │ ├── JavaBot.jar │ └── SimpleBot.jar ├── JavaBot │ ├── config │ │ ├── javabot-shell-config.edn │ │ └── javabot-ssh-config.edn │ ├── src │ │ └── bothack │ │ │ └── javabots │ │ │ └── javabot │ │ │ ├── EnhanceHandler.java │ │ │ ├── MinorTroubleHandler.java │ │ │ ├── MajorTroubleHandler.java │ │ │ ├── ProgressHandler.java │ │ │ ├── RecoverHandler.java │ │ │ ├── JavaBot.java │ │ │ ├── FightHandler.java │ │ │ ├── GatherItems.java │ │ │ └── FeedHandler.java │ └── .project └── SimpleBot │ ├── config │ ├── simplebot-shell-config.edn │ ├── simplebot-telnet-config.edn │ └── simplebot-ssh-config.edn │ ├── .project │ └── src │ └── bothack │ └── javabots │ └── simplebot │ └── SimpleBot.java ├── java └── bothack │ ├── actions │ ├── package-info.java │ ├── Predicate.java │ ├── IAction.java │ └── NavOption.java │ ├── bot │ ├── Hunger.java │ ├── Alignment.java │ ├── items │ │ ├── BUC.java │ │ ├── package-info.java │ │ ├── ItemKind.java │ │ ├── ItemSubtype.java │ │ ├── ItemType.java │ │ ├── IItemType.java │ │ └── IItem.java │ ├── Encumbrance.java │ ├── monsters │ │ ├── package-info.java │ │ ├── MonsterType.java │ │ ├── IMonster.java │ │ └── IMonsterType.java │ ├── dungeon │ │ ├── package-info.java │ │ ├── EngravingType.java │ │ ├── IDungeon.java │ │ ├── RoomType.java │ │ ├── ILevel.java │ │ ├── LevelTag.java │ │ └── Feature.java │ ├── IAppearance.java │ ├── package-info.java │ ├── IPosition.java │ ├── IPredicate.java │ ├── IFrame.java │ ├── Stat.java │ ├── Direction.java │ ├── IBotHack.java │ ├── Intrinsic.java │ ├── Position.java │ ├── Color.java │ └── HaveOption.java │ ├── events │ ├── IGameStateHandler.java │ ├── IRedrawHandler.java │ ├── IMultilineMessageHandler.java │ ├── IAboutToChooseActionHandler.java │ ├── IDlvlChangeHandler.java │ ├── IFoundItemsHandler.java │ ├── IToplineMessageHandler.java │ ├── IActionChosenHandler.java │ ├── IFullFrameHandler.java │ ├── package-info.java │ └── IKnowPositionHandler.java │ └── prompts │ ├── IOfferHandler.java │ ├── IWhichRingFingerHandler.java │ ├── IStopEatingHandler.java │ ├── IIdentifyWhatHandler.java │ ├── ITeleportWhereHandler.java │ ├── IReallyAttackHandler.java │ ├── IPayDamageHandler.java │ ├── ILevelTeleportHandler.java │ ├── IDoTeleportHandler.java │ ├── IVaultGuardHandler.java │ ├── ISellItHandler.java │ ├── IChargeWhatHandler.java │ ├── IEnhanceWhatHandler.java │ ├── IMakeWishHandler.java │ ├── ISeducedHandler.java │ ├── IDirectionHandler.java │ ├── package-info.java │ ├── IGenocideHandler.java │ └── IActionHandler.java ├── save └── 1000wizard.gz-equipped-valk-3 ├── ttyrec ├── samurai-bot-asc.ttyrec.xz ├── wizmode-fullauto-asc.ttyrec.xz ├── first-bot-asc-ever-valk.ttyrec.xz └── wizmode-exploration-dlvl1-28medusa.ttyrec.xz ├── config ├── shell-config.edn ├── shell-wizmode-config.edn ├── shell-wizmode-wizbot-config.edn ├── telnet-config.edn ├── ssh-nao-config.edn └── ssh-config.edn ├── .gitignore ├── scripts ├── itemdata │ ├── Gold.pm-edn │ ├── Gold.pm-x │ ├── Statue.pm-edn │ ├── Statue.pm-x │ ├── Other.pm-edn │ ├── Other.pm-x │ ├── Amulet.pm-edn │ ├── Amulet.pm-x │ └── itemdata.sed ├── ttywatch.sh └── run.sh ├── .project ├── src ├── log4j.properties └── bothack │ ├── action.clj │ ├── bots │ ├── simplebot.clj │ ├── dgl_menu.clj │ └── dgl_menu_wizmode.clj │ ├── fov.clj │ ├── ttyrec.clj │ └── handlers.clj ├── bothack.nethackrc └── project.clj /jta26/CHANGES: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jta26/license/README: -------------------------------------------------------------------------------- 1 | Please see http://javatelnet.org/ 2 | -------------------------------------------------------------------------------- /jta26/bin/telnet: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | java -jar `dirname $0`/../jar/jta26.jar $* 3 | -------------------------------------------------------------------------------- /doc/bothack-API.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/doc/bothack-API.dia -------------------------------------------------------------------------------- /doc/bothack-API.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/doc/bothack-API.png -------------------------------------------------------------------------------- /jta26/html/users.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/jta26/html/users.db -------------------------------------------------------------------------------- /doc/bothack-comm.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/doc/bothack-comm.dia -------------------------------------------------------------------------------- /doc/bothack-comm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/doc/bothack-comm.png -------------------------------------------------------------------------------- /javabots/bot-jars/JavaBot.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/javabots/bot-jars/JavaBot.jar -------------------------------------------------------------------------------- /java/bothack/actions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Things the bot can do. 3 | */ 4 | package bothack.actions; -------------------------------------------------------------------------------- /javabots/bot-jars/SimpleBot.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/javabots/bot-jars/SimpleBot.jar -------------------------------------------------------------------------------- /java/bothack/bot/Hunger.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | public enum Hunger {FAINTING, WEAK, HUNGRY, SATIATED} 4 | -------------------------------------------------------------------------------- /save/1000wizard.gz-equipped-valk-3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/save/1000wizard.gz-equipped-valk-3 -------------------------------------------------------------------------------- /ttyrec/samurai-bot-asc.ttyrec.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/ttyrec/samurai-bot-asc.ttyrec.xz -------------------------------------------------------------------------------- /java/bothack/bot/Alignment.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | public enum Alignment {LAWFUL, NEUTRAL, CHAOTIC, UNALIGNED} 4 | -------------------------------------------------------------------------------- /java/bothack/bot/items/BUC.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.items; 2 | 3 | public enum BUC { 4 | UNCURSED, BLESSED, CURSED; 5 | } 6 | -------------------------------------------------------------------------------- /ttyrec/wizmode-fullauto-asc.ttyrec.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/ttyrec/wizmode-fullauto-asc.ttyrec.xz -------------------------------------------------------------------------------- /java/bothack/bot/items/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Representations of items and item types. 3 | */ 4 | package bothack.bot.items; -------------------------------------------------------------------------------- /ttyrec/first-bot-asc-ever-valk.ttyrec.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/ttyrec/first-bot-asc-ever-valk.ttyrec.xz -------------------------------------------------------------------------------- /jta26/jta.manifest: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: Matthias L. Jugel & Marcus Meißner (c) 1996-2005 3 | Main-Class: de/mud/jta/Main 4 | -------------------------------------------------------------------------------- /java/bothack/bot/Encumbrance.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | public enum Encumbrance {BURDENED, STRESSED, STRAINED, OVERTAXED, OVERLOADED} 4 | -------------------------------------------------------------------------------- /java/bothack/bot/monsters/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Representations of monsters and their properties. 3 | */ 4 | package bothack.bot.monsters; -------------------------------------------------------------------------------- /jta26/de/mud/jta/Build.java: -------------------------------------------------------------------------------- 1 | package de.mud.jta; public class Build implements Version { public String getDate() { return "cust2014-anbf"; } } 2 | -------------------------------------------------------------------------------- /ttyrec/wizmode-exploration-dlvl1-28medusa.ttyrec.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krajj7/BotHack/HEAD/ttyrec/wizmode-exploration-dlvl1-28medusa.ttyrec.xz -------------------------------------------------------------------------------- /java/bothack/bot/dungeon/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Representations of dungeon elements – branches, levels, tiles... 3 | */ 4 | package bothack.bot.dungeon; -------------------------------------------------------------------------------- /jta26/bin/ssh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | plugins="Status,Socket,SSH,Terminal" 3 | cdir=`pwd` 4 | java -classpath $CLASSPATH:$cdir de.mud.jta.Main -plugins $plugins $* 22 5 | -------------------------------------------------------------------------------- /config/shell-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :bot "bothack.bots.mainbot" 3 | :ttyrec true 4 | :interface :shell 5 | :nh-command "/nh343/nethack.343-nao" 6 | :no-exit true 7 | } 8 | -------------------------------------------------------------------------------- /jta26/de/mud/terminal/colorSet.conf: -------------------------------------------------------------------------------- 1 | color0 = black 2 | color1 = red 3 | color2 = green 4 | color3 = yellow 5 | color4 = blue 6 | color5 = magenta 7 | color6 = cyan 8 | color7 = white -------------------------------------------------------------------------------- /javabots/JavaBot/config/javabot-shell-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :javabot "bothack.javabots.javabot.JavaBot" 3 | :ttyrec true 4 | :interface :shell 5 | :nh-command "/nh343/nethack.343-nao" 6 | } 7 | -------------------------------------------------------------------------------- /jta26/bin/terminal: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | plugins="Shell,Terminal" 3 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/jar 4 | java -classpath $CLASSPATH:.:jar: de.mud.jta.Main -plugins $plugins $* 22 5 | -------------------------------------------------------------------------------- /javabots/SimpleBot/config/simplebot-shell-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :javabot "bothack.javabots.simplebot.SimpleBot" 3 | :ttyrec true 4 | :interface :shell 5 | :nh-command "/nh343/nethack.343-nao" 6 | } 7 | -------------------------------------------------------------------------------- /jta26/de/mud/terminal/keyCodes.conf: -------------------------------------------------------------------------------- 1 | # this file has been intentionally left empty 2 | # 3 | # F1=F1-pressed 4 | # ESCAPE=Escape 5 | # SESCAPE=Shift-Escape 6 | # CESCAPE=Control-Escape 7 | # AESCAPE=Alt-Escape 8 | -------------------------------------------------------------------------------- /config/shell-wizmode-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :bot "bothack.bots.mainbot" 3 | :ttyrec true 4 | :interface :shell 5 | ;:start-paused true 6 | :nh-command "/nh343/wizmode" ; runs NH with -D 7 | ;:no-exit true 8 | } 9 | -------------------------------------------------------------------------------- /java/bothack/bot/IAppearance.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | /** Immutable representation of a virtual terminal character. */ 4 | public interface IAppearance { 5 | Character glyph(); 6 | Color color(); 7 | } 8 | -------------------------------------------------------------------------------- /config/shell-wizmode-wizbot-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :bot "bothack.bots.wizbot" 3 | :ttyrec true 4 | :interface :shell 5 | ;:start-paused true 6 | :nh-command "/nh343/wizmode" ; runs NH with -D 7 | :no-exit true 8 | } 9 | -------------------------------------------------------------------------------- /config/telnet-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :bot "bothack.bots.simplebot" 3 | :interface :telnet 4 | :menubot "bothack.bots.dgl-menu" 5 | :host "nethack.alt.org" 6 | :port 23 7 | :dgl-login "quitbot" 8 | :dgl-pass "tops3cr3t" 9 | :dgl-game "2" 10 | :ttyrec true 11 | } 12 | -------------------------------------------------------------------------------- /java/bothack/bot/items/ItemKind.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.items; 2 | 3 | public enum ItemKind { 4 | SPELLBOOK, 5 | AMULET, 6 | WEAPON, 7 | WAND, 8 | GEM, 9 | ARMOR, 10 | FOOD, 11 | OTHER, 12 | TOOL, 13 | STATUE, 14 | SCROLL, 15 | RING, 16 | POTION; 17 | } 18 | -------------------------------------------------------------------------------- /java/bothack/bot/items/ItemSubtype.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.items; 2 | 3 | public enum ItemSubtype { 4 | HELMET, CLOAK, SUIT, SHIRT, SHIELD, GLOVES, BOOTS, ACCESSORY, AMULET, 5 | WEAPON, TOOL, CORPSE, INSTRUMENT, CANDELABRUM, CONTAINER, KEY, LIGHT, 6 | TRAP, FIGURINE; 7 | } 8 | -------------------------------------------------------------------------------- /config/ssh-nao-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :bot "bothack.bots.mainbot" 3 | :interface :telnet 4 | :menubot "bothack.bots.dgl-menu" 5 | :host "nethack.alt.org" 6 | :port 23 7 | :dgl-login "dumbbot" 8 | :dgl-pass "tops3cr3t" 9 | :dgl-game "2" 10 | :ttyrec true 11 | :no-exit true 12 | } 13 | -------------------------------------------------------------------------------- /java/bothack/events/IGameStateHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | /** Notification of game start or end. */ 4 | public interface IGameStateHandler { 5 | /** Called when the game starts. */ 6 | void started(); 7 | /** Called when the game ends. */ 8 | void ended(); 9 | } 10 | -------------------------------------------------------------------------------- /java/bothack/events/IRedrawHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | import bothack.bot.IFrame; 4 | 5 | /** Called every time the screen contents change. */ 6 | public interface IRedrawHandler { 7 | /** Called every time the screen contents change. */ 8 | void redraw(IFrame frame); 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | /classes 3 | /checkouts 4 | /pom.xml 5 | /lib/ 6 | /classes/ 7 | /targets/ 8 | .lein-deps-sum 9 | pom.xml.asc 10 | *.class 11 | /.lein-* 12 | /.nrepl-port 13 | /jta26/doc/source/ 14 | *.log* 15 | /jta26/jni/linux/libjtapty.so 16 | video 17 | notes 18 | *.lo 19 | .classpath 20 | -------------------------------------------------------------------------------- /jta26/jni/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS = win32 linux solaris 2 | 3 | ARCH = linux 4 | 5 | all: 6 | cd $(ARCH) && $(MAKE) 7 | 8 | clean: 9 | set -e ; for i in $(SUBDIRS) ; do (cd $$i && $(MAKE) clean) ; done 10 | 11 | realclean: 12 | set -e ; for i in $(SUBDIRS) ; do (cd $$i && $(MAKE) realclean) ; done 13 | -------------------------------------------------------------------------------- /javabots/SimpleBot/config/simplebot-telnet-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :javabot "bothack.javabots.simplebot.SimpleBot" 3 | :interface :telnet 4 | :menubot "bothack.bots.dgl-menu" 5 | :host "nethack.alt.org" 6 | :port 23 7 | :dgl-login "quitbot" 8 | :dgl-pass "tops3cr3t" 9 | :dgl-game "2" 10 | :ttyrec true 11 | } 12 | -------------------------------------------------------------------------------- /java/bothack/events/IMultilineMessageHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | /** Called when a fullscreen message is presented to the player. */ 4 | public interface IMultilineMessageHandler { 5 | /** Called when a fullscreen message is presented to the player. */ 6 | void messageLines(java.util.List lines); 7 | } 8 | -------------------------------------------------------------------------------- /java/bothack/prompts/IOfferHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when the player can choose the amount of gold to offer. */ 4 | public interface IOfferHandler { 5 | /** Called when the player can choose the amount of gold to offer. 6 | * @return Amount of gold to offer*/ 7 | Long offerHowMuch(String prompt); 8 | } 9 | -------------------------------------------------------------------------------- /javabots/JavaBot/config/javabot-ssh-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :javabot "bothack.javabots.javabot.JavaBot" 3 | :interface :ssh 4 | :menubot "bothack.bots.dgl-menu" 5 | :host "nethack.xd.cm" 6 | :port 22 7 | :ssh-user "nethack" 8 | :ssh-pass "" 9 | :dgl-login "quitbot" 10 | :dgl-pass "tops3cr3t" 11 | :dgl-game "3" 12 | :ttyrec true 13 | } 14 | -------------------------------------------------------------------------------- /config/ssh-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :bot "bothack.bots.mainbot" 3 | :interface :ssh 4 | :menubot "bothack.bots.dgl-menu" 5 | :host "nethack.xd.cm" 6 | :port 22 7 | :ssh-user "nethack" 8 | :ssh-pass "" 9 | :dgl-login "dumbbot" 10 | :dgl-pass "tops3cr3t" 11 | :dgl-game "3" 12 | :ttyrec true 13 | :no-exit false 14 | :quit-resumed true 15 | } 16 | -------------------------------------------------------------------------------- /javabots/SimpleBot/config/simplebot-ssh-config.edn: -------------------------------------------------------------------------------- 1 | { 2 | :javabot "bothack.javabots.simplebot.SimpleBot" 3 | :interface :ssh 4 | :menubot "bothack.bots.dgl-menu" 5 | :host "nethack.xd.cm" 6 | :port 22 7 | :ssh-user "nethack" 8 | :ssh-pass "" 9 | :dgl-login "quitbot" 10 | :dgl-pass "tops3cr3t" 11 | :dgl-game "3" 12 | :ttyrec true 13 | } 14 | -------------------------------------------------------------------------------- /java/bothack/events/IAboutToChooseActionHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | import bothack.bot.IGame; 4 | 5 | /** Called before IActionHandler#chooseAction is about to be triggered. */ 6 | public interface IAboutToChooseActionHandler { 7 | /** Called before IActionHandler#chooseAction is about to be triggered. */ 8 | void aboutToChoose(IGame gamestate); 9 | } 10 | -------------------------------------------------------------------------------- /java/bothack/prompts/IWhichRingFingerHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when you can choose which hand to put a ring on. */ 4 | public interface IWhichRingFingerHandler { 5 | /** Called when you can choose which hand to put a ring on. 6 | * The left hand is chosen by default. 7 | * @return 'r' or 'l' */ 8 | Character whichFinger(String prompt); 9 | } 10 | -------------------------------------------------------------------------------- /java/bothack/bot/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Representations of elements of the game world. 3 | *

All interfaces except for IBotHack are backed by immutable objects and can 4 | * be used as keys in a Map, shared freely between threads etc.

5 | *

None of these except IPredicate are meant to be implemented by user code.

6 | * @see bothack.bot.IBotHack#game() 7 | */ 8 | package bothack.bot; -------------------------------------------------------------------------------- /java/bothack/prompts/IStopEatingHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when the player is close to dying from overeating. */ 4 | public interface IStopEatingHandler { 5 | /** Called when the player is close to dying from overeating. 6 | * False is returned by default. 7 | * @return True to keep eating (and possibly die) */ 8 | Boolean stopEatingHandler(String prompt); 9 | } 10 | -------------------------------------------------------------------------------- /java/bothack/prompts/IIdentifyWhatHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when the player can choose items to identify. */ 4 | public interface IIdentifyWhatHandler { 5 | /** Called when the player can choose items to identify. 6 | * Escaped by default. 7 | * @return The slot of the item you want identified. */ 8 | Character identifyWhat(java.util.Map options); 9 | } 10 | -------------------------------------------------------------------------------- /java/bothack/prompts/ITeleportWhereHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | import bothack.bot.IPosition; 4 | 5 | /** Called when the player can teleport in a controlled way. */ 6 | public interface ITeleportWhereHandler { 7 | /** Called when the player can teleport in a controlled way. 8 | * Escaped by default. 9 | * @return Position to teleport to. */ 10 | IPosition teleportWhere(); 11 | } 12 | -------------------------------------------------------------------------------- /java/bothack/prompts/IReallyAttackHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when you move towards a peaceful monster. */ 4 | public interface IReallyAttackHandler { 5 | /** Called when you move towards a peaceful monster. 6 | * False is returned by default. 7 | * @param what The name of the monster 8 | * @return True to attack the monster */ 9 | Boolean reallyAttack(String what); 10 | } 11 | -------------------------------------------------------------------------------- /java/bothack/prompts/IPayDamageHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when the player is asked to pay damage caused in the shop. */ 4 | public interface IPayDamageHandler { 5 | /** 6 | * Called when the player is asked to pay damage caused in the shop. 7 | * The damage is paid for by default. 8 | * @return False to refuse paying for the damage. */ 9 | Boolean payDamage(String prompt); 10 | } 11 | -------------------------------------------------------------------------------- /java/bothack/events/IDlvlChangeHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | /** 4 | * Called when the player switches dungeon levels. 5 | * Game state may not be fully updated yet. 6 | */ 7 | public interface IDlvlChangeHandler { 8 | /** 9 | * Called when the player switches dungeon levels. 10 | * Game state may not be fully updated yet. 11 | */ 12 | void dlvlChanged(String oldDlvl, String newDlvl); 13 | } 14 | -------------------------------------------------------------------------------- /java/bothack/events/IFoundItemsHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | import bothack.bot.items.IItem; 4 | 5 | /** Called every time the player encounters items on his current tile and in containers on the tile. */ 6 | public interface IFoundItemsHandler { 7 | /** Called every time the player encounters items on his current tile and in containers on the tile. */ 8 | void foundItems(java.util.List items); 9 | } 10 | -------------------------------------------------------------------------------- /jta26/html/b2.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Example for a more wrapped button bar 3 | # 4 | button F1 "Pressed F1 key!" 5 | button F2 "Pressed F2 key!" 6 | break 7 | button F3 "Pressed F3 key!" 8 | break 9 | button F4 "Pressed F4 key!" 10 | button F5 "Pressed F5 key!" 11 | break 12 | button F6 "Pressed F6 key!" 13 | break 14 | button F7 "Pressed F7 key!" 15 | button F8 "Pressed F8 key!" 16 | break 17 | button F9 "Pressed F9 key!" 18 | break 19 | -------------------------------------------------------------------------------- /java/bothack/prompts/ILevelTeleportHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** 4 | * Called when the player can choose a level to teleport to. 5 | * Escaped by default. 6 | */ 7 | public interface ILevelTeleportHandler { 8 | /** 9 | * Called when the player can choose a level to teleport to. 10 | * Escaped by default. 11 | * @return The number of the level to teleport to 12 | */ 13 | Long leveltele(String prompt); 14 | } 15 | -------------------------------------------------------------------------------- /java/bothack/events/IToplineMessageHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | /** 4 | * Called when a message appears on the top line (without --More-- if any). 5 | * Game state may not be fully updated yet. 6 | */ 7 | public interface IToplineMessageHandler { 8 | /** 9 | * Called when a message appears on the top line (without --More-- if any). 10 | * Game state may not be fully updated yet. 11 | */ 12 | void message(String text); 13 | } 14 | -------------------------------------------------------------------------------- /java/bothack/prompts/IDoTeleportHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** 4 | * Called when the player is prompted whether or not he wants to teleport. 5 | * Escaped by default. 6 | */ 7 | public interface IDoTeleportHandler { 8 | /** 9 | * Called when the player is prompted whether or not he wants to teleport. 10 | * Escaped by default. 11 | * @return true if you want to teleport 12 | */ 13 | Boolean doTeleport(String prompt); 14 | } 15 | -------------------------------------------------------------------------------- /java/bothack/prompts/IVaultGuardHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when a guard finds the player in a vault. */ 4 | public interface IVaultGuardHandler { 5 | /** Called when a guard finds the player in a vault. 6 | * The prompt is escaped by default. If the bot doesn't drop its gold it will 7 | * be attacked. 8 | * @return "Croesus" to make the guard leave (leaving you possibly stuck in the vault) */ 9 | String whoAreYou(String prompt); 10 | } 11 | -------------------------------------------------------------------------------- /scripts/itemdata/Gold.pm-edn: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Gold; 2 | { 3 | $NetHack::Item::Spoiler::Gold::VERSION = "0.21";} 4 | use strict; 5 | use warnings; 6 | use base "NetHack::Item::Spoiler"; 7 | use constant type :gold; 8 | sub _list { 9 | return { 10 | {:name "gold piece" 11 | :price 1 12 | :weight 0.01 13 | :glyph \$ 14 | :plural "gold pieces" 15 | :stackable 1 16 | :material :gold} };} 17 | 1; 18 | -------------------------------------------------------------------------------- /java/bothack/events/IActionChosenHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | import bothack.actions.IAction; 4 | 5 | /** 6 | * Called with the action that was chosen in response to 7 | * {@link bothack.prompts.IActionHandler#chooseAction(bothack.bot.IGame)} 8 | * and is about to be triggered. 9 | */ 10 | public interface IActionChosenHandler { 11 | /** Called with the action that was chosen and is about to be triggered. */ 12 | void actionChosen(IAction action); 13 | } 14 | -------------------------------------------------------------------------------- /java/bothack/events/IFullFrameHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | import bothack.bot.IFrame; 4 | 5 | /** Called when the frame on screen is fully drawn – the cursor is on the player, 6 | * the map and status lines are completely drawn. */ 7 | public interface IFullFrameHandler { 8 | /** Called when the frame on screen is fully drawn – the cursor is on the player, 9 | * the map and status lines are completely drawn. */ 10 | void fullFrame(IFrame frame); 11 | } 12 | -------------------------------------------------------------------------------- /java/bothack/prompts/ISellItHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** 4 | * Called when you drop an item in a shop and the shopkeeper is interested 5 | * in buying it. 6 | */ 7 | public interface ISellItHandler { 8 | /** 9 | * Called when you drop an item in a shop and the shopkeeper is interested 10 | * in buying it. 11 | * False is returned by default. 12 | * 13 | * @return True to sell the item. 14 | */ 15 | Boolean sellIt(Integer offer, String what); 16 | } 17 | -------------------------------------------------------------------------------- /java/bothack/bot/IPosition.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | /** 4 | * Immutable representation of a position on the screen. 5 | * @see bothack.bot.Position#create(Long, Long) 6 | */ 7 | public interface IPosition extends clojure.lang.IPersistentMap { 8 | /** X coordinate on the screen – 0 to 79 */ 9 | Long x(); 10 | /** Y coordinate on the screen – 1 to 21 */ 11 | Long y(); 12 | // the Longs are probably wasteful but it's what's currently used internally (Clojure's default) 13 | } -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BotHack 4 | This Eclipse project is just for editing the Java API 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /java/bothack/actions/Predicate.java: -------------------------------------------------------------------------------- 1 | package bothack.actions; 2 | 3 | import bothack.bot.IPredicate; 4 | 5 | /** Makes IPredicate callable natively from clojure (by implementing IFn via AFn). 6 | * IPredicates are wrapped automatically – bots don't need to use this. */ 7 | class Predicate extends clojure.lang.AFn { 8 | final IPredicate p; 9 | 10 | Predicate(IPredicate p) { 11 | this.p = p; 12 | } 13 | 14 | @Override 15 | public Object invoke(Object x) { 16 | return p.apply(x); 17 | } 18 | } -------------------------------------------------------------------------------- /java/bothack/bot/IPredicate.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import bothack.actions.Navigation; 4 | 5 | /** 6 | * Custom filter function. Implement this for use with 7 | * {@link IGame#have}, 8 | * {@link Navigation#navigate}, {@link Navigation#seek} etc. 9 | */ 10 | public interface IPredicate { 11 | /** 12 | * Return true for things you are interested in. 13 | * This function may be run many times, don't do expensive computation here if you can avoid it. */ 14 | boolean apply(T input); 15 | } 16 | -------------------------------------------------------------------------------- /java/bothack/prompts/IChargeWhatHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when the player may choose an item to charge after reading 4 | * a scroll of charging. */ 5 | public interface IChargeWhatHandler { 6 | /** Called when the player may choose an item to charge after reading 7 | * a scroll of charging. Return the slot of the item to be charged. 8 | * Escaped by default. 9 | * 10 | * @return the slot of the item to be charged. 11 | */ 12 | Character chargeWhat(String prompt); 13 | } 14 | -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/EnhanceHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.actions.ActionsComplex; 4 | import bothack.actions.IAction; 5 | import bothack.bot.IGame; 6 | import bothack.prompts.IActionHandler; 7 | 8 | public class EnhanceHandler implements IActionHandler { 9 | 10 | public IAction chooseAction(IGame game) { 11 | if (game.player().canEnhance()) { 12 | return ActionsComplex.enhanceAll(game); 13 | } else { 14 | return null; 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /java/bothack/prompts/IEnhanceWhatHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | import bothack.actions.ActionsComplex; 4 | 5 | /** Called when the Enhance skill menu appears with a choice of skill to enhance. 6 | * @see ActionsComplex#enhanceAll(bothack.bot.IGame) */ 7 | public interface IEnhanceWhatHandler { 8 | /** Called when the Enhance skill menu appears with a choice of skill to enhance. 9 | * @see ActionsComplex#enhanceAll(bothack.bot.IGame) */ 10 | Character enhanceWhat(java.util.Map options); 11 | } 12 | -------------------------------------------------------------------------------- /java/bothack/prompts/IMakeWishHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when the player can make a wish. */ 4 | public interface IMakeWishHandler { 5 | /** Called when the player can make a wish. 6 | * For auto-identification to work use a "standard" item label 7 | * (same as the item would appear in inventory) 8 | * Nothing is wished for by default. 9 | * 10 | * @return Label of the item to wish for, with the same order of modifiers 11 | * as would appear in the inventory */ 12 | String makeWish(String prompt); 13 | } 14 | -------------------------------------------------------------------------------- /scripts/itemdata/Gold.pm-x: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Gold; 2 | { 3 | $NetHack::Item::Spoiler::Gold::VERSION = '0.21'; } 4 | use strict; 5 | use warnings; 6 | use base 'NetHack::Item::Spoiler'; 7 | 8 | use constant type => 'gold'; 9 | 10 | sub _list { 11 | return { 12 | 'gold piece' => { 13 | price => 1, 14 | weight => 0.01, 15 | glyph => '$', 16 | plural => 'gold pieces', 17 | stackable => 1, 18 | material => 'gold', } }; } 19 | 20 | 1; 21 | 22 | 23 | -------------------------------------------------------------------------------- /java/bothack/prompts/ISeducedHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | /** Called when a succubus or an incubus makes a request. */ 4 | public interface ISeducedHandler { 5 | /** Called when a succubus or an incubus makes a request to put on a ring. 6 | * False is returned by default. 7 | * @return True to put the ring on.*/ 8 | Boolean seducedPuton(); 9 | /** Called when a succubus or an incubus makes a request to remove your clothing. 10 | * False is returned by default. 11 | * @return True to strip.*/ 12 | Boolean seducedRemove(); 13 | } 14 | -------------------------------------------------------------------------------- /java/bothack/events/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Notifications for things that happen in the game world. 3 | * 4 | *

All registered handlers are invoked for each event in priority order.

5 | * 6 | *

The bot may implement these if found useful. The framework automatically 7 | * uses information from these events to update the game state.

8 | * 9 | *

There are more undocumented event types in the package bothack.internal.

10 | * 11 | * @see bothack.bot.IBotHack#registerHandler(Integer, Object) 12 | */ 13 | package bothack.events; -------------------------------------------------------------------------------- /java/bothack/events/IKnowPositionHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.events; 2 | 3 | import bothack.bot.IFrame; 4 | 5 | /** 6 | * Called when the cursor is on the player – 7 | * besides full frames this also occurs on location prompts. 8 | * Game state may not be fully updated yet. 9 | */ 10 | public interface IKnowPositionHandler { 11 | /** 12 | * Called when the cursor is on the player – 13 | * besides full frames this also occurs on location prompts. 14 | * Game state may not be fully updated yet. 15 | */ 16 | void knowPosition(IFrame frame); 17 | } 18 | -------------------------------------------------------------------------------- /java/bothack/bot/dungeon/EngravingType.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.dungeon; 2 | 3 | import clojure.lang.Keyword; 4 | 5 | public enum EngravingType { 6 | /** Temporary engraving. */ 7 | DUST(Keyword.intern(null, "dust")), 8 | /** Semi-permanent engraving. */ 9 | SEMI(Keyword.intern(null, "semi")), 10 | /** Permanent engraving. */ 11 | PERMANENT(Keyword.intern(null, "permanent")); 12 | 13 | private final Keyword kw; 14 | 15 | private EngravingType(Keyword kw) { 16 | this.kw = kw; 17 | } 18 | 19 | public Keyword getKeyword() { 20 | return kw; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /java/bothack/bot/dungeon/IDungeon.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.dungeon; 2 | 3 | import java.util.Map; 4 | 5 | /** Immutable representation of the dungeon level tree. */ 6 | public interface IDungeon { 7 | /** Returns the Dlvl => ILevel map for the branch, if it was already visited and recognized. */ 8 | Map getBranch(Branch branch); 9 | /** Returns a level by Branch and Dlvl, if such was already visited. */ 10 | ILevel getLevel(Branch branch, String dlvl); 11 | /** Returns a level by Branch and tag, if such was already visited and identified. */ 12 | ILevel getLevel(Branch branch, LevelTag tag); 13 | } 14 | -------------------------------------------------------------------------------- /scripts/ttywatch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # keeps playing the most recent (growing) ttyrec 4 | 5 | if [ $(basename `pwd`) = "scripts" ]; then 6 | cd .. 7 | fi 8 | 9 | trap "exit" INT TERM && trap "kill 0" EXIT 10 | 11 | tail -F bothack.log 2>/dev/null | egrep --color=auto 'ERROR|WARN' & # barf any errors over the output 12 | last=$(ls -1 *.ttyrec | tail -n 1) 13 | clear; ttyplay -p "$last" & 14 | while true; do 15 | sleep 3 16 | new=$(ls -1 *.ttyrec | tail -n 1) 17 | if [ "$new" != "$last" ]; then 18 | kill %% 19 | last="$new" 20 | clear; ttyplay -p "$new" & 21 | fi 22 | done 23 | -------------------------------------------------------------------------------- /src/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=DEBUG, file, stdout 2 | 3 | log4j.appender.file=org.apache.log4j.RollingFileAppender 4 | log4j.appender.file.File=bothack.log 5 | log4j.appender.file.MaxFileSize=10MB 6 | log4j.appender.file.MaxBackupIndex=15 7 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1}:%L - %m%n 9 | 10 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 11 | log4j.appender.stdout.Target=System.out 12 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 13 | log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c{1}:%L - %m%n 14 | -------------------------------------------------------------------------------- /javabots/JavaBot/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | javabot 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /java/bothack/bot/IFrame.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import java.util.Map; 4 | 5 | /** Immutable representation of a 80x24 virtual terminal. */ 6 | public interface IFrame { 7 | /** Cursor position on the virtual terminal. */ 8 | public IPosition cursor(); 9 | /** The color of the glyph at given position on the virtual terminal. */ 10 | public Color colorAt(IPosition pos); 11 | /** The glyph at given position on the virtual terminal. */ 12 | public Character glyphAt(IPosition pos); 13 | /** 14 | * The row of text at the given y-coordinate on the virtual terminal. 15 | * @param y 0 to 23 inclusive. 16 | */ 17 | public String line(Long y); 18 | } 19 | -------------------------------------------------------------------------------- /src/bothack/action.clj: -------------------------------------------------------------------------------- 1 | (ns bothack.action 2 | (:require [clojure.tools.logging :as log])) 3 | 4 | (defprotocol Action 5 | (handler [this bh] 6 | "Retuns nil or an event/prompt handler that will be registered just 7 | before executing the action and deregistered when the next action is 8 | chosen. May also modify the game state immediately without 9 | returning a handler.") 10 | (trigger [this] 11 | "Returns the string to write to NetHack to perform the action.")) 12 | 13 | (extend-type bothack.actions.IAction 14 | Action 15 | (handler [this bh] (.handler this bh)) 16 | (trigger [this] (.trigger this))) 17 | -------------------------------------------------------------------------------- /javabots/SimpleBot/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | simplebot 4 | BotHack bot skeleton 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /java/bothack/actions/IAction.java: -------------------------------------------------------------------------------- 1 | package bothack.actions; 2 | 3 | import bothack.bot.IBotHack; 4 | 5 | /** 6 | * Representation of a primitive BotHack action. 7 | * This is not meant to be implemented by user code. 8 | * @see Actions 9 | */ 10 | public interface IAction { 11 | /** 12 | * Retuns null or an event/prompt handler that will be registered just 13 | * before executing the action and deregistered when the next action is 14 | * chosen. May also modify the game state immediately without returning 15 | * a handler. 16 | */ 17 | Object handler(IBotHack bh); 18 | /** Returns the string to write to NetHack to trigger the action. */ 19 | String trigger(); 20 | } 21 | -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/MinorTroubleHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.actions.Actions; 4 | import bothack.actions.ActionsComplex; 5 | import bothack.actions.IAction; 6 | import bothack.bot.IGame; 7 | import bothack.bot.IPlayer; 8 | import bothack.prompts.IActionHandler; 9 | 10 | public class MinorTroubleHandler implements IActionHandler { 11 | public IAction chooseAction(IGame game) { 12 | IPlayer player = game.player(); 13 | if (player.polymorphed() != null || player.isBlind() || player.isDizzy()) { 14 | return ActionsComplex.withReason(Actions.Search(), "waiting out minor trouble"); 15 | } 16 | return null; 17 | } 18 | } -------------------------------------------------------------------------------- /java/bothack/bot/Stat.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import clojure.lang.Keyword; 4 | 5 | public enum Stat { 6 | /** Charisma */ 7 | CHA(Keyword.intern(null, "cha")), 8 | /** Wisdom */ 9 | WIS(Keyword.intern(null, "wis")), 10 | /** Intelligence */ 11 | INT(Keyword.intern(null, "int")), 12 | /** Constitution */ 13 | CON(Keyword.intern(null, "con")), 14 | /** Dexterity */ 15 | DEX(Keyword.intern(null, "dex")), 16 | /** Strength */ 17 | STR(Keyword.intern(null, "str")); 18 | 19 | private final Keyword kw; 20 | private Stat(Keyword kw) { 21 | this.kw = kw; 22 | } 23 | 24 | public Keyword getKeyword() { 25 | return kw; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /doc/overview.html: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 |

BotHack — A Nethack Bot Framework.

7 | 8 |
9 |

API overview diagram (selection of types and methods):

10 | API overview diagram 11 | 12 |
13 | 14 |

Component communication diagram:

15 | component communication diagram 16 | 17 | 18 | -------------------------------------------------------------------------------- /java/bothack/prompts/IDirectionHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | import bothack.bot.Direction; 4 | 5 | /** 6 | * Called when a direction prompt is presented to the player. 7 | * Most of these prompts should get handled automatically via primitive actions 8 | * (use ApplyAt instead of Apply, ZapWandAt instead of ZapWand etc.). 9 | * Escaped by default. 10 | */ 11 | public interface IDirectionHandler { 12 | /** 13 | * Called when a direction prompt is presented to the player. 14 | * Most of these prompts should get handled automatically via primitive actions 15 | * (use ApplyAt instead of Apply, ZapWandAt instead of ZapWand etc.). 16 | * Escaped by default. 17 | */ 18 | Direction whatDirection(); 19 | } 20 | -------------------------------------------------------------------------------- /java/bothack/prompts/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Prompts from the game that the bot may have to respond to. 3 | * 4 | *

Prompt handlers are invoked on registered handlers in priority order until 5 | * one of them returns a non-null value. This value is used as the response and 6 | * no more handlers are invoked. The framework may handle some prompts 7 | * automatically via actions before they reach bot handlers.

8 | * 9 | *

There are many more types of prompts that the framework always handles 10 | * automatically via actions or default handlers. These are undocumented but 11 | * available in the package bothack.internal.

12 | * 13 | * @see bothack.bot.IBotHack#registerHandler(Integer, Object) 14 | */ 15 | package bothack.prompts; -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/MajorTroubleHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.actions.Actions; 4 | import bothack.actions.ActionsComplex; 5 | import bothack.actions.IAction; 6 | import bothack.bot.Hunger; 7 | import bothack.bot.IGame; 8 | import bothack.prompts.IActionHandler; 9 | 10 | class MajorTroubleHandler implements IActionHandler { 11 | public IAction chooseAction(IGame game) { 12 | if ((game.player().hunger() == Hunger.FAINTING 13 | || game.player().hasLycantrophy() 14 | || game.player().isIll() 15 | || (game.player().HP() < 11 && game.player().maxHP() > 30)) 16 | && game.canPray()) 17 | return ActionsComplex.withReason(Actions.Pray(), "major trouble"); 18 | return null; 19 | } 20 | } -------------------------------------------------------------------------------- /java/bothack/prompts/IGenocideHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | import bothack.bot.IGame; 4 | 5 | /** Called when the player can choose monsters to genocide. */ 6 | public interface IGenocideHandler { 7 | /** 8 | * Called when the player can choose a class of monsters to genocide. 9 | * Nothing is genocided by default. 10 | * @param prompt The prompt text 11 | * @return A character representing the class to genocide 12 | * @see IGame#genocided() */ 13 | Character genocideClass(String prompt); 14 | /** 15 | * Called when the player can choose a single monster type to genocide. 16 | * Nothing is genocided by default. 17 | * @param prompt The prompt text 18 | * @return The name of the monster type to genocide 19 | * @see IGame#genocided() 20 | */ 21 | String genocideMonster(String prompt); 22 | } 23 | -------------------------------------------------------------------------------- /java/bothack/bot/items/ItemType.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.items; 2 | 3 | import java.util.List; 4 | 5 | import clojure.java.api.Clojure; 6 | 7 | /** Factory and utility functions for item types. */ 8 | public final class ItemType { 9 | private ItemType() {}; 10 | 11 | static { 12 | Clojure.var("clojure.core", "require").invoke(Clojure.read("bothack.itemtype")); 13 | } 14 | 15 | /** If the name is a recognized NetHack item returns its IItemType. 16 | * @see IItem#name() */ 17 | public static IItemType byName(String name) { 18 | return (IItemType) Clojure.var("bothack.itemtype", "name->item").invoke(name); 19 | } 20 | 21 | /** Return the list of all item types in NetHack. */ 22 | public static List allItems() { 23 | return (List) Clojure.var("clojure.core", "vec").invoke(Clojure.var("bothack.itemtype", "items")); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /java/bothack/prompts/IActionHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.prompts; 2 | 3 | import bothack.actions.Actions; 4 | import bothack.actions.ActionsComplex; 5 | import bothack.actions.IAction; 6 | import bothack.bot.IGame; 7 | 8 | /** 9 | * This is the most crucial interface to implement in your bot 10 | * (in one or more registered handlers). 11 | * 12 | * If no action is chosen by any handler the framework will quit the game by 13 | * default. 14 | * If you set ":no-exit true" in the configuration an IllegalStateException will 15 | * be thrown instead. 16 | */ 17 | public interface IActionHandler { 18 | /** 19 | * Called when the game state is fully updated and NetHack is expecting 20 | * a player action. 21 | * 22 | * @return The action to be performed in the next turn 23 | * 24 | * @see Actions 25 | * @see ActionsComplex 26 | */ 27 | IAction chooseAction(IGame gamestate); 28 | } -------------------------------------------------------------------------------- /scripts/itemdata/Statue.pm-edn: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Statue; 2 | { 3 | $NetHack::Item::Spoiler::Statue::VERSION = "0.21";} 4 | use strict; 5 | use warnings; 6 | use base "NetHack::Item::Spoiler"; 7 | use NetHack::Monster::Spoiler; 8 | use constant type "statue"; 9 | sub _list { 10 | my %statues; 11 | for my $monster (NetHack::Monster::Spoiler->list) { 12 | my $name = "statue of "; 13 | $name .= "the " if $monster->is_unique && !$monster->has_proper_name; 14 | $name .= $monster->name =~ /^[aeiou]/i ? "an " : "a " 15 | if !$monster->is_unique; 16 | $name .= $monster->name; 17 | $statues{$name} = { 18 | :price 0 19 | :weight 900 20 | :glyph \` 21 | :sdam "d20" 22 | :ldam "d20" 23 | :nutrition 2500 24 | :material :mineral 25 | :monster $monster}} 26 | return \%statues;} 27 | 1; 28 | -------------------------------------------------------------------------------- /java/bothack/bot/monsters/MonsterType.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.monsters; 2 | 3 | import java.util.List; 4 | 5 | import clojure.java.api.Clojure; 6 | 7 | /** Factory and utility functions for item types. */ 8 | public final class MonsterType { 9 | private MonsterType() {}; 10 | 11 | static { 12 | Clojure.var("clojure.core", "require").invoke(Clojure.read("bothack.montype")); 13 | } 14 | 15 | /** If the name is a NetHack monster returns its IMonsterType. 16 | * Also works for all-lowercase name variants. 17 | * @see IMonsterType#name() */ 18 | public static IMonsterType byName(String name) { 19 | return (IMonsterType) Clojure.var("bothack.montype", "name->monster").invoke(name); 20 | } 21 | 22 | /** Return the list of all monster types recognized by BotHack. */ 23 | public static List allMonsters() { 24 | return (List) Clojure.var("bothack.montype", "monster-types"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/bothack/bots/simplebot.clj: -------------------------------------------------------------------------------- 1 | (ns bothack.bots.simplebot 2 | "A dumb example bot. Equivalent to SimpleBot.java" 3 | (:require [clojure.tools.logging :as log] 4 | [bothack.bothack :refer :all] 5 | [bothack.handlers :refer :all] 6 | [bothack.player :refer :all] 7 | [bothack.delegator :refer :all] 8 | [bothack.actions :refer :all])) 9 | 10 | (def ^:private circle-small (cycle [:N :E :S :W])) 11 | 12 | (defn- circle-mover [] 13 | (let [circle (atom circle-small)] 14 | (reify ActionHandler 15 | (choose-action [_ _] 16 | (->Move (first (swap! circle rest))))))) 17 | 18 | (defn- pray-for-food [] 19 | (reify ActionHandler 20 | (choose-action [_ game] 21 | (if (fainting? (:player game)) 22 | (->Pray))))) 23 | 24 | (defn init [bh] 25 | (-> bh 26 | (register-handler 0 (pray-for-food)) 27 | (register-handler 1 (circle-mover)))) 28 | -------------------------------------------------------------------------------- /java/bothack/bot/monsters/IMonster.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.monsters; 2 | 3 | import bothack.bot.IAppearance; 4 | import bothack.bot.IPosition; 5 | 6 | /** Immutable representation a monster on a level. 7 | * It may be currently seen or otherwise known or just remembered by the monster tracker. 8 | * @see IMonster#isRemembered() */ 9 | public interface IMonster extends IPosition,IAppearance { 10 | /** Turn number when the monster was last seen or otherwise known. */ 11 | Long lastKnown(); 12 | /** Type of the monster if known, else null */ 13 | IMonsterType type(); 14 | /** True if the monster was seen moving. */ 15 | Boolean isAwake(); 16 | /** True for tame monsters */ 17 | Boolean isFriendly(); 18 | /** True for peaceful monsters */ 19 | Boolean isPeaceful(); 20 | /** True if the monster is not currently known to be there. */ 21 | Boolean isRemembered(); 22 | /** True if the monster moved in the last turn */ 23 | Boolean hasJustMoved(); 24 | } 25 | -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/ProgressHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.actions.IAction; 4 | import bothack.actions.Navigation; 5 | import bothack.bot.IGame; 6 | import bothack.bot.dungeon.Branch; 7 | import bothack.bot.dungeon.LevelTag; 8 | import bothack.prompts.IActionHandler; 9 | 10 | class ProgressHandler implements IActionHandler { 11 | public IAction chooseAction(IGame game) { 12 | IAction res = null; 13 | res = Navigation.explore(game, Branch.MAIN, LevelTag.ORACLE); 14 | if (res != null) 15 | return res; 16 | res = Navigation.explore(game, Branch.MINES, LevelTag.MINETOWN); 17 | if (res != null) 18 | return res; 19 | res = Navigation.explore(game, Branch.MAIN, LevelTag.QUEST); 20 | if (res != null) 21 | return res; 22 | res = Navigation.explore(game, Branch.MINES); 23 | if (res != null) 24 | return res; 25 | res = Navigation.explore(game, Branch.MAIN); 26 | return res; 27 | } 28 | } -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/RecoverHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.actions.Actions; 4 | import bothack.actions.ActionsComplex; 5 | import bothack.actions.IAction; 6 | import bothack.actions.Navigation; 7 | import bothack.actions.Navigation.IPath; 8 | import bothack.bot.IGame; 9 | import bothack.bot.IPredicate; 10 | import bothack.bot.dungeon.ITile; 11 | import bothack.prompts.IActionHandler; 12 | 13 | public class RecoverHandler implements IActionHandler { 14 | public IAction chooseAction(IGame game) { 15 | 16 | IPath res = null; 17 | res = Navigation.navigate(game, new IPredicate() { 18 | public boolean apply(ITile i) { 19 | return i.hasNewItems(); 20 | } 21 | }, 5); 22 | if (res != null && res.step() != null) 23 | return res.step(); 24 | 25 | if ((double)game.player().HP() / game.player().maxHP() < 8.0/10.0) 26 | return ActionsComplex.withReason(Actions.Search(), "recovering"); 27 | return null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /scripts/itemdata/Statue.pm-x: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Statue; 2 | { 3 | $NetHack::Item::Spoiler::Statue::VERSION = '0.21'; } 4 | use strict; 5 | use warnings; 6 | use base 'NetHack::Item::Spoiler'; 7 | use NetHack::Monster::Spoiler; 8 | 9 | use constant type => 'statue'; 10 | 11 | sub _list { 12 | my %statues; 13 | 14 | for my $monster (NetHack::Monster::Spoiler->list) { 15 | my $name = "statue of "; 16 | $name .= "the " if $monster->is_unique && !$monster->has_proper_name; 17 | $name .= $monster->name =~ /^[aeiou]/i ? "an " : "a " 18 | if !$monster->is_unique; 19 | $name .= $monster->name; 20 | 21 | $statues{$name} = { 22 | price => 0, 23 | weight => 900, 24 | glyph => '`', 25 | sdam => 'd20', 26 | ldam => 'd20', 27 | nutrition => 2500, 28 | material => 'mineral', 29 | monster => $monster, } } 30 | 31 | return \%statues; } 32 | 33 | 1; 34 | 35 | 36 | -------------------------------------------------------------------------------- /java/bothack/bot/Direction.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import clojure.java.api.Clojure; 4 | import clojure.lang.Keyword; 5 | 6 | public enum Direction { 7 | N(Keyword.intern(null, "N")), 8 | NE(Keyword.intern(null, "NE")), 9 | E(Keyword.intern(null, "E")), 10 | SE(Keyword.intern(null, "SE")), 11 | S(Keyword.intern(null, "S")), 12 | SW(Keyword.intern(null, "SW")), 13 | W(Keyword.intern(null, "W")), 14 | NW(Keyword.intern(null, "NW")), 15 | DOWN(Keyword.intern(null, ">")), 16 | UP(Keyword.intern(null, "<")), 17 | HERE(Keyword.intern(null, ".")); 18 | 19 | static { 20 | Clojure.var("clojure.core", "require").invoke(Clojure.read("bothack.position")); 21 | } 22 | 23 | private final Keyword kw; 24 | 25 | private Direction(Keyword kw) { 26 | this.kw = kw; 27 | } 28 | 29 | public Keyword getKeyword() { 30 | return kw; 31 | } 32 | 33 | public static Direction towards(IPosition p1, IPosition p2) { 34 | return Direction.valueOf(((Keyword) Clojure.var("bothack.position", "towards").invoke(p1, p2)).getName()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /java/bothack/bot/dungeon/RoomType.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.dungeon; 2 | 3 | import clojure.lang.Keyword; 4 | 5 | public enum RoomType { 6 | /** Unknown shop. */ 7 | SHOP(Keyword.intern(null, "shop")), 8 | /** Only marked around the altar. */ 9 | TEMPLE(Keyword.intern(null, "temple")), 10 | /** General shop. */ 11 | GENERAL(Keyword.intern(null, "general")), 12 | /** Armor shop. */ 13 | ARMOR(Keyword.intern(null, "armor")), 14 | /** Book shop. */ 15 | BOOK(Keyword.intern(null, "book")), 16 | /** Potion shop. */ 17 | POTION(Keyword.intern(null, "potion")), 18 | /** Weapon shop. */ 19 | WEAPON(Keyword.intern(null, "weapon")), 20 | /** Food shop / delicatessen. */ 21 | FOOD(Keyword.intern(null, "food")), 22 | /** Gem and jewelry shop. */ 23 | GEM(Keyword.intern(null, "gem")), 24 | /** Wand shop. */ 25 | WAND(Keyword.intern(null, "wand")), 26 | /** Tool shop. */ 27 | TOOL(Keyword.intern(null, "tool")), 28 | /** Light shop. */ 29 | LIGHT(Keyword.intern(null, "light")); 30 | 31 | private final Keyword kw; 32 | 33 | private RoomType(Keyword kw) { 34 | this.kw = kw; 35 | } 36 | 37 | public Keyword getKeyword() { 38 | return kw; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | public interface Version { 28 | public String getDate(); 29 | } 30 | -------------------------------------------------------------------------------- /scripts/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # restore save (hardcoded), archive old logs/ttyrecs, compile and run in REPL with 4 | # hardcoded config. 5 | # might want to run ttywatch.sh in another console to watch the bot play. 6 | 7 | ARCH_DIR=~/tmp 8 | 9 | CONFIG="config/shell-config.edn" 10 | NH_VAR="/nh343/var" 11 | #CONFIG="config/shell-wizmode-chobot-config.edn" 12 | #SAVE="save/1000wizard.gz-equipped-valk-3" 13 | #SAVE="save/1000wizard.gz-floating-blindfold" 14 | #SAVE="save/1000wizard.gz-throwing" 15 | 16 | if [ $(basename `pwd`) = "scripts" ]; then 17 | cd .. 18 | fi 19 | 20 | arch="$ARCH_DIR/$(date +%Y-%m-%d.%H-%M-%S)" 21 | mkdir -pv "$arch" 22 | mv *.log* *.ttyrec "$NH_VAR"/save/* "$NH_VAR"/bon* "$arch" 23 | if [ -n "$SAVE" ]; then 24 | cp -v "$SAVE" "$NH_VAR"/save/1000wizard.gz 25 | fi 26 | # LD_LIBRARY_PATH is necessary for the local shell interface (not needed for 27 | # ssh/telnet), the JNI interface must be compiled manually beforehand 28 | if [ "$1" = "repl" ]; then 29 | lein compile && LD_LIBRARY_PATH=jta26/jni/linux/ lein repl 30 | else 31 | lein compile && (echo "(-main \"$CONFIG\")" 32 | cat -) | LD_LIBRARY_PATH=jta26/jni/linux/ lein repl 33 | fi 34 | -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/JavaBot.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.bot.IBotHack; 4 | 5 | /** This is an example of a bot using the Java API. 6 | * It is a very basic bot, doing only minimal things to demonstrate and test 7 | * basic functionality of the API. You can expect it to die fairly quickly. 8 | * See {@link https://github.com/krajj7/BotHack/blob/master/doc/running.md} 9 | * for how to run it. */ 10 | public class JavaBot { 11 | public JavaBot(IBotHack bothack) { 12 | // All of these implement IActionHandler and will be invoked in priority 13 | // order until one of them returns a non-null value (the action to perform). 14 | bothack.registerHandler(-16, new EnhanceHandler()); 15 | bothack.registerHandler(-11, new MajorTroubleHandler()); 16 | bothack.registerHandler(-6, new FightHandler()); 17 | bothack.registerHandler(-3, new MinorTroubleHandler()); 18 | bothack.registerHandler(1, new FeedHandler()); 19 | bothack.registerHandler(3, new RecoverHandler()); 20 | bothack.registerHandler(6, new GatherItems()); 21 | bothack.registerHandler(19, new ProgressHandler()); 22 | System.out.println("bot initialized"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /java/bothack/bot/dungeon/ILevel.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.dungeon; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import bothack.bot.IPosition; 7 | import bothack.bot.monsters.IMonster; 8 | 9 | /** Immutable representation of a dungeon level with its inhabitants. */ 10 | public interface ILevel { 11 | /** Returns the Dlvl string for the level. */ 12 | String dlvl(); 13 | /** Returns the branch this level belongs to. */ 14 | Branch branch(); 15 | /** Returns the tile at given position on the level. */ 16 | ITile at(IPosition pos); 17 | /** Returns the map of all monsters known or remembered to be on the level. */ 18 | Map monsters(); 19 | /** Returns the monster representation at the given position. */ 20 | IMonster monsterAt(IPosition pos); 21 | /** Returns the list of tiles on the level adjacent to position pos. */ 22 | List neighbors(IPosition pos); 23 | /** True if the level contains a temple. */ 24 | Boolean hasTemple(); 25 | /** True if the level contains an altar. */ 26 | Boolean hasAltar(); 27 | /** True if the level contains a shop. */ 28 | Boolean hasShop(); 29 | /** True if the level floor can be dug through (until proven otherwise). */ 30 | Boolean hasDiggableFloor(); 31 | } 32 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/Build.java.tmpl: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | 26 | package de.mud.jta; 27 | 28 | /** 29 | * The build class shows the date and time if the release 30 | */ 31 | public class Build implements Version { 32 | public String getDate() { 33 | return "@date@"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/bothack/fov.clj: -------------------------------------------------------------------------------- 1 | (ns bothack.fov 2 | (:import [bothack NHFov NHFov$TransparencyInfo]) 3 | (:require [clojure.tools.logging :as log] 4 | [bothack.dungeon :refer :all] 5 | [bothack.player :refer :all] 6 | [bothack.tile :refer :all] 7 | [bothack.util :refer :all])) 8 | 9 | (defn update-fov [game cursor] 10 | (let [level (curlvl game)] 11 | (assoc game :fov 12 | (.calculateFov (NHFov.) (:x cursor) (dec (:y cursor)) 13 | (reify NHFov$TransparencyInfo 14 | (isTransparent [_ x y] 15 | (boolean 16 | (if (and (< 0 y 20) (< 0 x 79)) 17 | (transparent? 18 | (get-in level [:tiles y x])))))))))) 19 | 20 | (defn in-fov? [game pos] 21 | (get-in game [:fov (dec (:y pos)) (:x pos)])) 22 | 23 | (defn visible? 24 | "Only considers normal sight, not infravision/ESP/..." 25 | ([game pos] (visible? game (curlvl game) pos)) 26 | ([{:keys [player] :as game} level pos] ; checking visibility only makes sense for current level, if supplied explicitly it performs faster in tight loops (for each tile etc.) 27 | (and (not (blind? player)) 28 | (in-fov? game pos) 29 | (lit? player level pos)))) 30 | -------------------------------------------------------------------------------- /javabots/SimpleBot/src/bothack/javabots/simplebot/SimpleBot.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.simplebot; 2 | 3 | import bothack.actions.*; 4 | import bothack.bot.*; 5 | import bothack.prompts.*; 6 | 7 | /** A dumb example bot. Equivalent to simplebot.clj 8 | * All the bot does is run in a circle until it dies. 9 | * See the JavaBot project for a slightly more advanced example bot. 10 | * See {@link https://github.com/krajj7/BotHack/blob/master/doc/running.md} 11 | * for how to run this. */ 12 | public class SimpleBot { 13 | IBotHack bothack; 14 | 15 | class CircleMover implements IActionHandler { 16 | Direction[] smallCircle = {Direction.N, Direction.E, Direction.S, Direction.W}; 17 | int next = 0; 18 | 19 | public IAction chooseAction(IGame game) { 20 | next = next % smallCircle.length; 21 | return Actions.Move(smallCircle[next++]); 22 | } 23 | } 24 | 25 | class PrayForFood implements IActionHandler { 26 | public IAction chooseAction(IGame game) { 27 | if (game.player().hunger() == Hunger.FAINTING) 28 | return Actions.Pray(); 29 | else 30 | return null; 31 | } 32 | } 33 | 34 | public SimpleBot(IBotHack bothack) { 35 | this.bothack = bothack; 36 | bothack.registerHandler(0, new PrayForFood()); 37 | bothack.registerHandler(1, new CircleMover()); 38 | System.out.println("bot initialized"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jta26/de/mud/terminal/VDUDisplay.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | 26 | package de.mud.terminal; 27 | 28 | /** 29 | * Generic display 30 | */ 31 | public interface VDUDisplay { 32 | public void redraw(); 33 | public void updateScrollBar(); 34 | 35 | public void setVDUBuffer(VDUBuffer buffer); 36 | public VDUBuffer getVDUBuffer(); 37 | } 38 | -------------------------------------------------------------------------------- /jta26/html/simple.conf: -------------------------------------------------------------------------------- 1 | # This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 2 | # 3 | # (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 4 | # 5 | # Please visit http://javatelnet.org/ for updates and contact. 6 | # 7 | # --LICENSE NOTICE-- 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | # --LICENSE NOTICE-- 22 | # 23 | 24 | # This is an example file how to configure the applet. It may contain 25 | # any property defined in de/mud/jta/default.conf or by a plugin. 26 | # 27 | 28 | # common definitions 29 | plugins = Socket,Telnet,Terminal 30 | layout.Status = South 31 | layout.Terminal = Center 32 | 33 | Socket.host = mg.mud.de 34 | Socket.port = 23 35 | -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/FightHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import org.apache.commons.lang3.RandomUtils; 4 | 5 | import bothack.actions.Actions; 6 | import bothack.actions.IAction; 7 | import bothack.bot.Direction; 8 | import bothack.bot.IGame; 9 | import bothack.bot.IPlayer; 10 | import bothack.bot.Position; 11 | import bothack.bot.dungeon.ITile; 12 | import bothack.bot.monsters.IMonster; 13 | import bothack.prompts.IActionHandler; 14 | 15 | public class FightHandler implements IActionHandler { 16 | IAction hit(IPlayer player, IMonster m) { 17 | return Actions.Move(Direction.towards(player, m)); 18 | } 19 | 20 | public IAction chooseAction(IGame game) { 21 | IPlayer player = game.player(); 22 | ITile atPlayer = game.currentLevel().at(player); 23 | if (player.isEngulfed()) { 24 | return Actions.Move(Direction.W); 25 | } 26 | int adjacent = 0; 27 | IMonster target = null; 28 | for (IMonster m : game.currentLevel().monsters().values()) { 29 | if (!m.isPeaceful() && !m.isFriendly() && Position.areAdjacent(player, m)) { 30 | ++adjacent; 31 | target = m; 32 | } 33 | } 34 | if ((adjacent > 1) && atPlayer.isEngravable() && RandomUtils.nextInt(0, 2) == 1) 35 | return Actions.EngraveAppending('-', "Elbereth"); 36 | if (target != null) 37 | return hit(game.player(), target); 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/PluginListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | /** 28 | * A tag interface for a plugin message listener. 29 | *

30 | * Maintainer: Matthias L. Jugel 31 | * 32 | * @version $Id: PluginListener.java 499 2005-09-29 08:24:54Z leo $ 33 | * @author Matthias L. Jugel, Marcus Mei�ner 34 | */ 35 | public interface PluginListener { 36 | } 37 | -------------------------------------------------------------------------------- /jta26/doc/plugins/keyCodes.at386: -------------------------------------------------------------------------------- 1 | # 2 | # keyCodes.at386 contributed by Selwyn Rosenstein (SelwynR@scas.com) 3 | # 4 | # AT-386 ANSI Terminal keyCodes definition file for Java Terminal Applet with 5 | # Terminal.id = at386 6 | # Terminal.IBM = true 7 | # Terminal.colorSet = /de/mud/terminal/colorSet.conf (default) 8 | # 9 | # This configuration file should be compatible with most ANSI monitors 10 | # monitors running under most versions of UNIX. 11 | # 12 | # F1 thru F10 13 | # 14 | F1=\\eOP 15 | F2=\\eOQ 16 | F3=\\eOR 17 | F4=\\eOS 18 | F5=\\eOT 19 | F6=\\eOU 20 | F7=\\eOV 21 | F8=\\eOW 22 | F9=\\eOX 23 | F10=\\eOY 24 | F11=\\eOZ 25 | F12=\\eOA 26 | # 27 | # Shift F1 thru F10 28 | # 29 | SF1=\\eOp 30 | SF2=\\eOq 31 | SF3=\\eOr 32 | SF4=\\eOs 33 | SF5=\\eOt 34 | SF6=\\eOu 35 | SF7=\\eOv 36 | SF8=\\eOw 37 | SF9=\\eOx 38 | SF10=\\eOy 39 | SF11=\\eOz 40 | SF12=\\eOa 41 | # 42 | # Other cursor movement keys 43 | # 44 | UP=\\e[A 45 | DOWN=\\e[B 46 | RIGHT=\\e[C 47 | LEFT=\\e[D 48 | # 49 | INSERT=\\e[@ 50 | # REMOVE=\\177 #( hex 7F / Decimal 127 / Octal 177 / DEL Key) 51 | # 52 | HOME=\\e[H 53 | PGDOWN=\\e[U 54 | PGUP=\\e[V 55 | END=\\e[Y 56 | # 57 | # 58 | # The following may be usefull to someone wishing to know the correct escape 59 | # sequences to send to the terminal to change display modes 60 | # 61 | # LOW-INTENSITY=\\e[0m 62 | # HIGH-INTENSITY=\\e[1m 63 | # REVERSE=\\e[7m 64 | # RESET=\\e[0m 65 | # 66 | # COLOR-SEQ=\\e[3%d;4%dm 67 | # COLOR-8=1 68 | -------------------------------------------------------------------------------- /java/bothack/bot/IBotHack.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | /** 4 | * The root of BotHack functionality. 5 | *

This represents a handle for the BotHack framework, through which you can 6 | * register custom handlers, get the current game state etc.

7 | *

Unlike other BotHack interfaces this is the only mutable one.

8 | */ 9 | public interface IBotHack { 10 | /** 11 | * Register a custom handler with the default priority. 12 | * @param handler The handler object should implement one or more interfaces 13 | * from {@link bothack.events} or {@link bothack.prompts}. 14 | */ 15 | void registerHandler(Object handler); 16 | /** 17 | * Register a custom handler with the specified priority. 18 | * @param priority Lower number = processed earlier. 19 | * @param handler The handler object should implement one or more interfaces 20 | * from {@link bothack.events} or {@link bothack.prompts}. 21 | */ 22 | void registerHandler(Integer priority, Object handler); 23 | /** 24 | * Deregister a handler that was registered earlier. 25 | * Nothing happens if the handler is not registered. 26 | */ 27 | void deregisterHandler(Object handler); 28 | /** 29 | * Replace a handler that was registered earlier (with the same priority). 30 | * @throws IllegalArgumentException if oldHandler is not registered. 31 | */ 32 | void replaceHandler(Object oldHandler, Object newHandler); 33 | /** Returns the current game state snapshot. */ 34 | IGame game(); 35 | } 36 | -------------------------------------------------------------------------------- /scripts/itemdata/Other.pm-edn: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Other; 2 | { 3 | $NetHack::Item::Spoiler::Other::VERSION = "0.21";} 4 | use strict; 5 | use warnings; 6 | use base "NetHack::Item::Spoiler"; 7 | use constant type "other"; 8 | sub _list { 9 | return { 10 | {:name "boulder" 11 | :price 0 12 | :weight 6000 13 | :glyph \8 14 | :sdam "d20" 15 | :ldam "d20" 16 | :nutrition 2000 17 | :plural "boulders" 18 | :material :mineral} 19 | {:name "heavy iron ball" 20 | :price 10 21 | :weight 480 22 | :glyph \0 23 | :sdam "d25" 24 | :ldam "d25" 25 | :nutrition 480 26 | :plural "heavy iron balls" 27 | :material :iron} 28 | {:name "iron chain" 29 | :price 0 30 | :weight 120 31 | :glyph \_ 32 | :sdam "d4+1" 33 | :ldam "d4+1" 34 | :nutrition 120 35 | :plural "iron chains" 36 | :material :iron} 37 | {:name "acid venom" 38 | :price 0 39 | :weight 1 40 | :glyph \. 41 | :sdam "2d6" 42 | :ldam "2d6" 43 | :plural "acid venoms" 44 | :stackable 1 45 | :material "liquid"} 46 | {:name "blinding venom" 47 | :price 0 48 | :weight 1 49 | :glyph \. 50 | :plural "blinding venoms" 51 | :stackable 1 52 | :material "liquid"} };} 53 | 1; 54 | -------------------------------------------------------------------------------- /java/bothack/bot/Intrinsic.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import clojure.lang.Keyword; 4 | 5 | public enum Intrinsic { 6 | TELEPATHY(Keyword.intern(null, "telepathy")), 7 | /** Teleport control */ 8 | TELECONTROL(Keyword.intern(null, "telecontrol")), 9 | /** Fire resistance */ 10 | FIRE(Keyword.intern(null, "fire")), 11 | /** Cold resistance */ 12 | COLD(Keyword.intern(null, "cold")), 13 | /** Sleep resistance */ 14 | SLEEP(Keyword.intern(null, "sleep")), 15 | /** Shock resistance */ 16 | SHOCK(Keyword.intern(null, "shock")), 17 | /** Poison resistance */ 18 | POISON(Keyword.intern(null, "poison")), 19 | /** Teleportitis */ 20 | TELEPORT(Keyword.intern(null, "teleport")), 21 | /** Disintegration resistance */ 22 | DISINTEGRATION(Keyword.intern(null, "disintegration")), 23 | /** Warning (numbers for nearby unseen monsters) */ 24 | WARNING(Keyword.intern(null, "warning")), 25 | /** Doesn't wake up monsters */ 26 | STEALTH(Keyword.intern(null, "stealth")), 27 | /** Aggravate monster */ 28 | AGGRAVATE(Keyword.intern(null, "aggravate")), 29 | INVISIBILITY(Keyword.intern(null, "invisibility")), 30 | /** See invisible */ 31 | SEE_INVIS(Keyword.intern(null, "see-invis")), 32 | /** Automatic searching */ 33 | SEARCH(Keyword.intern(null, "search")), 34 | SPEED(Keyword.intern(null, "speed")); 35 | 36 | private final Keyword kw; 37 | private Intrinsic(Keyword kw) { 38 | this.kw = kw; 39 | } 40 | 41 | public Keyword getKeyword() { 42 | return kw; 43 | } 44 | } -------------------------------------------------------------------------------- /src/bothack/ttyrec.clj: -------------------------------------------------------------------------------- 1 | (ns bothack.ttyrec 2 | "JTA filter plugin to save a ttyrec" 3 | (:require [clojure.java.io :refer [output-stream]]) 4 | (:import [de.mud.jta FilterPlugin] 5 | [java.nio ByteBuffer ByteOrder]) 6 | (:gen-class 7 | :name bothack.Ttyrec 8 | :extends de.mud.jta.Plugin 9 | :implements [de.mud.jta.FilterPlugin] 10 | :state state 11 | :init init)) 12 | 13 | (defn -getFilterSource [this source] 14 | (:source @(.state this))) 15 | 16 | (defn -setFilterSource [this source] 17 | (swap! (.state this) assoc :source source)) 18 | 19 | (defn -read [this b] 20 | (let [n (.read ^FilterPlugin (:source @(.state ^bothack.Ttyrec this)) b) 21 | ts (System/currentTimeMillis) 22 | ts-sec (quot ts 1000) 23 | ts-usec (* 1000 (- ts (* ts-sec 1000))) 24 | ttyrec-hdr (doto (ByteBuffer/allocate 12) 25 | (.order ByteOrder/LITTLE_ENDIAN))] 26 | (when (pos? n) 27 | (doto ttyrec-hdr 28 | ;(.clear) 29 | (.putInt ts-sec) 30 | (.putInt ts-usec) 31 | (.putInt n)) 32 | (doto ^java.io.OutputStream (:ttyrec @(.state ^bothack.Ttyrec this)) 33 | (.write (.array ttyrec-hdr) 0 12) 34 | (.write b 0 n) 35 | (.flush))) 36 | n)) 37 | 38 | (defn -write [this b] 39 | (.write ^FilterPlugin (:source @(.state ^bothack.Ttyrec this)) b)) 40 | 41 | (defn -init [bus id] 42 | [[bus id] (atom {:source nil 43 | :ttyrec (output-stream 44 | (str (System/currentTimeMillis) ".ttyrec"))})]) 45 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/SoundListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | import java.net.URL; 30 | 31 | /** 32 | * Play a sound when requested. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: SoundListener.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface SoundListener extends PluginListener { 40 | /** Play a sound that is given as a URL */ 41 | public void playSound(URL audioClip); 42 | } 43 | -------------------------------------------------------------------------------- /java/bothack/bot/items/IItemType.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.items; 2 | 3 | import java.util.List; 4 | 5 | import bothack.bot.monsters.IMonsterType; 6 | 7 | /** Representation of item "prototypes" of all kinds. 8 | * @see ItemType 9 | * @see ItemKind */ 10 | public interface IItemType { 11 | /** Name of the item type. */ 12 | String name(); 13 | /** For artifact items – return the base type. */ 14 | IItemType baseType(); 15 | /** Glyph representation of the item type. */ 16 | Character glyph(); 17 | /** Base price for items of this type. */ 18 | Long price(); 19 | /** Returns the item category. */ 20 | ItemKind kind(); 21 | /** How much the item weights. */ 22 | Long weight(); 23 | /** Initial possible appearances of the item. */ 24 | List appearances(); 25 | /** True if items of this type may stack. */ 26 | Boolean isStackable(); 27 | /** True if the item type is an artifact. 28 | * @see IItemType#baseType() */ 29 | Boolean isArtifact(); 30 | /** If true generally won't cause any immediate bad effects upon use. */ 31 | Boolean isSafe(); 32 | /** True if the item requires both hands to wield. */ 33 | Boolean isTwohanded(); 34 | /** How much the item lowers your AC (lower AC = better). */ 35 | Long AC(); 36 | /** Magic cancellation – how well the item protects against magical attack 37 | * effects */ 38 | Long MC(); 39 | /** Armor slot or item category. */ 40 | ItemSubtype subtype(); 41 | /** 42 | * For corpses, tins, eggs, statues and figurines may return the monster type 43 | * if known. 44 | */ 45 | IMonsterType monster(); 46 | /** For edible items. */ 47 | Long nutrition(); 48 | } 49 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/ssh.conf: -------------------------------------------------------------------------------- 1 | # This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 2 | # 3 | # (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 4 | # 5 | # Please visit http://javatelnet.org/ for updates and contact. 6 | # 7 | # --LICENSE NOTICE-- 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | # --LICENSE NOTICE-- 22 | # 23 | 24 | # This is an example file how to configure the applet. It may contain 25 | # any property defined in de/mud/jta/default.conf or by a plugin. 26 | # 27 | 28 | # common definitions 29 | plugins = Status,Socket,SSH,Terminal 30 | layout.Status = South 31 | layout.Terminal = Center 32 | 33 | Terminal.resize = screen 34 | 35 | Applet.disconnect = false 36 | 37 | # commented out so the login window pops up 38 | #SSH.password = 39 | 40 | Socket.port = 22 41 | 42 | # Terminal configuration 43 | Terminal.foreground = #ffffff 44 | Terminal.background = #000000 45 | Terminal.id = vt100 46 | -------------------------------------------------------------------------------- /bothack.nethackrc: -------------------------------------------------------------------------------- 1 | # slightly altered TAEB settings 2 | 3 | ROLE=valkyrie 4 | OPTIONS=race:dwarf 5 | 6 | OPTIONS=!bones 7 | OPTIONS=lit_corridor 8 | 9 | # more feedback! 10 | OPTIONS=msg_wall_hits 11 | 12 | OPTIONS=!sparkle 13 | OPTIONS=runmode:teleport 14 | OPTIONS=!timed_delay 15 | 16 | # display 17 | OPTIONS=!showexp 18 | OPTIONS=showscore 19 | OPTIONS=time 20 | OPTIONS=color 21 | OPTIONS=boulder:8 22 | OPTIONS=!tombstone 23 | OPTIONS=!news 24 | OPTIONS=!legacy 25 | OPTIONS=suppress_alert:3.4.3 26 | OPTIONS=hilite_pet 27 | 28 | # functionality 29 | OPTIONS=!autopickup 30 | OPTIONS=pickup_types:$ 31 | OPTIONS=pickup_burden:unburdened 32 | OPTIONS=!prayconfirm 33 | OPTIONS=pettype:none 34 | OPTIONS=!cmdassist 35 | OPTIONS=disclose:yi +avgc 36 | OPTIONS=menustyle:partial 37 | 38 | # miscellaneous 39 | OPTIONS=!mail 40 | 41 | # map changes for code simplicity 42 | OPTIONS=monsters:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@X'&;:~m 43 | # "strange monster" = m (mimic) 44 | # ghost/shade = X now space is solid rock 45 | 46 | OPTIONS=traps:\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^ 47 | # spider web = ^ now " is amulet 48 | 49 | OPTIONS=dungeon: |--------||.-|]]}}.##<><>_\\\\{{~.}..}} #} 50 | # sink => { one less #, walkable 51 | # drawbridge => } one less #, not walkable 52 | # iron bars => } one less #, not walkable (color: cyan) 53 | # trees => } one less #, not walkable (color: green) 54 | # closed doors => ] now + is spellbook 55 | # grave => \ now gray | and - are walls, (grey -- thrones) 56 | 57 | OPTIONS=objects:m 58 | # "strange object" = m (mimic) 59 | # now ] is closed door 60 | -------------------------------------------------------------------------------- /jta26/JTA.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/EndOfRecordListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | /** 30 | * This interface should be used by plugins who would like to be notified 31 | * about the end of record event 32 | *

33 | * Maintainer: Marcus Meissner 34 | * 35 | * @version $Id: EndOfRecordListener.java 499 2005-09-29 08:24:54Z leo $ 36 | * @author Matthias L. Jugel, Marcus Mei�ner 37 | */ 38 | public interface EndOfRecordListener extends PluginListener { 39 | /** Called if the end of record event appears */ 40 | public void EndOfRecord(); 41 | } 42 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/LocalEchoListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | /** 30 | * This interface should be used by plugins who would like to be notified 31 | * about the local echo property. 32 | *

33 | * Maintainer: Matthias L. Jugel 34 | * 35 | * @version $Id: LocalEchoListener.java 499 2005-09-29 08:24:54Z leo $ 36 | * @author Matthias L. Jugel, Marcus Mei�ner 37 | */ 38 | public interface LocalEchoListener extends PluginListener { 39 | /** Called if the local echo property changes. */ 40 | public void setLocalEcho(boolean echo); 41 | } 42 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/WindowSizeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | import java.awt.Dimension; 30 | 31 | /** 32 | * This is the interface for a window size listener. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: WindowSizeListener.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface WindowSizeListener extends PluginListener { 40 | /** Return the current window size of the terminal in rows and columns. */ 41 | public Dimension getWindowSize(); 42 | } 43 | -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/GatherItems.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.actions.Actions; 4 | import bothack.actions.IAction; 5 | import bothack.actions.NavOption; 6 | import bothack.actions.Navigation; 7 | import bothack.actions.Navigation.IPath; 8 | import bothack.bot.IGame; 9 | import bothack.bot.IPlayer; 10 | import bothack.bot.IPredicate; 11 | import bothack.bot.dungeon.ITile; 12 | import bothack.bot.items.IItem; 13 | import bothack.bot.items.IItemType; 14 | import bothack.bot.items.ItemType; 15 | import bothack.prompts.IActionHandler; 16 | 17 | public class GatherItems implements IActionHandler { 18 | static IItemType GOLD = ItemType.byName("gold piece"); 19 | 20 | IPredicate hasGold = new IPredicate() { 21 | public boolean apply(ITile tile) { 22 | for (IItem i : tile.items()) 23 | if (i.type().equals(GOLD)) 24 | return true; 25 | return false; 26 | } 27 | }; 28 | 29 | boolean wantGold(IGame game) { 30 | return game.gold() < 100; 31 | } 32 | 33 | public IAction chooseAction(IGame game) { 34 | if (!wantGold(game)) 35 | return null; 36 | final IPlayer player = game.player(); 37 | ITile atPlayer = game.currentLevel().at(player); 38 | IPath res = null; 39 | res = Navigation.navigate(game, hasGold, NavOption.EXPLORED); 40 | if (res != null) { 41 | if (res.step() != null) { 42 | return res.step(); 43 | } else { 44 | IItem gold = null; 45 | for (IItem i : atPlayer.items()) { 46 | if (i.type().equals(GOLD)) { 47 | gold = i; 48 | break; 49 | } 50 | } 51 | return Actions.PickUp(gold.label()); 52 | } 53 | } 54 | return null; 55 | } 56 | } -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/ConfigurationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | import de.mud.jta.PluginConfig; 29 | 30 | 31 | /** 32 | * Configuration listener will be notified of configuration events. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: ConfigurationListener.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface ConfigurationListener extends PluginListener { 40 | /** Called for configuration changes. */ 41 | public void setConfiguration(PluginConfig config); 42 | } 43 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/SetWindowSizeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | import java.awt.Dimension; 30 | 31 | /** 32 | * This is the interface for a window size listener. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: WindowSizeListener.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface SetWindowSizeListener extends PluginListener { 40 | /** Set the current window size of the terminal in rows and columns. */ 41 | public void setWindowSize(int columns, int rows); 42 | } 43 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/PluginMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | /** 28 | * The base interface for a plugin message. 29 | *

30 | * Maintainer: Matthias L. Jugel 31 | * 32 | * @version $Id: PluginMessage.java 499 2005-09-29 08:24:54Z leo $ 33 | * @author Matthias L. Jugel, Marcus Mei�ner 34 | */ 35 | public interface PluginMessage { 36 | /** 37 | * Fire the message to all listeners that are compatible with this 38 | * message and return the result. 39 | * @param pl the list of plugin message listeners 40 | * @return the result message 41 | */ 42 | public Object firePluginMessage(PluginListener pl); 43 | } 44 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/AppletListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | import javax.swing.JApplet; 30 | 31 | /** 32 | * This is the interface is for applet listeners, plugins that 33 | * want to know the applet object. 34 | *

35 | * Maintainer: Matthias L. Jugel 36 | * 37 | * @version $Id: AppletListener.java 499 2005-09-29 08:24:54Z leo $ 38 | * @author Matthias L. Jugel, Marcus Mei�ner 39 | */ 40 | public interface AppletListener extends PluginListener { 41 | /** Return the current window size of the terminal in rows and columns. */ 42 | public void setApplet(JApplet applet); 43 | } 44 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/OnlineStatusListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | import java.awt.Dimension; 30 | 31 | /** 32 | * This is the interface for a online status listener. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: OnlineStatusListener.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface OnlineStatusListener extends PluginListener { 40 | /** Called when the system is online. */ 41 | public void online(); 42 | /** Called when the system is offline. */ 43 | public void offline(); 44 | } 45 | -------------------------------------------------------------------------------- /jta26/de/mud/ssh/NONE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.ssh; 26 | 27 | /** 28 | * @author Marcus Meissner 29 | * @version $Id: NONE.java 499 2005-09-29 08:24:54Z leo $ 30 | */ 31 | public final class NONE extends Cipher { 32 | 33 | public void setKey(String skey) { 34 | } 35 | 36 | public void setKey(byte[] key) { 37 | } 38 | 39 | public synchronized void encrypt(byte[] src, int srcOff, byte[] dest, int destOff, int len) { 40 | System.arraycopy(src,srcOff,dest,destOff,len); 41 | } 42 | 43 | public synchronized void decrypt(byte[] src, int srcOff, byte[] dest, int destOff, int len) { 44 | System.arraycopy(src,srcOff,dest,destOff,len); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /doc/config.md: -------------------------------------------------------------------------------- 1 | ## Watching bots run 2 | 3 | Unless you disabled the :ttyrec option in the config, a [.ttyrec](http://en.wikipedia.org/wiki/Ttyrec) file will be created in the working directory for each run. 4 | 5 | You can use ttyrec viewers like ttyplay or [IPBT](http://www.chiark.greenend.org.uk/~sgtatham/ipbt/) to replay these. 6 | 7 | Use `ttyplay -p` to watch a growing ttyrec live. You can use the bash script [scripts/ttywatch.sh](https://github.com/krajj7/BotHack/blob/master/scripts/ttywatch.sh) to keep playing the most recent ttyrec (needs ttyplay). 8 | 9 | ## Configuration options 10 | 11 | You can change these keys in the config files: 12 | 13 | * :javabot - the main class of a Java bot 14 | * :bot - the main namespace of a Clojure bot 15 | * :menubot - the namespace of a bot that handles server menu 16 | * :host - hostname of a NetHack server 17 | * :port - port of the NetHack server 18 | * :dgl-login - server login for dgl-menubot 19 | * :dgl-pass - server password for dgl-menubot 20 | * :ttyrec - if true creates a ttyrec file for each run 21 | * :interface - can be either :shell, :telnet or :ssh 22 | * :nh-command - NetHack command (when :interface is set to :shell) 23 | * :ssh-user - user for SSH login (when :interface is set to :ssh) 24 | * :ssh-pass - password for SSH login (when :interface is set to :ssh) 25 | * :no-exit - if set to true the program will not terminate when the game ends or when the bot gets stuck (useful for debugging from the repl) 26 | * :quit-resumed - when set to true will quit the game if the bot is started with a saved game with T:100 or higher 27 | 28 | ## Logging 29 | 30 | Detailed logs are generated in the working directory in `bothack.log` files. These logs are rotated automatically. 31 | -------------------------------------------------------------------------------- /jta26/html/ssh.conf: -------------------------------------------------------------------------------- 1 | # This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 2 | # 3 | # (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 4 | # 5 | # Please visit http://javatelnet.org/ for updates and contact. 6 | # 7 | # --LICENSE NOTICE-- 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | # --LICENSE NOTICE-- 22 | # 23 | 24 | # This is an example file how to configure the applet. It may contain 25 | # any property defined in de/mud/jta/default.conf or by a plugin. 26 | # 27 | 28 | # common definitions 29 | plugins = Status,Socket,SSH,Terminal 30 | layout.Status = South 31 | layout.Terminal = Center 32 | 33 | Applet.disconnect = false 34 | 35 | #SSH.user = leo 36 | # commented out so the login window pops up 37 | #SSH.password = 38 | 39 | # Socket, please change this to 22 for real usage. 40 | Socket.port = 2222 41 | 42 | # Terminal configuration 43 | Terminal.foreground = #ffffff 44 | Terminal.background = #000000 45 | #Terminal.keyCodes = http://www.mud.de/~leo/keys.test 46 | Terminal.id = vt100 47 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/TerminalTypeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | /** 30 | * This is the interface for a terminal type listener. It should return 31 | * the terminal type id as a string. Valid terminal types include 32 | * VT52, VT100, VT200, VT220, VT320, ANSI etc. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: TerminalTypeListener.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface TerminalTypeListener extends PluginListener { 40 | /** Return the terminal type string */ 41 | public String getTerminalType(); 42 | } 43 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/ReturnFocusListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | 26 | package de.mud.jta.event; 27 | 28 | import de.mud.jta.PluginListener; 29 | 30 | /** 31 | * This interface should be used by plugins who would like to be notified 32 | * about the return of the focus from another plugin. 33 | *

34 | * Implemented after a suggestion by Dave <david@mirrabooka.com> 35 | *

36 | * Maintainer: Matthias L. Jugel 37 | * 38 | * @version $Id: ReturnFocusListener.java 499 2005-09-29 08:24:54Z leo $ 39 | * @author Matthias L. Jugel, Marcus Mei�ner 40 | */ 41 | public interface ReturnFocusListener extends PluginListener { 42 | /** Called if the end of return focus message is sent. */ 43 | public void returnFocus(); 44 | } 45 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/TelnetCommandListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | import java.io.IOException; 29 | 30 | /** 31 | * This interface should be used by plugins who would like to be notified 32 | * about the end of record event 33 | *

34 | * Maintainer: Marcus Meissner 35 | * 36 | * @version $Id: TelnetCommandListener.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface TelnetCommandListener extends PluginListener { 40 | /** Called by code in the terminal interface or somewhere for sending 41 | * telnet commands 42 | */ 43 | public void sendTelnetCommand(byte command) throws IOException; 44 | } 45 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/FocusStatusListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.Plugin; 28 | import de.mud.jta.PluginListener; 29 | 30 | import java.awt.Dimension; 31 | 32 | /** 33 | * This is the interface for a focus status listener. 34 | *

35 | * Maintainer: Matthias L. Jugel 36 | * 37 | * @version $Id: FocusStatusListener.java 499 2005-09-29 08:24:54Z leo $ 38 | * @author Matthias L. Jugel, Marcus Mei�ner 39 | */ 40 | public interface FocusStatusListener extends PluginListener { 41 | /** Called if a plugin gained the input focus. */ 42 | public void pluginGainedFocus(Plugin plugin); 43 | /** Called if a plugin lost the input focus. */ 44 | public void pluginLostFocus(Plugin plugin); 45 | } 46 | -------------------------------------------------------------------------------- /scripts/itemdata/Other.pm-x: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Other; 2 | { 3 | $NetHack::Item::Spoiler::Other::VERSION = '0.21'; } 4 | use strict; 5 | use warnings; 6 | use base 'NetHack::Item::Spoiler'; 7 | 8 | use constant type => 'other'; 9 | 10 | sub _list { 11 | return { 12 | 'boulder' => { 13 | price => 0, 14 | weight => 6000, 15 | glyph => '8', 16 | sdam => 'd20', 17 | ldam => 'd20', 18 | nutrition => 2000, 19 | plural => 'boulders', 20 | material => 'mineral', } 21 | 'heavy iron ball' => { 22 | price => 10, 23 | weight => 480, 24 | glyph => '0', 25 | sdam => 'd25', 26 | ldam => 'd25', 27 | nutrition => 480, 28 | plural => 'heavy iron balls', 29 | material => 'iron', } 30 | 'iron chain' => { 31 | price => 0, 32 | weight => 120, 33 | glyph => '_', 34 | sdam => 'd4+1', 35 | ldam => 'd4+1', 36 | nutrition => 120, 37 | plural => 'iron chains', 38 | material => 'iron', } 39 | 'acid venom' => { 40 | price => 0, 41 | weight => 1, 42 | glyph => '.', 43 | sdam => '2d6', 44 | ldam => '2d6', 45 | plural => 'acid venoms', 46 | stackable => 1, 47 | material => 'liquid', } 48 | 'blinding venom' => { 49 | price => 0, 50 | weight => 1, 51 | glyph => '.', 52 | plural => 'blinding venoms', 53 | stackable => 1, 54 | material => 'liquid', } }; } 55 | 56 | 1; 57 | 58 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/VisualTransferPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | import java.awt.datatransfer.Clipboard; 28 | 29 | /** 30 | * A visual plugin that also allows to copy and paste data. 31 | *

32 | * Maintainer: Matthias L. Jugel 33 | * 34 | * @version $Id: VisualTransferPlugin.java 499 2005-09-29 08:24:54Z leo $ 35 | * @author Matthias L. Jugel, Marcus Mei�ner 36 | */ 37 | public interface VisualTransferPlugin extends VisualPlugin { 38 | /** 39 | * Copy currently selected text into the clipboard. 40 | * @param clipboard the clipboard 41 | */ 42 | public void copy(Clipboard clipboard); 43 | 44 | /** 45 | * Paste text from clipboard to the plugin. 46 | * @param clipboard the clipboard 47 | */ 48 | public void paste(Clipboard clipboard); 49 | } 50 | -------------------------------------------------------------------------------- /jta26/jni/win32/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 2 | # 3 | # (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 4 | # 5 | # Please visit http://javatelnet.org/ for updates and contact. 6 | # 7 | # --LICENSE NOTICE-- 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | # --LICENSE NOTICE-- 22 | # 23 | 24 | #### This makefile is incomplete! Someone please finish it. 25 | 26 | JAVAH = /q/opt/jdk1.2.2/bin/javah 27 | TOPDIR = ../.. 28 | SRCDIR = ../../de 29 | CDIR = ../src 30 | 31 | JNI_INCLUDE = -Ic:\java\include -Ic:\java\include\win32 32 | 33 | CC = gcc 34 | SOCFLAGS = -fPIC -c -Wall -I. $(JNI_INCLUDE) 35 | SOLFLAGS = -shared -lutil 36 | 37 | all: jtapty.dll 38 | 39 | # 40 | # On Win32, the following command builds a dynamic link library hello.dll using Microsoft Visual C++ 4.0: 41 | # 42 | # cl -Ic:\java\include -Ic:\java\include\win32 43 | # -LD HelloWorldImp.c -Fehello.dll 44 | # 45 | # On Linux libutil contains forkpty() 46 | # 47 | # 48 | # This will most likely not be easily portable to Win32, except probably 49 | # using cygwin. Do not expect it to work. 50 | 51 | clean: 52 | 53 | realclean: clean 54 | 55 | # EOF 56 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/VisualPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | import javax.swing.*; 28 | 29 | /** 30 | * To show data on-screen a plugin may have a visible component. That component 31 | * may either be a single awt component or a container with severel elements. 32 | *

33 | * Maintainer: Matthias L. Jugel 34 | * 35 | * @version $Id: VisualPlugin.java 499 2005-09-29 08:24:54Z leo $ 36 | * @author Matthias L. Jugel, Marcus Mei�ner 37 | */ 38 | public interface VisualPlugin { 39 | /** 40 | * Get the visible components from the plugin. 41 | * @return a component that represents the plugin 42 | */ 43 | public JComponent getPluginVisual(); 44 | 45 | /** 46 | * Get the menu entry for this component. 47 | * @return a menu that can be used to change the plugin state 48 | */ 49 | public JMenu getPluginMenu(); 50 | } 51 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/PluginBus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | /** 28 | * A plugin bus is used for communication between plugins. The interface 29 | * describes the broadcast method that should broad cast the message 30 | * to all plugins known and return an answer message immediatly.

31 | * The functionality is just simuliar to a bus, but depends on the 32 | * actual implementation of the bus. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: PluginBus.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface PluginBus { 40 | /** Broadcast a plugin message to all listeners. */ 41 | public Object broadcast(PluginMessage message); 42 | /** Register a plugin listener with this bus object */ 43 | public void registerPluginListener(PluginListener listener); 44 | } 45 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/SocketListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | 29 | import java.net.UnknownHostException; 30 | import java.io.IOException; 31 | 32 | /** 33 | * The socket listener should be implemented by plugins that want to know 34 | * when the whole systems connects or disconnects. 35 | *

36 | * Maintainer: Matthias L. Jugel 37 | * 38 | * @version $Id: SocketListener.java 499 2005-09-29 08:24:54Z leo $ 39 | * @author Matthias L. Jugel, Marcus Mei�ner 40 | */ 41 | public interface SocketListener extends PluginListener { 42 | /** Called if a connection should be established. */ 43 | public void connect(String host, int port) 44 | throws UnknownHostException, IOException; 45 | /** Called if the connection should be stopped. */ 46 | public void disconnect() 47 | throws IOException; 48 | } 49 | -------------------------------------------------------------------------------- /jta26/jni/solaris/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 2 | # 3 | # (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 4 | # 5 | # Please visit http://javatelnet.org/ for updates and contact. 6 | # 7 | # --LICENSE NOTICE-- 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | # --LICENSE NOTICE-- 22 | # 23 | 24 | ### This makefile is incomplete. Please adjust it to your environment. 25 | 26 | JAVAH = /usr/java/bin/javah 27 | TOPDIR = ../.. 28 | SRCDIR = ../../de 29 | CDIR = ../src 30 | 31 | JNI_INCLUDE = -I/usr/java/include -I/usr/java/include/linux 32 | 33 | CC = /opt/SUNWspro/SC5.0/bin/cc 34 | SOCFLAGS = -c -I. $(JNI_INCLUDE) -G 35 | SOLFLAGS = -G 36 | 37 | # 38 | # major rules to create files 39 | # 40 | all: libjtapty.so 41 | 42 | HandlerPTY.h: $(SRCDIR)/mud/jta/plugin/HandlerPTY.class 43 | $(JAVAH) -force -classpath $(TOPDIR) -o $@ de.mud.jta.plugin.HandlerPTY 44 | 45 | libjtapty.so: HandlerPTY.lo 46 | $(CC) $(SOLFLAGS) -o $@ HandlerPTY.lo 47 | 48 | HandlerPTY.lo: $(CDIR)/HandlerPTY.c HandlerPTY.h 49 | $(CC) $(SOCFLAGS) -o $@ $(CDIR)/HandlerPTY.c 50 | 51 | clean: 52 | -find . -name \*~ -print | xargs rm -f 53 | -rm -f HandlerPTY.h libjtapty.so 54 | 55 | realclean: clean 56 | 57 | # EOF 58 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/WindowSizeRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.WindowSizeListener; 30 | 31 | /** 32 | * Request the current window size of the terminal. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: WindowSizeRequest.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public class WindowSizeRequest implements PluginMessage { 40 | /** 41 | * Return the size of the window 42 | * @param pl the list of plugin message listeners 43 | */ 44 | public Object firePluginMessage(PluginListener pl) { 45 | if(pl instanceof WindowSizeListener) { 46 | Object ret = ((WindowSizeListener)pl).getWindowSize(); 47 | if(ret != null) return ret; 48 | } 49 | return null; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jta26/html/b1.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Example for writing a button bar config file. 3 | # 4 | # The syntaxt for defining buttons, input fields and breaks is as follows: 5 | # 6 | # - defining a label: 7 | # A labvel is defined by giving the keyword 'label' followed by the text 8 | # of the label. If the label contains whitespace characters, enclode it in 9 | # quote (") characters! 10 | # 11 | label "Welcome to Tanis" 12 | # 13 | # - defining a button: 14 | # A button is defined by giving the keyword 'button' followed by the text 15 | # of the button and the command that should be sent when pressing the 16 | # button. If the command contains whitespace characters, enclode it in 17 | # quote (") characters! 18 | button Connect "\\$connect(\\@host@,\\@port@)" 19 | # 20 | # - defining an input field: 21 | # An input field is defined just like the button above, but it has one more 22 | # parameter, the size of the input field. So you define it, by giving the 23 | # keyword 'input' followed by the name of the input field (for reference) 24 | # followed by the size of the input field and optionally a third parameter 25 | # which is the initial text to be displayed in that field. 26 | input host 20 "tanis" 27 | # 28 | # We want to have the host field stretch as much as possible. The keyword 29 | # below does accomplish that. 30 | stretch 31 | # 32 | # And another input field. 33 | input port 4 "23" 34 | # 35 | # Now after the button and two input fields we define another button which 36 | # will be shown last in the row. Order is significant for the order in 37 | # which the buttons and fields appear. 38 | button Disconnect "\\$disconnect()" 39 | # 40 | # This button is only useful if the remote understands TELNET IAC BREAK. 41 | # (like routers or other embedded thingies) 42 | # 43 | button TelnetBreak "\\$break()" 44 | # 45 | # we want an input line on the next row take the whole row (last break) 46 | break 47 | input send 20 "\\@send@\n" "who" 48 | break 49 | -------------------------------------------------------------------------------- /jta26/jni/linux/Makefile: -------------------------------------------------------------------------------- 1 | # This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 2 | # 3 | # (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 4 | # 5 | # Please visit http://javatelnet.org/ for updates and contact. 6 | # 7 | # --LICENSE NOTICE-- 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | # --LICENSE NOTICE-- 22 | # 23 | 24 | JAVAH = javah 25 | TOPDIR = ../.. 26 | SRCDIR = ../../de 27 | CDIR = ../src 28 | 29 | JNI_INCLUDE = -I/usr/lib/j2sdk1.3/include -I/usr/lib/j2sdk1.3/include/linux 30 | 31 | # Linux (glibc 2.1.3) 32 | # libutil contains forkpty() 33 | CC = gcc -Ofast 34 | SOCFLAGS = -fPIC -c -Wall -I. $(JNI_INCLUDE) 35 | SOLFLAGS = -shared -lutil 36 | 37 | # 38 | # major rules to create files 39 | # 40 | all: libjtapty.so 41 | 42 | HandlerPTY.h: $(SRCDIR)/mud/jta/plugin/HandlerPTY.class 43 | $(JAVAH) -classpath /usr/java/lib/classes.zip:$(TOPDIR) -o $@ de.mud.jta.plugin.HandlerPTY 44 | 45 | libjtapty.so: HandlerPTY.lo 46 | $(CC) $(SOLFLAGS) -o $@ HandlerPTY.lo 47 | 48 | HandlerPTY.lo: $(CDIR)/HandlerPTY.c HandlerPTY.h 49 | $(CC) $(SOCFLAGS) -o $@ $(CDIR)/HandlerPTY.c 50 | 51 | clean: 52 | -find . -name \*~ -print | xargs rm -f 53 | -rm -f HandlerPTY.h HandlerPTY.lo libjtapty.so 54 | 55 | realclean: clean 56 | 57 | # EOF 58 | -------------------------------------------------------------------------------- /java/bothack/bot/Position.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import java.util.List; 4 | 5 | import bothack.bot.dungeon.ILevel; 6 | import clojure.java.api.Clojure; 7 | 8 | /** Position factory and utility functions. */ 9 | final public class Position { 10 | private Position() {}; 11 | 12 | static { 13 | Clojure.var("clojure.core", "require").invoke(Clojure.read("bothack.position")); 14 | } 15 | 16 | /** 17 | * Make an IPosition with given coordinates. 18 | * @param x 0 to 79 inclusive 19 | * @param y 0 to 23 inclusive, level tiles appear at 1 to 21 inclusive 20 | */ 21 | public static IPosition create(Long x, Long y) { 22 | return (IPosition) Clojure.var("bothack.position", "position").invoke(x, y); 23 | } 24 | 25 | /** 26 | * Strip the given IPosition map of all keys except :x and :y. 27 | * Useful for printing. 28 | */ 29 | public static IPosition of(IPosition something) { 30 | return (IPosition) Clojure.var("bothack.position", "position").invoke(something); 31 | } 32 | 33 | public static Boolean areAdjacent(IPosition pos1, IPosition pos2) { 34 | return (Boolean) Clojure.var("bothack.position", "adjacent?").invoke(pos1, pos2); 35 | } 36 | 37 | /** Uniform norm distance (steps allowing diagonals). */ 38 | public static Long distance(IPosition pos1, IPosition pos2) { 39 | return (Long) Clojure.var("bothack.position", "distance").invoke(pos1, pos2); 40 | } 41 | 42 | /** Manhattan distance (not allowing diagonals). */ 43 | public static Long distanceManhattan(IPosition pos1, IPosition pos2) { 44 | return (Long) Clojure.var("bothack.position", "distance-manhattan").invoke(pos1, pos2); 45 | } 46 | 47 | /** 48 | * Returns a list of valid adjacent positions. 49 | * @see ILevel#neighbors(IPosition pos) 50 | */ 51 | public static List neighbors(IPosition pos) { 52 | return (List) Clojure.var("clojure.core", "vec").invoke( 53 | Clojure.var("bothack.position", "neighbors").invoke(pos)); 54 | } 55 | } -------------------------------------------------------------------------------- /src/bothack/handlers.clj: -------------------------------------------------------------------------------- 1 | (ns bothack.handlers 2 | (:require [clojure.tools.logging :as log] 3 | [bothack.util :refer :all] 4 | [bothack.dungeon :refer :all] 5 | [bothack.delegator :refer :all])) 6 | 7 | (defn register-handler 8 | [bh & args] 9 | (send (:delegator bh) #(apply register % args)) 10 | bh) 11 | 12 | (defn deregister-handler 13 | [bh handler] 14 | (send (:delegator bh) deregister handler) 15 | bh) 16 | 17 | (defn replace-handler 18 | [bh handler-old handler-new] 19 | (send (:delegator bh) switch handler-old handler-new) 20 | bh) 21 | 22 | (defn update-before-action 23 | "Before the next action is chosen call (apply swap! game f args). This 24 | happens when game state is updated and player position is known." 25 | [bh f & args] 26 | {:pre [(:game bh)]} 27 | (register-handler bh priority-top 28 | (reify AboutToChooseActionHandler 29 | (about-to-choose [this _] 30 | (apply swap! (:game bh) f args) 31 | (deregister-handler bh this))))) 32 | 33 | (defn update-on-known-position 34 | "When player position on map is known call (apply swap! game f args). Game 35 | state may not be fully updated yet for the turn." 36 | [bh f & args] 37 | {:pre [(:game bh)]} 38 | (register-handler bh priority-top 39 | (reify 40 | AboutToChooseActionHandler ; handler might have been registered too late to receive know-position this turn 41 | (about-to-choose [this _] 42 | (apply swap! (:game bh) f args) 43 | (deregister-handler bh this)) 44 | KnowPositionHandler 45 | (know-position [this _] 46 | (apply swap! (:game bh) f args) 47 | (deregister-handler bh this))))) 48 | 49 | (defn update-at-player-when-known 50 | "Update the tile at player's next known position by applying update-fn to its 51 | current value and args" 52 | [bh update-fn & args] 53 | (update-on-known-position bh #(apply update-at-player % update-fn args))) 54 | -------------------------------------------------------------------------------- /java/bothack/actions/NavOption.java: -------------------------------------------------------------------------------- 1 | package bothack.actions; 2 | 3 | import bothack.bot.dungeon.ITile; 4 | import clojure.lang.Keyword; 5 | 6 | public enum NavOption { 7 | /** Don't use any actions except Move to reach the target. 8 | * Means no door opening, digging etc. */ 9 | WALKING(Keyword.intern(null, "walking")), 10 | /** Navigate to nearest tile adjacent to the target. */ 11 | ADJACENT(Keyword.intern(null, "adjacent")), 12 | /** Only navigate through tiles that were already seen or walked. */ 13 | EXPLORED(Keyword.intern(null, "explored")), 14 | /** Avoid all traps. */ 15 | NO_TRAPS(Keyword.intern(null, "no-traps")), 16 | /** Don't use digging tools. */ 17 | NO_DIG(Keyword.intern(null, "no-dig")), 18 | /** Don't use levitation items. */ 19 | NO_LEVITATION(Keyword.intern(null, "no-levitation")), 20 | /** Prefer to step on tiles with new items. 21 | * This is useful for quicker exploration but potentially dangerous when 22 | * retreating as tiles with new items may likely be traps. 23 | * @see ITile#hasNewItems() */ 24 | PREFER_ITEMS(Keyword.intern(null, "prefer-items")), 25 | /** Don't use the autonavigation (_) command. 26 | * Autonavigation makes the bot play much faster but may miss interesting 27 | * game updates (monsters closing in). Recommended when fighting, 28 | * otherwise is usually safe as NetHack stops autonavigation in dangerous 29 | * situations. */ 30 | NO_AUTONAV(Keyword.intern(null, "no-autonav")), 31 | /** Don't path through tiles containing hostile monsters (seen or remembered). 32 | * There is no sophisticated monster avoidance, the path may still be 33 | * dangerous or end up blocked when monsters move. */ 34 | NO_FIGHT(Keyword.intern(null, "no-fight")), 35 | /** For interlevel navigation. */ 36 | UP(Keyword.intern(null, "up")); 37 | 38 | private final Keyword kw; 39 | 40 | private NavOption(Keyword kw) { 41 | this.kw = kw; 42 | } 43 | 44 | public Keyword getKeyword() { 45 | return kw; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /scripts/itemdata/Amulet.pm-edn: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Amulet; 2 | { 3 | $NetHack::Item::Spoiler::Amulet::VERSION = "0.21";} 4 | use strict; 5 | use warnings; 6 | use base "NetHack::Item::Spoiler"; 7 | use constant type "amulet"; 8 | my @amulets = map { "$_ amulet"} ( 9 | qw/circular spherical oval triangular pyramidal square concave hexagonal 10 | octagonal/ 11 | ); 12 | sub _list { 13 | my $amulets = { 14 | {:name "Amulet of Yendor" 15 | :price 30000 16 | :artifact 1 17 | :fullname "The Amulet of Yendor" 18 | :appearances ["Amulet of Yendor"] 19 | :material :mithril} 20 | {:name "Eye of the Aethiopica" 21 | :price 4000 22 | :edible 1 23 | :artifact 1 24 | :fullname "The Eye of the Aethiopica" 25 | :base "amulet of ESP" 26 | :material :iron} 27 | {:name "cheap plastic imitation of the Amulet of Yendor" 28 | :price 0 29 | :appearances ["Amulet of Yendor"] 30 | :material :plastic} 31 | {:name "amulet of change" 32 | :edible 1 :material :iron} 33 | {:name "amulet of ESP" 34 | :edible 1 :material :iron} 35 | {:name "amulet of life saving" 36 | :material :iron} 37 | {:name "amulet of magical breathing" 38 | :edible 1 :material :iron} 39 | {:name "amulet of reflection" 40 | :material :iron} 41 | {:name "amulet of restful sleep" 42 | :edible 1 :material :iron} 43 | {:name "amulet of strangulation" 44 | :edible 1 :material :iron} 45 | {:name "amulet of unchanging" 46 | :edible 1 :material :iron} 47 | {:name "amulet versus poison" 48 | :edible 1 :material :iron} 49 | }; 50 | return $amulets (weight 20 :price 150 :appearances amulets 51 | :glyph \");} 52 | 1; 53 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/plugin/HandlerPTY.java: -------------------------------------------------------------------------------- 1 | // JNI interface to slave process. 2 | // This is a part of Shell plugin. 3 | // If not for a static member, we'd have HandlerPTY private to Shell. XXX 4 | 5 | // HandlerPTY is meant to be robust, in a way that you can 6 | // instantiate it and work with it until it throws an exception, 7 | 8 | /* 9 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 10 | * 11 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 12 | * 13 | * Please visit http://javatelnet.org/ for updates and contact. 14 | * 15 | * --LICENSE NOTICE-- 16 | * This program is free software; you can redistribute it and/or 17 | * modify it under the terms of the GNU General Public License 18 | * as published by the Free Software Foundation; either version 2 19 | * of the License, or (at your option) any later version. 20 | * 21 | * This program is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | * GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License 27 | * along with this program; if not, write to the Free Software 28 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 | * --LICENSE NOTICE-- 30 | * 31 | */ 32 | package de.mud.jta.plugin; 33 | 34 | public class HandlerPTY { 35 | public native int start(String cmd); // open + fork/exec 36 | public native void close(); 37 | public native int read(byte[] b); 38 | public native int write(byte[] b); 39 | 40 | private int fd; 41 | boolean good = false; 42 | 43 | static { 44 | // System.loadLibrary("libutil"); // forkpty on Linux lives in libutil 45 | System.loadLibrary("jtapty"); 46 | } 47 | 48 | protected void finalize() throws Throwable { 49 | super.finalize(); 50 | if(good) { 51 | close(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/AppletRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginListener; 28 | import de.mud.jta.PluginMessage; 29 | 30 | import javax.swing.JApplet; 31 | 32 | 33 | /** 34 | * Tell listeners the applet object. 35 | *

36 | * Maintainer: Matthias L. Jugel 37 | * 38 | * @version $Id: AppletRequest.java 499 2005-09-29 08:24:54Z leo $ 39 | * @author Matthias L. Jugel, Marcus Mei�ner 40 | */ 41 | public class AppletRequest implements PluginMessage { 42 | protected JApplet applet; 43 | 44 | public AppletRequest(JApplet applet) { 45 | this.applet = applet; 46 | } 47 | 48 | /** 49 | * Notify all listeners of a configuration event. 50 | * @param pl the list of plugin message listeners 51 | */ 52 | public Object firePluginMessage(PluginListener pl) { 53 | if (pl instanceof AppletListener) { 54 | ((AppletListener) pl).setApplet(applet); 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/SoundRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.SoundListener; 30 | 31 | import java.net.URL; 32 | 33 | /** 34 | * Play a sound. 35 | *

36 | * Maintainer: Matthias L. Jugel 37 | * 38 | * @version $Id: SoundRequest.java 499 2005-09-29 08:24:54Z leo $ 39 | * @author Matthias L. Jugel, Marcus Mei�ner 40 | */ 41 | public class SoundRequest implements PluginMessage { 42 | protected URL audioClip; 43 | 44 | public SoundRequest(URL audioClip) { 45 | this.audioClip = audioClip; 46 | } 47 | 48 | /** 49 | * Notify all listeners that they may play the sound. 50 | * @param pl the list of plugin message listeners 51 | */ 52 | public Object firePluginMessage(PluginListener pl) { 53 | if(pl instanceof SoundListener) { 54 | ((SoundListener)pl).playSound(audioClip); 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/EndOfRecordRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.EndOfRecordListener; 30 | 31 | /** 32 | * Notification of the end of record event 33 | *

34 | * Maintainer: Marcus Meissner 35 | * 36 | * @version $Id: EndOfRecordRequest.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public class EndOfRecordRequest implements PluginMessage { 40 | /** Create a new local echo request with the specified value. */ 41 | public EndOfRecordRequest() { } 42 | 43 | /** 44 | * Notify all listeners about the end of record message 45 | * @param pl the list of plugin message listeners 46 | * @return always null 47 | */ 48 | public Object firePluginMessage(PluginListener pl) { 49 | if(pl instanceof EndOfRecordListener) 50 | ((EndOfRecordListener)pl).EndOfRecord(); 51 | return null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /java/bothack/bot/Color.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import clojure.lang.Keyword; 4 | 5 | public enum Color { 6 | RED(Keyword.intern(null, "red")), 7 | GREEN(Keyword.intern(null, "green")), 8 | BROWN(Keyword.intern(null, "brown")), 9 | BLUE(Keyword.intern(null, "blue")), 10 | MAGENTA(Keyword.intern(null, "magenta")), 11 | CYAN(Keyword.intern(null, "cyan")), 12 | GRAY(Keyword.intern(null, "gray")), 13 | BOLD(Keyword.intern(null, "bold")), 14 | ORANGE(Keyword.intern(null, "orange")), 15 | BRIGHT_GREEN(Keyword.intern(null, "bright-green")), 16 | YELLOW(Keyword.intern(null, "yellow")), 17 | BRIGHT_BLUE(Keyword.intern(null, "bright-blue")), 18 | BRIGHT_MAGENTA(Keyword.intern(null, "bright-magenta")), 19 | BRIGHT_CYAN(Keyword.intern(null, "bright-cyan")), 20 | WHITE(Keyword.intern(null, "white")), 21 | INVERSE(Keyword.intern(null, "inverse")), 22 | INVERSE_RED(Keyword.intern(null, "inverse-red")), 23 | INVERSE_GREEN(Keyword.intern(null, "inverse-green")), 24 | INVERSE_BROWN(Keyword.intern(null, "inverse-brown")), 25 | INVERSE_BLUE(Keyword.intern(null, "inverse-blue")), 26 | INVERSE_MAGENTA(Keyword.intern(null, "inverse-magenta")), 27 | INVERSE_CYAN(Keyword.intern(null, "inverse-cyan")), 28 | INVERSE_GRAY(Keyword.intern(null, "inverse-gray")), 29 | INVERSE_BOLD(Keyword.intern(null, "inverse-bold")), 30 | INVERSE_ORANGE(Keyword.intern(null, "inverse-orange")), 31 | INVERSE_BRIGHT_GREEN(Keyword.intern(null, "inverse-bright-green")), 32 | INVERSE_YELLOW(Keyword.intern(null, "inverse-yellow")), 33 | INVERSE_BRIGHT_BLUE(Keyword.intern(null, "inverse-bright-blue")), 34 | INVERSE_BRIGHT_MAGENTA(Keyword.intern(null, "inverse-bright-magenta")), 35 | INVERSE_BRIGHT_CYAN(Keyword.intern(null, "inverse-bright-cyan")), 36 | INVERSE_WHITE(Keyword.intern(null, "inverse-white")); 37 | 38 | private final Keyword kw; 39 | private Color(Keyword kw) { 40 | this.kw = kw; 41 | } 42 | 43 | public Keyword getKeyword() { 44 | return kw; 45 | } 46 | } -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/SetWindowSizeRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.SetWindowSizeListener; 30 | 31 | /** 32 | * Request the current window size of the terminal. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: WindowSizeRequest.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public class SetWindowSizeRequest implements PluginMessage { 40 | 41 | private int columns, rows; 42 | public SetWindowSizeRequest(int c, int r) { 43 | rows = r; 44 | columns = c; 45 | } 46 | /** 47 | * Set the new size of the window 48 | * @param pl the list of plugin message listeners 49 | */ 50 | public Object firePluginMessage(PluginListener pl) { 51 | if(pl instanceof SetWindowSizeListener) { 52 | ((SetWindowSizeListener)pl).setWindowSize(columns, rows); 53 | } 54 | return null; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/ReturnFocusRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | 26 | package de.mud.jta.event; 27 | 28 | import de.mud.jta.PluginMessage; 29 | import de.mud.jta.PluginListener; 30 | import de.mud.jta.event.ReturnFocusListener; 31 | 32 | /** 33 | * Notify listeners that the focus is to be returned to whoever wants it. 34 | *

35 | * Implemented after a suggestion by Dave <david@mirrabooka.com> 36 | *

37 | * Maintainer: Matthias L. Jugel 38 | * 39 | * @author Matthias L. Jugel, Marcus Mei�ner 40 | */ 41 | public class ReturnFocusRequest implements PluginMessage { 42 | /** Create a new return focus request.*/ 43 | public ReturnFocusRequest() { } 44 | 45 | /** 46 | * Notify all listeners about return focus message. 47 | * @param pl the list of plugin message listeners 48 | * @return always null 49 | */ 50 | public Object firePluginMessage(PluginListener pl) { 51 | if(pl instanceof ReturnFocusListener) 52 | ((ReturnFocusListener)pl).returnFocus(); 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/TerminalTypeRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.TerminalTypeListener; 30 | 31 | /** 32 | * Request message for the current terminal type. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: TerminalTypeRequest.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public class TerminalTypeRequest implements PluginMessage { 40 | /** 41 | * Ask all terminal type listener about the terminal type and return 42 | * the first answer. 43 | * @param pl the list of plugin message listeners 44 | * @return the terminal type or null 45 | */ 46 | public Object firePluginMessage(PluginListener pl) { 47 | if(pl instanceof TerminalTypeListener) { 48 | Object ret = ((TerminalTypeListener)pl).getTerminalType(); 49 | if(ret != null) return ret; 50 | } 51 | return null; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jta26/de/mud/ssh/SshWrapperExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | 26 | package de.mud.ssh; 27 | 28 | 29 | /** 30 | * This is an example for using the SshWrapper class. Note that the 31 | * password here is in plaintext, so do not make this .class file 32 | * available with your password inside it. 33 | * 34 | *

35 | * Maintainer:Marcus Meissner 36 | * 37 | * @version $Id: SshWrapperExample.java 499 2005-09-29 08:24:54Z leo $ 38 | * @author Matthias L. Jugel, Marcus Mei�ner 39 | */ 40 | public class SshWrapperExample { 41 | public static void main(String args[]) { 42 | SshWrapper ssh = new SshWrapper(); 43 | try { 44 | byte[] buffer = new byte[256]; 45 | ssh.connect(args[0], 22); 46 | ssh.login("marcus", "xxxxx"); 47 | ssh.setPrompt("marcus"); 48 | 49 | System.out.println("after login"); 50 | 51 | ssh.send("ls -l"); 52 | ssh.read(buffer); 53 | System.out.println(new String(buffer)); 54 | } catch (java.io.IOException e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /java/bothack/bot/dungeon/LevelTag.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.dungeon; 2 | 3 | import clojure.lang.Keyword; 4 | 5 | public enum LevelTag { 6 | /** Any level that has an altar */ 7 | ALTAR(Keyword.intern(null, "altar")), 8 | /** Any level that has a temple */ 9 | TEMPLE(Keyword.intern(null, "temple")), 10 | ORACLE(Keyword.intern(null, "oracle")), 11 | MINETOWN(Keyword.intern(null, "minetown")), 12 | MINETOWN_GROTTO(Keyword.intern(null, "minetown-grotto")), 13 | MEDUSA(Keyword.intern(null, "medusa")), 14 | CASTLE(Keyword.intern(null, "castle")), 15 | /** Asmodeus's level */ 16 | ASMODEUS(Keyword.intern(null, "asmodeus")), 17 | /** Baalzebub's level */ 18 | BAALZEBUB(Keyword.intern(null, "baalzebub")), 19 | /** Juiblex's level */ 20 | JUIBLEX(Keyword.intern(null, "juiblex")), 21 | /** Both levels with and without the portal */ 22 | FAKE_WIZTOWER(Keyword.intern(null, "fake-wiztower")), 23 | /** Entrance to the wizard's tower */ 24 | WIZTOWER(Keyword.intern(null, "wiztower")), 25 | /** Valley of the dead */ 26 | VOTD(Keyword.intern(null, "votd")), 27 | /** Bottom level of a three-level branch. */ 28 | BOTTOM(Keyword.intern(null, "bottom")), 29 | /** Middle level of a three-level branch. */ 30 | MIDDLE(Keyword.intern(null, "middle")), 31 | /** Branch end (for MAIN branch this is the level with the vibrating square). */ 32 | END(Keyword.intern(null, "end")), 33 | /** Moloch's sanctum. Deepest level of the game. */ 34 | SANCTUM(Keyword.intern(null, "sanctum")), 35 | /** Entrance to the gnomish mines. */ 36 | MINES(Keyword.intern(null, "mines")), 37 | /** Entrance to sokoban. */ 38 | SOKOBAN(Keyword.intern(null, "sokoban")), 39 | /** Entrance to the quest. */ 40 | QUEST(Keyword.intern(null, "quest")), 41 | /** Entrance to fort ludios. */ 42 | LUDIOS(Keyword.intern(null, "ludios")), 43 | /** Entrance to Vlad's tower. */ 44 | VLAD(Keyword.intern(null, "vlad")); 45 | 46 | private final Keyword kw; 47 | 48 | private LevelTag(Keyword kw) { 49 | this.kw = kw; 50 | } 51 | 52 | public Keyword getKeyword() { 53 | return kw; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject bothack "1.0.0-SNAPSHOT" 2 | :description "BotHack – A NetHack Bot Framework" 3 | :url "https://github.com/krajj7/BotHack" 4 | :license {:name "GPLv2"} 5 | :java-source-paths ["jta26/de/mud" "java"] 6 | :javac-options ["-target" "1.7" "-source" "1.7"] 7 | :plugins [[lein-javadoc "0.1.1"] 8 | [codox "0.8.10"]] 9 | :codox {:output-dir "cljdoc" 10 | :src-dir-uri "https://github.com/krajj7/BotHack/tree/master/" 11 | :src-linenum-anchor-prefix "L"} 12 | :javadoc-opts {:package-names ["bothack.actions" 13 | "bothack.bot" 14 | "bothack.events" 15 | "bothack.prompts"] 16 | :additional-args ["-overview" "doc/overview.html" 17 | "-docencoding" "utf-8" 18 | "-noqualifier" "all" 19 | "-charset" "utf-8" 20 | "-windowtitle" "BotHack JavaDoc" 21 | "-encoding" "utf-8" 22 | "-notimestamp"]} 23 | :dependencies [[org.clojure/clojure "1.6.0"] 24 | [org.clojure/data.priority-map "0.0.7"] 25 | [org.clojure/tools.logging "0.2.6"] 26 | [org.clojure/core.logic "0.8.8"] 27 | [com.cemerick/pomegranate "0.3.0"] 28 | [org.flatland/ordered "1.5.2"] 29 | [org.clojars.achim/multiset "0.1.0-SNAPSHOT"] 30 | [com.jcraft/jsch "0.1.52"] 31 | [criterium "0.4.3"] 32 | [log4j/log4j "1.2.17" :exclusions [javax.mail/mail 33 | javax.jms/jms 34 | com.sun.jmdk/jmxtools 35 | com.sun.jmx/jmxri]]] 36 | ;:global-vars {*warn-on-reflection* true} 37 | :aot [clojure.tools.logging.impl bothack.delegator bothack.actions 38 | bothack.term bothack.ttyrec bothack.main] 39 | :main bothack.main) 40 | -------------------------------------------------------------------------------- /scripts/itemdata/Amulet.pm-x: -------------------------------------------------------------------------------- 1 | package NetHack::Item::Spoiler::Amulet; 2 | { 3 | $NetHack::Item::Spoiler::Amulet::VERSION = '0.21'; } 4 | use strict; 5 | use warnings; 6 | use base 'NetHack::Item::Spoiler'; 7 | 8 | use constant type => 'amulet'; 9 | 10 | my @amulets = map { "$_ amulet" } ( 11 | qw/circular spherical oval triangular pyramidal square concave hexagonal 12 | octagonal/ 13 | ); 14 | 15 | sub _list { 16 | my $amulets = { 17 | 'Amulet of Yendor' => { 18 | price => 30000, 19 | artifact => 1, 20 | fullname => 'The Amulet of Yendor', 21 | appearance => 'Amulet of Yendor', 22 | material => 'mithril', } 23 | 24 | 'Eye of the Aethiopica' => { 25 | price => 4000, 26 | edible => 1, 27 | artifact => 1, 28 | fullname => 'The Eye of the Aethiopica', 29 | base => 'amulet of ESP', 30 | material => 'iron', } 31 | 32 | 'cheap plastic imitation of the Amulet of Yendor' => { 33 | price => 0, 34 | appearance => 'Amulet of Yendor', 35 | material => 'plastic', } 36 | 37 | 'amulet of change' => { 38 | edible => 1, material => 'iron', } 39 | 'amulet of ESP' => { 40 | edible => 1, material => 'iron', } 41 | 'amulet of life saving' => { 42 | material => 'iron', } 43 | 'amulet of magical breathing' => { 44 | edible => 1, material => 'iron', } 45 | 'amulet of reflection' => { 46 | material => 'iron', } 47 | 'amulet of restful sleep' => { 48 | edible => 1, material => 'iron', } 49 | 'amulet of strangulation' => { 50 | edible => 1, material => 'iron', } 51 | 'amulet of unchanging' => { 52 | edible => 1, material => 'iron', } 53 | 'amulet versus poison' => { 54 | edible => 1, material => 'iron', } 55 | }; 56 | 57 | return $amulets, (weight => 20, price => 150, appearances => \@amulets, 58 | glyph => '"'); } 59 | 60 | 1; 61 | 62 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/OnlineStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | 30 | /** 31 | * Notify all listeners that we on or offline. 32 | *

33 | * Maintainer: Matthias L. Jugel 34 | * 35 | * @version $Id: OnlineStatus.java 499 2005-09-29 08:24:54Z leo $ 36 | * @author Matthias L. Jugel, Marcus Mei�ner 37 | */ 38 | public class OnlineStatus implements PluginMessage { 39 | protected boolean online; 40 | 41 | /** Create a new online status message with the specified value. */ 42 | public OnlineStatus(boolean online) { 43 | this.online = online; 44 | } 45 | 46 | /** 47 | * Notify the listers about the online status. 48 | * @param pl the list of plugin message listeners 49 | * @return the window size or null 50 | */ 51 | public Object firePluginMessage(PluginListener pl) { 52 | if(pl instanceof OnlineStatusListener) 53 | if(online) 54 | ((OnlineStatusListener)pl).online(); 55 | else 56 | ((OnlineStatusListener)pl).offline(); 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/ConfigurationRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.PluginConfig; 30 | import de.mud.jta.event.ConfigurationListener; 31 | 32 | 33 | /** 34 | * Configuration request message. Subclassing this message can be used to 35 | * make the configuration more specific and efficient. 36 | *

37 | * Maintainer: Matthias L. Jugel 38 | * 39 | * @version $Id: ConfigurationRequest.java 499 2005-09-29 08:24:54Z leo $ 40 | * @author Matthias L. Jugel, Marcus Mei�ner 41 | */ 42 | public class ConfigurationRequest implements PluginMessage { 43 | PluginConfig config; 44 | 45 | public ConfigurationRequest(PluginConfig config) { 46 | this.config = config; 47 | } 48 | 49 | /** 50 | * Notify all listeners of a configuration event. 51 | * @param pl the list of plugin message listeners 52 | */ 53 | public Object firePluginMessage(PluginListener pl) { 54 | if(pl instanceof ConfigurationListener) { 55 | ((ConfigurationListener)pl).setConfiguration(config); 56 | } 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/LocalEchoRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.LocalEchoListener; 30 | 31 | /** 32 | * Notification of the local echo property. The terminal should echo all 33 | * typed in characters locally of this is true. 34 | *

35 | * Maintainer: Matthias L. Jugel 36 | * 37 | * @version $Id: LocalEchoRequest.java 499 2005-09-29 08:24:54Z leo $ 38 | * @author Matthias L. Jugel, Marcus Mei�ner 39 | */ 40 | public class LocalEchoRequest implements PluginMessage { 41 | protected boolean xecho = false; 42 | 43 | /** Create a new local echo request with the specified value. */ 44 | public LocalEchoRequest(boolean echo) { 45 | xecho = echo; 46 | } 47 | 48 | /** 49 | * Notify all listeners about the status of local echo. 50 | * @param pl the list of plugin message listeners 51 | * @return always null 52 | */ 53 | public Object firePluginMessage(PluginListener pl) { 54 | if(pl instanceof LocalEchoListener) 55 | ((LocalEchoListener)pl).setLocalEcho(xecho); 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /java/bothack/bot/HaveOption.java: -------------------------------------------------------------------------------- 1 | package bothack.bot; 2 | 3 | import bothack.actions.ActionsComplex; 4 | import clojure.lang.Keyword; 5 | 6 | public enum HaveOption { 7 | /** Only items not known to be cursed. */ 8 | NONCURSED(Keyword.intern(null, "noncursed")), 9 | /** Only items not known to be blessed. */ 10 | NONBLESSED(Keyword.intern(null, "nonblessed")), 11 | /** Only items known to be blessed. */ 12 | BLESSED(Keyword.intern(null, "blessed")), 13 | /** Only items known to be cursed. */ 14 | CURSED(Keyword.intern(null, "cursed")), 15 | /** Only items with known BUC status. */ 16 | KNOW_BUC(Keyword.intern(null, "know-buc")), 17 | /** Same as {@link HaveOption#KNOW_BUC} + {@link HaveOption#NONCURSED} */ 18 | SAFE_BUC(Keyword.intern(null, "safe-buc")), 19 | /** Complement of {@link HaveOption#SAFE_BUC}. */ 20 | UNSAFE_BUC(Keyword.intern(null, "unsafe-buc")), 21 | /** Only items currently worn or wielded. */ 22 | IN_USE(Keyword.intern(null, "in-use")), 23 | /** Only items currently worn. */ 24 | WORN(Keyword.intern(null, "worn")), 25 | /** 26 | * Only items that are currently in use or are not blocked by any cursed items. 27 | * @see ActionsComplex#makeUse(IGame, Character) 28 | */ 29 | CAN_USE(Keyword.intern(null, "can-use")), 30 | /** Complement of {@link HaveOption#CAN_USE}. */ 31 | NO_CAN_USE(Keyword.intern(null, "no-can-use")), 32 | /** 33 | * Only items that are not currently in use or are not blocked by any cursed items. 34 | * @see ActionsComplex#removeUse(IGame, Character) 35 | */ 36 | CAN_REMOVE(Keyword.intern(null, "can-remove")), 37 | /** Complement of {@link HaveOption#CAN_REMOVE}. */ 38 | NO_CAN_REMOVE(Keyword.intern(null, "no-can-remove")), 39 | /** 40 | * Also examine containers in main inventory. 41 | * If a matching item is not in main inventory(Keyword.intern(null, "inventory")), return the slot of the container and the matching IItem from inside of it (if present). 42 | * @see ActionsComplex#unbag(IGame, java.util.Map.Entry) 43 | */ 44 | BAGGED(Keyword.intern(null, "bagged")); 45 | 46 | private final Keyword kw; 47 | 48 | private HaveOption(Keyword kw) { 49 | this.kw = kw; 50 | } 51 | 52 | public Keyword getKeyword() { 53 | return kw; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /javabots/JavaBot/src/bothack/javabots/javabot/FeedHandler.java: -------------------------------------------------------------------------------- 1 | package bothack.javabots.javabot; 2 | 3 | import bothack.actions.Actions; 4 | import bothack.actions.IAction; 5 | import bothack.actions.Navigation; 6 | import bothack.actions.Navigation.IPath; 7 | import bothack.bot.Hunger; 8 | import bothack.bot.IGame; 9 | import bothack.bot.IPlayer; 10 | import bothack.bot.IPredicate; 11 | import bothack.bot.dungeon.ITile; 12 | import bothack.bot.items.IItem; 13 | import bothack.bot.items.ItemKind; 14 | import bothack.prompts.IActionHandler; 15 | 16 | public class FeedHandler implements IActionHandler { 17 | String getFoodLabel(IGame game, ITile tile, boolean beneficial) { 18 | final IPlayer player = game.player(); 19 | for (IItem i : tile.items()) 20 | if (i.type().kind() == ItemKind.FOOD && 21 | (!i.isCorpse() || (i.isCorpse() && game.isCorpseFresh(tile, i))) && 22 | ((beneficial && player.canEatWithBenefit(i)) || (!beneficial && player.canEat(i)))) 23 | return i.label(); 24 | return null; 25 | } 26 | 27 | public IAction chooseAction(final IGame game) { 28 | final IPlayer player = game.player(); 29 | final ITile atPlayer = game.currentLevel().at(player); 30 | if (player.isOverloaded() || player.hunger() == Hunger.SATIATED) { 31 | return null; 32 | } 33 | 34 | // eat beneficial corpses 35 | IPath res = null; 36 | res = Navigation.navigate(game, new IPredicate() { 37 | public boolean apply(ITile tile) { 38 | return getFoodLabel(game, tile, true) != null; 39 | } 40 | }, 15); 41 | if (res != null) { 42 | if (res.step() != null) { 43 | return res.step(); 44 | } else { 45 | return Actions.Eat(getFoodLabel(game, atPlayer, true)); 46 | } 47 | } 48 | 49 | //if (!player.isHungry()) 50 | // return null; 51 | 52 | // eat anything 53 | res = Navigation.navigate(game, new IPredicate() { 54 | public boolean apply(ITile tile) { 55 | return getFoodLabel(game, tile, false) != null; 56 | } 57 | }, 15); 58 | if (res != null) { 59 | if (res.step() != null) { 60 | return res.step(); 61 | } else { 62 | return Actions.Eat(getFoodLabel(game, atPlayer, false)); 63 | } 64 | } 65 | 66 | return null; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/TelnetCommandRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.TelnetCommandListener; 30 | 31 | import java.io.IOException; 32 | 33 | /** 34 | * Notification of the end of record event 35 | *

36 | * Maintainer: Marcus Meissner 37 | * 38 | * @version $Id: TelnetCommandRequest.java 499 2005-09-29 08:24:54Z leo $ 39 | * @author Matthias L. Jugel, Marcus Mei�ner 40 | */ 41 | public class TelnetCommandRequest implements PluginMessage { 42 | /** Create a new telnet command request with the specified value. */ 43 | byte cmd; 44 | public TelnetCommandRequest(byte command ) { cmd = command; } 45 | 46 | /** 47 | * Notify all listeners about the end of record message 48 | * @param pl the list of plugin message listeners 49 | * @return always null 50 | */ 51 | public Object firePluginMessage(PluginListener pl) { 52 | if(pl instanceof TelnetCommandListener) { 53 | try { 54 | ((TelnetCommandListener)pl).sendTelnetCommand(cmd); 55 | } catch (IOException io) { 56 | System.err.println("io exception caught:"+io); 57 | io.printStackTrace(); 58 | } 59 | } 60 | return null; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /java/bothack/bot/monsters/IMonsterType.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.monsters; 2 | 3 | import java.util.Set; 4 | 5 | import bothack.bot.IAppearance; 6 | import bothack.bot.Intrinsic; 7 | 8 | /** Immutable representation of one of the 375 NetHack monsters. 9 | * @see MonsterType */ 10 | public interface IMonsterType extends IAppearance { 11 | /** Name of the monster type */ 12 | String name(); 13 | /** Difficulty according to NetHack sources */ 14 | Long difficulty(); 15 | /** How often the monster gets a turn - larger is better */ 16 | Long speed(); 17 | /** Armor class - lower is better */ 18 | Long AC(); 19 | /** Magic resistance */ 20 | Long MR(); 21 | Long alignment(); 22 | //List attacks(); 23 | Long nutrition(); 24 | Set resistances(); 25 | /** Intrinsics the player can gain when eating the corpse */ 26 | Set conferredResistances(); 27 | /** Does the monster have a poisonous corpse? */ 28 | Boolean isPoisonous(); 29 | Boolean isUnique(); 30 | Boolean hasHands(); 31 | /** Is the monster always hostile when generated? 32 | * A peaceful or tame instance of this monster can still exist. */ 33 | Boolean isHostile(); 34 | /** Monsters that will teleport to the upstairs to heal and steal artifacts. */ 35 | Boolean isCovetous(); 36 | Boolean respectsElbereth(); 37 | Boolean seesInvisible(); 38 | Boolean isFollower(); 39 | Boolean isAmphibious(); 40 | Boolean hasDrowningAttack(); 41 | Boolean isFlying(); 42 | Boolean isWerecreature(); 43 | Boolean isMimic(); 44 | Boolean isPriest(); 45 | Boolean isShopkeeper(); 46 | /** Does the monster corrode weapons passively? */ 47 | Boolean isCorrosive(); 48 | /** Does the monster lack active attacks? */ 49 | Boolean isPassive(); 50 | /** Sessile monsters don't move at all. */ 51 | Boolean isSessile(); 52 | /** Killing humans has a penalty for lawfuls, as does cannibalism */ 53 | Boolean isHuman(); 54 | /** Corresponds to a NetHack monster flag */ 55 | Boolean isNasty(); 56 | /** Riders of the apocalypse on Astral */ 57 | Boolean isRider(); 58 | /** Corresponds to a NetHack monster flag */ 59 | Boolean isStrong(); 60 | Boolean isUndead(); 61 | /** True for the minetown watch and vault guards */ 62 | Boolean isGuard(); 63 | /** Mindless monsters can't be seen by telepathy */ 64 | Boolean isMindless(); 65 | Boolean canBeSeenByInfravision(); 66 | } 67 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/FilterPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | import java.io.IOException; 28 | 29 | /** 30 | * The filter plugin is the base interface for plugins that want to intercept 31 | * the communication between front end and back end plugins. Filters and 32 | * protocol handlers are a good example. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: FilterPlugin.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public interface FilterPlugin { 40 | /** 41 | * Set the source plugin where we get our data from and where the data 42 | * sink (write) is. The actual data handling should be done in the 43 | * read() and write() methods. 44 | * @param source the data source 45 | */ 46 | public void setFilterSource(FilterPlugin source) 47 | throws IllegalArgumentException; 48 | 49 | public FilterPlugin getFilterSource(); 50 | 51 | /** 52 | * Read a block of data from the back end. 53 | * @param b the buffer to read the data into 54 | * @return the amount of bytes actually read 55 | */ 56 | public int read(byte[] b) 57 | throws IOException; 58 | 59 | /** 60 | * Write a block of data to the back end. 61 | * @param b the buffer to be sent 62 | */ 63 | public void write(byte[] b) 64 | throws IOException; 65 | } 66 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/FocusStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.Plugin; 28 | import de.mud.jta.PluginMessage; 29 | import de.mud.jta.PluginListener; 30 | 31 | import java.awt.event.FocusEvent; 32 | 33 | /** 34 | * Notify all listeners that a component has got the input focus. 35 | *

36 | * Maintainer: Matthias L. Jugel 37 | * 38 | * @version $Id: FocusStatus.java 499 2005-09-29 08:24:54Z leo $ 39 | * @author Matthias L. Jugel, Marcus Mei�ner 40 | */ 41 | public class FocusStatus implements PluginMessage { 42 | protected Plugin plugin; 43 | protected FocusEvent event; 44 | 45 | /** Create a new online status message with the specified value. */ 46 | public FocusStatus(Plugin plugin, FocusEvent event) { 47 | this.plugin = plugin; 48 | this.event = event; 49 | } 50 | 51 | /** 52 | * Notify the listers about the focus status of the sending component. 53 | * @param pl the list of plugin message listeners 54 | * @return null 55 | */ 56 | public Object firePluginMessage(PluginListener pl) { 57 | if(pl instanceof FocusStatusListener) 58 | switch(event.getID()) { 59 | case FocusEvent.FOCUS_GAINED: 60 | ((FocusStatusListener)pl).pluginGainedFocus(plugin); break; 61 | case FocusEvent.FOCUS_LOST: 62 | ((FocusStatusListener)pl).pluginLostFocus(plugin); 63 | } 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/bothack/bots/dgl_menu.clj: -------------------------------------------------------------------------------- 1 | (ns bothack.bots.dgl-menu 2 | "Navigation for nethack.alt.org/acehack.de dgamelaunch menu - to log in and 3 | start the game." 4 | (:require [bothack.bothack :refer :all] 5 | [bothack.util :refer :all] 6 | [bothack.frame :refer :all] 7 | [bothack.delegator :refer :all] 8 | [bothack.handlers :refer :all] 9 | [clojure.tools.logging :as log])) 10 | 11 | (defn- login-sequence [login pass] 12 | (format "%s\n%s\n" login pass)) 13 | 14 | (defn- menu-drawn? [frame] 15 | (and (some (partial re-seq #"q\) (Quit|Back)") (:lines frame)) 16 | (before-cursor? frame "=> "))) 17 | 18 | (defn- user-prompt? [frame] 19 | (and (some #(.contains % "Please enter your username.") (:lines frame)) 20 | (before-cursor? frame "=> "))) 21 | 22 | (defn- logged-in? [frame] 23 | (some #(.contains % "Logged in as") (:lines frame))) 24 | 25 | (defn init [{:keys [delegator config] :as bh}] 26 | (let [logged-in (reify RedrawHandler 27 | (redraw [this frame] 28 | (when (menu-drawn? frame) 29 | (deregister-handler bh this) 30 | (if-not (logged-in? frame) 31 | (throw (IllegalStateException. "Failed to login"))) 32 | (log/info "DGL menubot finished") 33 | (send delegator started) 34 | (send delegator write (config-get config :dgl-game))))) ; play! 35 | pass-prompt (reify RedrawHandler 36 | (redraw [this frame] 37 | (when (user-prompt? frame) 38 | ; set up the final handler 39 | (send delegator write (login-sequence 40 | (config-get config :dgl-login) 41 | (config-get config :dgl-pass))) 42 | (replace-handler bh this logged-in)))) 43 | trigger (reify RedrawHandler 44 | (redraw [this frame] 45 | (when (menu-drawn? frame) 46 | (log/info "logging in") 47 | (send delegator write \l) 48 | ; set up the followup handler 49 | (replace-handler bh this pass-prompt))))] 50 | (register-handler bh trigger)) 51 | (log/info "Waiting for DGL menu to draw")) 52 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/event/SocketRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta.event; 26 | 27 | import de.mud.jta.PluginMessage; 28 | import de.mud.jta.PluginListener; 29 | import de.mud.jta.event.SocketListener; 30 | 31 | /** 32 | * Notification of a socket request. Send this message if the system 33 | * should connect or disconnect. 34 | *

35 | * Maintainer: Matthias L. Jugel 36 | * 37 | * @version $Id: SocketRequest.java 499 2005-09-29 08:24:54Z leo $ 38 | * @author Matthias L. Jugel, Marcus Mei�ner 39 | */ 40 | public class SocketRequest implements PluginMessage { 41 | String host; 42 | int port; 43 | 44 | /** Create a new disconnect message */ 45 | public SocketRequest() { 46 | host = null; 47 | } 48 | 49 | /** Create a new connect message */ 50 | public SocketRequest(String host, int port) { 51 | this.host = host; 52 | this.port = port; 53 | } 54 | 55 | /** 56 | * Tell all listeners that we would like to connect. 57 | * @param pl the list of plugin message listeners 58 | * @return the terminal type or null 59 | */ 60 | public Object firePluginMessage(PluginListener pl) { 61 | if(pl instanceof SocketListener) try { 62 | if(host != null) 63 | ((SocketListener)pl).connect(host, port); 64 | else 65 | ((SocketListener)pl).disconnect(); 66 | } catch(Exception e) { 67 | e.printStackTrace(); 68 | } 69 | return null; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /java/bothack/bot/dungeon/Feature.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.dungeon; 2 | 3 | import clojure.lang.Keyword; 4 | 5 | public enum Feature { 6 | ROCK(Keyword.intern(null, "rock")), 7 | FLOOR(Keyword.intern(null, "floor")), 8 | WALL(Keyword.intern(null, "wall")), 9 | STAIRS_UP(Keyword.intern(null, "stairs-up")), 10 | STAIRS_DOWN(Keyword.intern(null, "stairs-down")), 11 | CORRIDOR(Keyword.intern(null, "corridor")), 12 | ALTAR(Keyword.intern(null, "altar")), 13 | POOL(Keyword.intern(null, "pool")), 14 | DOOR_OPEN(Keyword.intern(null, "door-open")), 15 | DOOR_CLOSED(Keyword.intern(null, "door-closed")), 16 | DOOR_LOCKED(Keyword.intern(null, "door-locked")), 17 | DOOR_SECRET(Keyword.intern(null, "door-secret")), 18 | SINK(Keyword.intern(null, "sink")), 19 | FOUNTAIN(Keyword.intern(null, "fountain")), 20 | GRAVE(Keyword.intern(null, "grave")), 21 | THRONE(Keyword.intern(null, "throne")), 22 | BARS(Keyword.intern(null, "bars")), 23 | TREE(Keyword.intern(null, "tree")), 24 | DRAWBRIDGE_RAISED(Keyword.intern(null, "drawbridge-raised")), 25 | DRAWBRIDGE_LOWERED(Keyword.intern(null, "drawbridge-lowered")), 26 | LAVA(Keyword.intern(null, "lava")), 27 | ICE(Keyword.intern(null, "ice")), 28 | /** Unknown trap */ 29 | TRAP(Keyword.intern(null, "trap")), 30 | ANTIMAGIC(Keyword.intern(null, "antimagic")), 31 | ARROWTRAP(Keyword.intern(null, "arrowtrap")), 32 | BEARTRAP(Keyword.intern(null, "beartrap")), 33 | DARTTRAP(Keyword.intern(null, "darttrap")), 34 | FIRETRAP(Keyword.intern(null, "firetrap")), 35 | HOLE(Keyword.intern(null, "hole")), 36 | MAGICTRAP(Keyword.intern(null, "magictrap")), 37 | ROCKTRAP(Keyword.intern(null, "rocktrap")), 38 | MINE(Keyword.intern(null, "mine")), 39 | LEVELPORT(Keyword.intern(null, "levelport")), 40 | PIT(Keyword.intern(null, "pit")), 41 | POLYTRAP(Keyword.intern(null, "polytrap")), 42 | PORTAL(Keyword.intern(null, "portal")), 43 | BOULDERTRAP(Keyword.intern(null, "bouldertrap")), 44 | RUSTTRAP(Keyword.intern(null, "rusttrap")), 45 | SLEEPTRAP(Keyword.intern(null, "sleeptrap")), 46 | SPIKEPIT(Keyword.intern(null, "spikepit")), 47 | SQUEAKY(Keyword.intern(null, "squeaky")), 48 | TELETRAP(Keyword.intern(null, "teletrap")), 49 | TRAPDOOR(Keyword.intern(null, "trapdoor")), 50 | WEB(Keyword.intern(null, "web")), 51 | STATUETRAP(Keyword.intern(null, "statuetrap")); 52 | 53 | private final Keyword kw; 54 | 55 | private Feature(Keyword kw) { 56 | this.kw = kw; 57 | } 58 | 59 | public Keyword getKeyword() { 60 | return kw; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /doc/compiling.md: -------------------------------------------------------------------------------- 1 | ## Compiling BotHack from source and running Clojure bots 2 | 3 | These instructions are for Linux systems. 4 | 5 | ### Prerequisites 6 | 7 | * Make sure you have Java 7 JDK (check `javac -version`) 8 | * Install Leiningen from http://leiningen.org/ (prefer the most recent version from the website to a pre-packaged one for your distribution, the installation is very simple) 9 | * Run `lein compile` in the project directory. Dependecies will be downloaded automatically. 10 | 11 | ### Running against a public server 12 | 13 | The framework should work with any server running the nethack.alt.org version of NetHack, for example those at http://alt.org/nethack (USA) and http://nethack.xd.cm (Germany). 14 | 15 | NOTE: Java 8 may be necessary to play on nethack.xd.cm due to [a JDK bug](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6521495) 16 | 17 | * Register an account on your chosen server. 18 | * Replace the default nethackrc for the account with [the one provided](https://github.com/krajj7/BotHack/blob/master/bothack.nethackrc). 19 | * Make a copy of `config/ssh-config.edn` or `config/telnet-config.edn`, set the server address, your username and password. 20 | * Run `lein run config/` 21 | 22 | The DGL (dgamelaunch) menubot set by default in the config files should work with nethack.alt.org and nethack.xd.cm servers, it may need tweaking for other servers. 23 | 24 | Network latency may make the bot play very slowly (and not be CPU-bound), if that is the case consider setting up a local instalation of NetHack (which also allows you to do testing in wizard mode). 25 | 26 | Increasing the JVM heap size limits (`:jvm-opts ["-Xms4g" "-Xmx4g"]` in project.clj) might improve performance. 27 | 28 | ### Running against a local NetHack installation 29 | 30 | The only supported version of NetHack is 3.4.3 with the nethack.alt.org patchset, available here: http://alt.org/nethack/naonh.php 31 | 32 | * Run `ant` in the `jta26` directory. 33 | * Run `make` in the `jta26/jni/linux` directory (use jni.h and jni\_md.h headers provided with your JDK). 34 | * Make a copy of `config/shell-config.edn`, set the command to run NetHack on your system. 35 | * Make sure [the provided nethackrc](https://github.com/krajj7/BotHack/blob/master/bothack.nethackrc). is used when you run the command manually (you should NOT get the initial "It is written in the Book of $DEITY" message when you start a game). 36 | * Run `LD_LIBRARY_PATH=jta26/jni/linux/ lein run config/` 37 | -------------------------------------------------------------------------------- /src/bothack/bots/dgl_menu_wizmode.clj: -------------------------------------------------------------------------------- 1 | (ns bothack.bots.dgl-menu-wizmode 2 | "Navigation for nethack.alt.org/acehack.de dgamelaunch menu - to log in and 3 | start the game in wizmode." 4 | (:require [bothack.bothack :refer :all] 5 | [bothack.util :refer :all] 6 | [bothack.frame :refer :all] 7 | [bothack.delegator :refer :all] 8 | [bothack.handlers :refer :all] 9 | [clojure.tools.logging :as log])) 10 | 11 | (defn- login-sequence [login pass] 12 | (format "%s\n%s\n" login pass)) 13 | 14 | (defn- menu-drawn? [frame] 15 | (and (some (partial re-seq #"q\) (Quit|Back)") (:lines frame)) 16 | (before-cursor? frame "=> "))) 17 | 18 | (defn- user-prompt? [frame] 19 | (and (some #(.contains % "Please enter your username.") (:lines frame)) 20 | (before-cursor? frame "=> "))) 21 | 22 | (defn- logged-in? [frame] 23 | (some #(.contains % "Logged in as ") (:lines frame))) 24 | 25 | (defn init [{:keys [delegator config] :as bh}] 26 | (let [logged-in (reify RedrawHandler 27 | (redraw [this frame] 28 | (when (menu-drawn? frame) 29 | (deregister-handler bh this) 30 | (if-not (logged-in? frame) 31 | (throw (IllegalStateException. "Failed to login"))) 32 | (log/info "DGL menubot finished") 33 | (send delegator started) 34 | ; the n is for acehack.de to select NetHack, for nao it does nothing 35 | (send delegator write "d")))) ; play! 36 | pass-prompt (reify RedrawHandler 37 | (redraw [this frame] 38 | (when (user-prompt? frame) 39 | ; set up the final handler 40 | (send delegator write (login-sequence 41 | (config-get config :dgl-login) 42 | (config-get config :dgl-pass))) 43 | (replace-handler bh this logged-in)))) 44 | trigger (reify RedrawHandler 45 | (redraw [this frame] 46 | (when (menu-drawn? frame) 47 | (log/info "logging in") 48 | (send delegator write \l) 49 | ; set up the followup handler 50 | (replace-handler bh this pass-prompt))))] 51 | (register-handler bh trigger)) 52 | (log/info "Waiting for DGL menu to draw")) 53 | -------------------------------------------------------------------------------- /scripts/itemdata/itemdata.sed: -------------------------------------------------------------------------------- 1 | #!/bin/sed -f 2 | 3 | # turns TAEB's item data into somewhat more Clojure-friendly data 4 | # thanks TAEB! 5 | 6 | /=> {/ !s/, \([a-z][a-z]* [^=]*=> \)/ :\1/g 7 | s/ \([a-zA-Z0-9][a-zA-Z0-9]*[^'] *=>\)/:\1/g 8 | s/=> ''/=> nil/g 9 | s/'/"/g 10 | s/=> //g 11 | s/,//g 12 | s/ }/}/g 13 | s/\(".*"\) *{/{:name \1/ 14 | s/\(:[a-zA-Z0-9][a-zA-Z0-9]*\) */\1 / 15 | /:glyph "[08]"/ !s/"\([0-9][0-9]*\)"/\1/ 16 | s/:glyph "\(.\)"/:glyph \\\1/ 17 | s/}};$/} };/ 18 | s/};}$/ };}/ 19 | s/"accessory"/:accessory/ 20 | /:appearanc/!s/"key"/:key/ 21 | s/"wood"/:wood/ 22 | s/"container"/:container/ 23 | s/"light"/:light/ 24 | s/"metal"/:metal/ 25 | /:appearance/!s/"horn"/:horn/ 26 | s/"weapon"/:weapon/ 27 | s/"leather"/:leather/ 28 | s/"figurine"/:figurine/ 29 | s/"instrument"/:instrument/ 30 | s/"gold"/:gold/ 31 | s/"soft"/:soft/ 32 | s/"silver"/:silver/ 33 | s/"copper"/:copper/ 34 | s/"hard"/:hard/ 35 | s/"iron"/:iron/ 36 | s/"glass"/:glass/ 37 | s/"boots"/:boots/ 38 | s/"shield"/:shield/ 39 | s/"gloves"/:gloves/ 40 | s/"helmet"/:helmet/ 41 | s/"cloak"/:cloak/ 42 | s/"bodyarmor"/:body-armor/ 43 | s/"veggy"/:veggy/ 44 | s/"flesh"/:flesh/ 45 | s/"dragon hide"/:dragon-hide/ 46 | s/"mineral"/:mineral/ 47 | s/"cloth"/:cloth/ 48 | s/"plastic"/:plastic/ 49 | s/"wax"/:wax/ 50 | s/"gemstone"/:gemstone/ 51 | s/"beam"/:beam/ 52 | s/"nodir"/:nodir/ 53 | s/"ray"/:ray/ 54 | s/"mithril"/:mithril/ 55 | s/"bone"/:bone/ 56 | s/"matter"/:matter/ 57 | s/"paper"/:paper/ 58 | s/"escape"/:escape/ 59 | s/"clerical"/:clerical/ 60 | s/"enchantment"/:enchantment/ 61 | s/"divination"/:divination/ 62 | s/"healing"/:healing/ 63 | s/"attack"/:attack/ 64 | s/"distant"/:distant/ 65 | s/"Pri"/:priest/ 66 | s/"Kni"/:knight/ 67 | s/"Sam"/:samurai/ 68 | s/"Wiz"/:wizard/ 69 | s/"Arc"/:archeologist/ 70 | s/"Bar"/:barbarian/ 71 | s/"Cav"/:caveman/ 72 | s/"Hea"/:healer/ 73 | s/"Mon"/:monk/ 74 | s/"Rog"/:rogue/ 75 | s/"Ran"/:ranger/ 76 | s/"Tou"/:tourist/ 77 | s/"Val"/:valkyrie/ 78 | s/:tohit\>/:to-hit/ 79 | /:appearances / s/\([a-zA-Z]\) \([a-zA-Z]\)/\1" "\2/g 80 | /:appearances / s/qw\//"/ 81 | /:appearances / s/\//"/ 82 | s/:appearances \\@/:appearances / 83 | s/:appearance "\([^"]*\)"/:appearances ["\1"]/ 84 | s/:maxcharges\>/:max-charges/ 85 | s/:chargeable 0/:chargeable false/ 86 | s/:chargeable 1/:chargeable true/ 87 | s/:vegan 0/:vegan false/ 88 | s/:vegan 1/:vegan true/ 89 | s/:vegetarian 0/:vegetarian false/ 90 | s/:vegetarian 1/:vegetarian true/ 91 | s/:stackable 1/:stackable true/ 92 | s/:stackable 0/:stackable false/ 93 | s/:emergency 1/:emergency true/ 94 | s/:emergency 0/:emergency false/ 95 | s/:artifact 1/:artifact true/ 96 | s/:artifact 0/:artifact false/ 97 | /^[ \t]*$/d 98 | -------------------------------------------------------------------------------- /jta26/de/mud/ssh/Cipher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.ssh; 26 | 27 | /** 28 | * Cipher class is the type for all other ciphers. 29 | * @author Marcus Meissner 30 | * @version $Id: Cipher.java 499 2005-09-29 08:24:54Z leo $ 31 | */ 32 | 33 | public abstract class Cipher { 34 | 35 | public static Cipher getInstance(String algorithm) { 36 | Class c; 37 | try { 38 | c = Class.forName("de.mud.ssh." + algorithm); 39 | return (Cipher) c.newInstance(); 40 | } catch (Throwable t) { 41 | System.err.println("Cipher: unable to load instance of '" + algorithm + "'"); 42 | return null; 43 | } 44 | } 45 | 46 | /** 47 | * Encrypt source byte array using the instantiated algorithm. 48 | */ 49 | public byte[] encrypt(byte[] src) { 50 | byte[] dest = new byte[src.length]; 51 | encrypt(src, 0, dest, 0, src.length); 52 | return dest; 53 | } 54 | 55 | /** 56 | * The actual encryption takes place here. 57 | */ 58 | public abstract void encrypt(byte[] src, int srcOff, byte[] dest, int destOff, int len); 59 | 60 | /** 61 | * Decrypt source byte array using the instantiated algorithm. 62 | */ 63 | public byte[] decrypt(byte[] src) { 64 | byte[] dest = new byte[src.length]; 65 | decrypt(src, 0, dest, 0, src.length); 66 | return dest; 67 | } 68 | 69 | /** 70 | * The actual decryption takes place here. 71 | */ 72 | public abstract void decrypt(byte[] src, int srcOff, byte[] dest, int destOff, int len); 73 | 74 | public abstract void setKey(byte[] key); 75 | 76 | public void setKey(String key) { 77 | setKey(key.getBytes()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /jta26/README: -------------------------------------------------------------------------------- 1 | JTA - Telnet/SSH for the JAVA(tm) platform 2 | ========================================== 3 | 4 | (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | 6 | Please make sure you read and understood the documentation that comes 7 | with this software. The documentation explains about the most common 8 | problems encountered and contains information about the license this 9 | software is covered by. By using this software you agree to the terms 10 | and conditions laid down in the license. For a quick start the license 11 | is provided in the "license" directory in text format. 12 | 13 | As it seems there are situations where people cannot agree to the license. 14 | Please contact us to discuss the terms and conditions for a commercial 15 | license. Use the address mentioned at the bottom of the file. 16 | 17 | The most current version of the software can always be found at: 18 | 19 | http://javassh.org/ 20 | 21 | The directories and files contained in the distribution contain the 22 | following information: 23 | 24 | README 25 | You are currently reading this file. 26 | REVISION 27 | Contains a list of source files and their respective revision 28 | number. This may be useful to find our which files have 29 | changed since you last updated the software. 30 | CHANGES 31 | This file contains all the comments for the changes made to 32 | the source files. 33 | bin/ 34 | Contains scripts and additional helper programs. 35 | de/ 36 | This is the root package name for the software. It contains 37 | all Java related source files. 38 | doc/ 39 | The documentation for the source is contained herein. 40 | jar/ 41 | Using the make file to compile the source and building jar 42 | files will result in the packages to be stored in that 43 | directory. 44 | jni/ 45 | Implementation of native methods for different platforms. 46 | license/ 47 | Contains the license this software is covered by in text format. 48 | 49 | We provide this software with confidence that is useful. If you feel that 50 | you would like to repay the authors you may do so by either sending a 51 | postcard or whatever you think is appropriate to either Matthias or Marcus. 52 | The mail address can be achieved by sending an email to either leo@mud.de 53 | or marcus@mud.de or both. 54 | 55 | Quite a lot of people have helped us to debug the software and make it 56 | better by giving us new ideas to implement. If you feel that an important 57 | feature is missing do not hesitate to contact us. We thank all those 58 | who have already done so. 59 | 60 | Thank you for using the software. 61 | 62 | Matthias L. Jugel, Marcus Meißner 63 | 64 | Contact: 65 | Matthias L. Jugel | Marcus Meißner 66 | leo@mud.de | marcus@mud.de 67 | -------------------------------------------------------------------------------- /doc/issues.md: -------------------------------------------------------------------------------- 1 | # Known issues 2 | 3 | ## Of the framework 4 | 5 | * Java 8 may be necessary to play on nethack.xd.cm due to [a JDK bug](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6521495) 6 | * if monsters dig out parts of shops in minetown while the bot is entering, the entire level may be marked as a shop and the bot will likely loop trying to price-id things 7 | * amnesia may break item identification for named items and cause a loop (should forget facts about forgotten names but it doesn't always work) 8 | * very rarely the scraper gets stuck in unusual situations (eg. many potions breaking during farming). should use [vt\_tiledata](http://nethackwiki.com/wiki/Vt_tiledata) instead. the auto-unstuck mechanism after 3 idle minutes usually fixes the situation however. 9 | * baalzebub level and some other lairs could use more pre-mapping and faster recog, the bot is usually digging out weird patterns. 10 | * items with really long labels (blessed +0 thoroughly rusty thoroughly corroded ...) may cut off before "(being worn)" and cause issues. 11 | * may get stuck in sokoban when boulders get destroyed (monster with a striking wand) 12 | * if two same direction sets of stairs get generated on a level with possibly ambiguous branching (mines range, vlad range) may get confused about which leads where (hard to handle as the bot may randomly appear on the other stair or elsewhere when it descends for the first time) 13 | * zapping spells is not implemented 14 | * multidrop is not implemented 15 | * only valkyrie and samurai have the quest mapped, other roles will get stuck 16 | * sliming is not handled (doesn't have a reliable message when fixed) 17 | * rare unhandled prompt "That jade ring looks pretty. May I have it?" [yn] (n) 18 | 19 | ## Of mainbot 20 | 21 | * may reach the castle without a wand of striking at get stuck 22 | * when it fails uncursing invocation artifacts it gets stuck 23 | * if fountains at Oracle don't yield Excalibur will dip in minetown and anger guards 24 | * may get stoned by medusa if she descends 25 | * may name a fake Amulet of Yendor as real if Rodney enters the sanctum with a fake (should bag-id) 26 | * unbagging gold piece by piece 27 | * should spend less time exploring during the ascension run 28 | * covetous monsters should be handled more efficiently 29 | * doesn't recover if invocation artifacts fall into water or lava (but tries to avoid it) 30 | * if rodney steals the amulet and gets ported downstairs by the mysterious force, bot will keep looking for him upstairs 31 | * farming will likely fail if there's a trapdoor or a hole or when a djinni appears at the sink 32 | * when missing a usable ring of levitation, bot can't enter Rodney's tower and gets stuck searching 33 | * may hit peacefuls when blind 34 | * hits gas spores even when peacefuls are around 35 | -------------------------------------------------------------------------------- /doc/running.md: -------------------------------------------------------------------------------- 1 | ## Running the example Java bot 2 | 3 | ### Prerequisites 4 | 5 | Make sure you have Java 7 JDK and Maven installed (check `mvn -V`) 6 | 7 | ### Compiling the bot skeleton 8 | 9 | There is a working bot Maven project skeleton available here: 10 | https://github.com/krajj7/BotHack/blob/master/javabots/SimpleBot 11 | 12 | Or a more expanded, but still fairly basic bot example here: 13 | https://github.com/krajj7/BotHack/blob/master/javabots/JavaBot 14 | 15 | To compile these, run `mvn compile` in the project directory. 16 | 17 | BotHack itself doesn't need to be compiled manually to run Java bots against public servers, a packaged version of the framework jar and other dependencies will be downloaded automatically by Maven. 18 | 19 | ### Running against a public server 20 | 21 | The framework should work with any server running the nethack.alt.org version of NetHack, for example those at http://alt.org/nethack (USA) and http://nethack.xd.cm (Germany). 22 | 23 | NOTE: Java 8 may be necessary to play on nethack.xd.cm due to [a JDK bug](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6521495) 24 | 25 | * Register an account on your chosen server. 26 | * Replace the default nethackrc for the account with [the one provided](https://github.com/krajj7/BotHack/blob/master/bothack.nethackrc). 27 | * Edit `config/simplebot-ssh-config.edn` or `config/simplebot-telnet-config.edn` in the SimpleBot project (or the JavaBot equivalents), change the server address, your username and password. 28 | * Run `mvn test -Prun-ssh` or `mvn test -Prun-telnet` 29 | 30 | The DGL (dgamelaunch) menubot set by default in the config files should work with nethack.alt.org and nethack.xd.cm servers, it may need tweaking for other servers. 31 | 32 | Network latency may make the bot play very slowly (and not be CPU-bound), if that is the case consider setting up a local instalation of NetHack (which also allows you to do testing in wizard mode). 33 | 34 | Increasing the JVM heap size limits (`:jvm-opts ["-Xms4g" "-Xmx4g"]` in project.clj) might improve performance. 35 | 36 | ### Running against a local NetHack installation (on Linux) 37 | 38 | The only supported version of NetHack is 3.4.3 with the nethack.alt.org patchset, available here: http://alt.org/nethack/naonh.php 39 | 40 | * Run `ant` in the `jta26` directory. 41 | * Run `make` in the `jta26/jni/linux` directory (use jni.h and jni\_md.h headers provided with your JDK). 42 | * Edit `config/simplebot-shell-config.edn`, set the command to run NetHack on your system. 43 | * Make sure [the provided nethackrc](https://github.com/krajj7/BotHack/blob/master/bothack.nethackrc). is used when you run the command manually (you should NOT get the initial "It is written in the Book of $DEITY" message when you start a game). 44 | * Run `LD_LIBRARY_PATH=../../jta26/jni/linux/ mvn test -Prun-shell` 45 | -------------------------------------------------------------------------------- /jta26/de/mud/jta/Plugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | package de.mud.jta; 26 | 27 | 28 | /** 29 | * Plugin base class for the JTA. A plugin is a component 30 | * for the PluginBus and may occur several times. If we have more than one 31 | * plugin of the same type the protected value id contains the unique plugin 32 | * id as configured in the configuration. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: Plugin.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public class Plugin { 40 | /** holds the plugin bus used for communication between plugins */ 41 | protected PluginBus bus; 42 | /** 43 | * in case we have several plugins of the same type this contains their 44 | * unique id 45 | */ 46 | protected String id; 47 | 48 | /** 49 | * Create a new plugin and set the plugin bus used by this plugin and 50 | * the unique id. The unique id may be null if there is only one plugin 51 | * used by the system. 52 | * @param bus the plugin bus 53 | * @param id the unique plugin id 54 | */ 55 | public Plugin(PluginBus bus, String id) { 56 | this.bus = bus; 57 | this.id = id; 58 | } 59 | 60 | /** 61 | * Return identifier for this plugin. 62 | * @return id string 63 | */ 64 | public String getId() { 65 | return id; 66 | } 67 | 68 | /** 69 | * Print an error message to stderr prepending the plugin name. This method 70 | * is public due to compatibility with Java 1.1 71 | * @param msg the error message 72 | */ 73 | public void error(String msg) { 74 | String name = getClass().toString(); 75 | name = name.substring(name.lastIndexOf('.') + 1); 76 | System.err.println(name + (id != null ? "(" + id + ")" : "") + ": " + msg); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /java/bothack/bot/items/IItem.java: -------------------------------------------------------------------------------- 1 | package bothack.bot.items; 2 | 3 | import java.util.List; 4 | 5 | import bothack.bot.IGame; 6 | 7 | /** 8 | * Immutable representation of an item. 9 | * The item may be on the ground or in inventory or not exist at all. 10 | */ 11 | public interface IItem { 12 | /** For stackable items. Non-stackable will return 1. */ 13 | Long quantity(); 14 | /** How the item appears in the inventory. */ 15 | String label(); 16 | /** The stripped base name of the item. Japanese names are converted to english. 17 | * This may not be the same as the item's {@link IItemType#name()}! 18 | * It may be an unidentified appearance like "buckled boots", which 19 | * is not an existing IItemType name. */ 20 | String name(); 21 | /** Blessedness of the item (if known). */ 22 | BUC buc(); 23 | /** How corroded/burnt/rusty the item is (0-3). */ 24 | Long erosion(); 25 | /** True for rustproof/fireproof/fixed items. */ 26 | Boolean isFixed(); 27 | /** Positive or negative enchantment. Null if unknown. */ 28 | Long enchantment(); 29 | /** Displayed number of charges. Null if unknown. 30 | * @see IItem#isCharged() */ 31 | Long charges(); 32 | /** Displayed number of recharges. Null if unknown. 33 | * @see IItem#isRecharged() */ 34 | Long recharges(); 35 | /** True if the item is not known to be empty. */ 36 | Boolean isCharged(); 37 | /** True if the item has been recharged. */ 38 | Boolean isRecharged(); 39 | /** True if the item requires both hands to wield. */ 40 | Boolean isTwohanded(); 41 | /** True if the item can be safely enchanted. */ 42 | Boolean isSafeToEnchant(); 43 | /** True if the item is an artifact. 44 | * @see IItemType#baseType() */ 45 | Boolean isArtifact(); 46 | /** Returns properties of the item that can be determined without the 47 | * current game context (discoveries). 48 | * @see IGame#identifyType(IItem) */ 49 | IItemType type(); 50 | /** Returns the list of all possible item types for the item without 51 | * considering the current game context (discoveries). 52 | * @see IGame#identifyPossibilities(IItem) */ 53 | List possibilities(); 54 | /** Price demanded at a shop. Null if none. 55 | * @see IItemType#price() */ 56 | Long cost(); 57 | /** True if the item is worn or wielded. */ 58 | Boolean isInUse(); 59 | /** True if the item wielded by the player. */ 60 | Boolean isWielded(); 61 | /** True if the item worn by the player. */ 62 | Boolean isWorn(); 63 | /** True if the item may contain other items. */ 64 | Boolean isContainer(); 65 | /** False if the item is a container with unknown contents. */ 66 | Boolean knowContents(); 67 | /** If the item is a container returns the contents. 68 | * @see IItem#isContainer()*/ 69 | List contents(); 70 | /** True if the item is a monster's corpse. */ 71 | Boolean isCorpse(); 72 | } 73 | -------------------------------------------------------------------------------- /jta26/de/mud/telnet/ScriptHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of "JTA - Telnet/SSH for the JAVA(tm) platform". 3 | * 4 | * (c) Matthias L. Jugel, Marcus Meißner 1996-2005. All Rights Reserved. 5 | * 6 | * Please visit http://javatelnet.org/ for updates and contact. 7 | * 8 | * --LICENSE NOTICE-- 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation; either version 2 12 | * of the License, or (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * --LICENSE NOTICE-- 23 | * 24 | */ 25 | 26 | package de.mud.telnet; 27 | 28 | import java.util.Vector; 29 | 30 | /** 31 | * A script handler, that tries to match strings and returns true when 32 | * it found the string it searched for. 33 | *

34 | * Maintainer: Matthias L. Jugel 35 | * 36 | * @version $Id: ScriptHandler.java 499 2005-09-29 08:24:54Z leo $ 37 | * @author Matthias L. Jugel, Marcus Mei�ner 38 | */ 39 | public class ScriptHandler { 40 | 41 | /** debugging level */ 42 | private final static int debug = 0; 43 | 44 | private int matchPos; // current position in the match 45 | private byte[] match; // the current bytes to look for 46 | private boolean done = true; // nothing to look for! 47 | 48 | /** 49 | * Setup the parser using the passed string. 50 | * @param match the string to look for 51 | */ 52 | public void setup(String match) { 53 | if(match == null) return; 54 | this.match = match.getBytes(); 55 | matchPos = 0; 56 | done = false; 57 | } 58 | 59 | /** 60 | * Try to match the byte array s against the match string. 61 | * @param s the array of bytes to match against 62 | * @param length the amount of bytes in the array 63 | * @return true if the string was found, else false 64 | */ 65 | public boolean match(byte[] s, int length) { 66 | if(done) return true; 67 | for(int i = 0; !done && i < length; i++) { 68 | if(s[i] == match[matchPos]) { 69 | // the whole thing matched so, return the match answer 70 | // and reset to use the next match 71 | if(++matchPos >= match.length) { 72 | done = true; 73 | return true; 74 | } 75 | } else 76 | matchPos = 0; // get back to the beginning 77 | } 78 | return false; 79 | } 80 | } 81 | --------------------------------------------------------------------------------