Difference between revisions of "User:Unsup"

From Discworld MUD Wiki
Jump to: navigation, search
(Add a section on counters)
Line 179: Line 179:
  
 
<pre>alias octogr-maybe put money into backpack; sheathe bo; get bo from harness; get penny from backpack; wait; drop penny; wait; get penny, octogram; wait; put penny, bo into harness; hold bo; octograve with bo; get penny; wait; put penny into backpack</pre>
 
<pre>alias octogr-maybe put money into backpack; sheathe bo; get bo from harness; get penny from backpack; wait; drop penny; wait; get penny, octogram; wait; put penny, bo into harness; hold bo; octograve with bo; get penny; wait; put penny into backpack</pre>
 +
 +
 +
=== Counters, general computations ===
 +
 +
Binary counters (using an alias per bit) are very slow, incrementing a 3-bit "register" takes about 30 seconds with the regular alias penalties, but many individual aliases can be generated to get counters of the form <code>$*$ n</code>, for instance, and FSMs in general can be implemented on aliases. With such counters stacks (or even tapes) can be emulated. General computations would be very slow, but a stack machine (with external aliases for specific tasks) may be handy. Though not yet sure what for.
 +
  
 
=== More tricks/problems to investigate ===
 
=== More tricks/problems to investigate ===

Revision as of 15:43, 3 January 2019

Aliases

Blorples

User:Juliette#Laos provides a nice setup.

"with": Klein bottle, tool, money, etc

I find these kinds of aliases to be rather handy:

alias with-tool get $1$ from backpack; hold $1$ in right hand; $2*$; put $1$ into backpack
alias with-money get money from backpack; $*$; put money into backpack
alias tactics-hands tactics parry $1$; tactics attack $1$
alias with-klein-bottle tactics-hands left; get klein bottle from backpack into right hand; $*$; put klein bottle into backpack; tactics-hands both

Restricting player interactions

Some players don't like certain (or any) interactions, and it gets hard to keep track of it by just writing those down. But nicknames can be used for that, e.g.:

alias violet get violet from backpack; braid violet into $*$ except no-violet&no-interaction hair
nickname player1&player2 as no-violet
nickname player3 as no-interaction

Here is a couple of aliases to manage nickname databases without copying and pasting their previous values each time:

alias nickname-create alias $1$-add \$*\$ as $1$
alias nickname-add $1$-add nickname $2*$; $1$-add alias $1$-add \$*\$&$2*$

Mind space

Both Quow's plugins and his website provide a way to check the mind space taken by spells, it's trivial and better to set in the client, but here's an alias as well:

> mindspace-sum mmm nes ccc tpa grg ahsb fnp boa jpct ftf otf ffm wms
mmm:25 nes:45 ccc:25 tpa:25 grg:40 ahsb:25 fnp:35 boa:10 jpct:20 ftf:20 otf:15 ffm:15 wms:25
Queued command: mindspace-sum-brief mmm nes ccc tpa grg ahsb fnp boa jpct ftf otf ffm wms
> 325.000000
alias mindspace-spell-alias alias mindspace-$1$ \$*\$ + $2$; alias mindspace-print-$1$ \$*\$ $1$:$2$

mindspace-spell-alias cts 15
mindspace-spell-alias ahsb 25
mindspace-spell-alias asb 5
mindspace-spell-alias aiw 25
mindspace-spell-alias baf 15
mindspace-spell-alias bep 50
mindspace-spell-alias bfp 10
mindspace-spell-alias boa 10
mindspace-spell-alias bhee 5
mindspace-spell-alias ceib 25
mindspace-spell-alias cbb 10
mindspace-spell-alias ccc 25
mindspace-spell-alias cips 10
mindspace-spell-alias cfd 10
mindspace-spell-alias cmseq 60
mindspace-spell-alias cms2 60
mindspace-spell-alias cms 40
mindspace-spell-alias ddd 10
mindspace-spell-alias dkdd 60
mindspace-spell-alias dwfpp 25
mindspace-spell-alias dtid 20
mindspace-spell-alias eha 30
mindspace-spell-alias ehai 10
mindspace-spell-alias eham 10
mindspace-spell-alias eha2 10
mindspace-spell-alias eff 20
mindspace-spell-alias esb 10
mindspace-spell-alias fci 15
mindspace-spell-alias fae 20
mindspace-spell-alias ftf 20
mindspace-spell-alias ffm 15
mindspace-spell-alias fhe 10
mindspace-spell-alias ffod 15
mindspace-spell-alias fnp 35
mindspace-spell-alias gon 30
mindspace-spell-alias grtw 25
mindspace-spell-alias gct 5
mindspace-spell-alias grg 40
mindspace-spell-alias gfr 25
mindspace-spell-alias heb 30
mindspace-spell-alias irv 5
mindspace-spell-alias jpct 20
mindspace-spell-alias jmc 20
mindspace-spell-alias jhsd 75
mindspace-spell-alias kof 30
mindspace-spell-alias kid 20
mindspace-spell-alias kpp 15
mindspace-spell-alias mac 10
mindspace-spell-alias masi 60
mindspace-spell-alias mpol 5
mindspace-spell-alias mgagt 30
mindspace-spell-alias mwic 10
mindspace-spell-alias mvc 5
mindspace-spell-alias mmm 25
mindspace-spell-alias mmd 10
mindspace-spell-alias mvs 30
mindspace-spell-alias nes 45
mindspace-spell-alias nha 30
mindspace-spell-alias nmd 15
mindspace-spell-alias otf 15
mindspace-spell-alias obbk 25
mindspace-spell-alias ptqwb 50
mindspace-spell-alias ppp 10
mindspace-spell-alias pfg 30
mindspace-spell-alias plg 30
mindspace-spell-alias pmg 10
mindspace-spell-alias pfga 50
mindspace-spell-alias reap 20
mindspace-spell-alias rpd 5
mindspace-spell-alias rps 30
mindspace-spell-alias rvrv 10
mindspace-spell-alias sssu 30
mindspace-spell-alias sss2 30
mindspace-spell-alias sss 10
mindspace-spell-alias sfper 20
mindspace-spell-alias sfp2 20
mindspace-spell-alias sfp 10
mindspace-spell-alias smr 40
mindspace-spell-alias tdcf 20
mindspace-spell-alias tig 50
mindspace-spell-alias tmc 10
mindspace-spell-alias tpa 25
mindspace-spell-alias tea 10
mindspace-spell-alias updd 25
mindspace-spell-alias vhsc 35
mindspace-spell-alias www 45
mindspace-spell-alias wamg 15
mindspace-spell-alias wbps 30
mindspace-spell-alias wgs 35
mindspace-spell-alias wms 25
mindspace-spell-alias yee 35

alias mindspace-base math 0

alias expand-with-prefix-and-base $ifarg3:$1$-$3$$endif$ $ifarg4:$1$-$4$$endif$ $ifarg5:$1$-$5$$endif$ $ifarg6:$1$-$6$$endif$ $ifarg7:$1$-$7$$endif$ $ifarg8:$1$-$8$$endif$ $ifarg9:$1$-$9$$endif$ $ifarg10:$1$-$10$$endif$ $ifarg11:$1$-$11$$endif$ $ifarg12:$1$-$12$$endif$ $ifarg13:$1$-$13$$endif$ $ifarg14:$1$-$14$$endif$ $ifarg15:$1$-$15$$endif$ $ifarg16:$1$-$16$$endif$ $ifarg17:$1$-$17$$endif$ $ifarg18:$1$-$18$$endif$ $ifarg19:$1$-$19$$endif$ $ifarg20:$1$-$20$$endif$ $ifarg21:$1$-$21$$endif$ $ifarg22:$1$-$22$$endif$ $ifarg23:$1$-$23$$endif$ $ifarg24:$1$-$24$$endif$ $ifarg25:$1$-$25$$endif$ $ifarg26:$1$-$26$$endif$ $ifarg27:$1$-$27$$endif$ $ifarg28:$1$-$28$$endif$ $ifarg29:$1$-$29$$endif$ $ifarg30:$1$-$30$$endif$ $ifarg31:$1$-$31$$endif$ $ifarg32:$1$-$32$$endif$ $ifarg33:$1$-$33$$endif$ $ifarg34:$1$-$34$$endif$ $ifarg35:$1$-$35$$endif$ $ifarg36:$1$-$36$$endif$ $ifarg37:$1$-$37$$endif$ $ifarg38:$1$-$38$$endif$ $ifarg39:$1$-$39$$endif$ $ifarg40:$1$-$40$$endif$ $ifarg41:$1$-$41$$endif$ $ifarg42:$1$-$42$$endif$ $ifarg43:$1$-$43$$endif$ $ifarg44:$1$-$44$$endif$ $ifarg45:$1$-$45$$endif$ $ifarg46:$1$-$46$$endif$ $ifarg47:$1$-$47$$endif$ $ifarg48:$1$-$48$$endif$ $ifarg49:$1$-$49$$endif$ $ifarg50:$1$-$50$$endif$ $2$

alias mindspace-sum expand-with-prefix-and-base mindspace-print frimble $*$; mindspace-sum-brief $*$
alias mindspace-sum-brief expand-with-prefix-and-base mindspace mindspace-base $*$


Library navigation

This is awkward/slow and better to set client-side (as I did, see below), but here are aliases that help to keep track of the direction:

alias alias-swap alias rename $1$ to _tmp; alias rename $2$ to $1$; alias rename _tmp to $2$
alias alias-rotate alias rename $1$ to _tmp; alias rename $2$ to $1$; alias rename $3$ to $2$; alias rename $4$ to $3$; alias rename _tmp to $4$

alias compass-init alias compass-north forward; alias compass-west left; alias compass-east right; alias compass-south backward

alias lib-backward alias-swap compass-south compass-north; alias-swap compass-west compass-east
alias lib-left alias-rotate compass-north compass-east compass-south compass-west
alias lib-right alias-rotate compass-north compass-west compass-south compass-east

alias lbw lib-backward; bw; alias compass-north
alias lfw fw; alias compass-north
alias llt lib-left; left; alias compass-north
alias lrt lib-right; right; alias compass-north


Repetition

These are useful to repeat actions:

alias 2 $*$; $*$
alias 3 2 $*$; $*$
alias 4 3 $*$; $*$
alias 5 4 $*$; $*$
alias 6 5 $*$; $*$
alias 7 6 $*$; $*$
alias 8 7 $*$; $*$
alias 9 8 $*$; $*$
alias 10 9 $*$; $*$
...


Octograving

Octograving only if there's no octogram:

alias octogr-maybe put money into backpack; sheathe bo; get bo from harness; get penny from backpack; wait; drop penny; wait; get penny, octogram; wait; put penny, bo into harness; hold bo; octograve with bo; get penny; wait; put penny into backpack


Counters, general computations

Binary counters (using an alias per bit) are very slow, incrementing a 3-bit "register" takes about 30 seconds with the regular alias penalties, but many individual aliases can be generated to get counters of the form $*$ n, for instance, and FSMs in general can be implemented on aliases. With such counters stacks (or even tapes) can be emulated. General computations would be very slow, but a stack machine (with external aliases for specific tasks) may be handy. Though not yet sure what for.


More tricks/problems to investigate

The aliases are very limited in their capabilities for gathering information from the environment. They can be made to fail or succeed depending on presence of given objects in the inventory (using containers and items needed for aliases to succeed), and maybe with higher covert skills that would also allow to check which NPCs are around by planting items on them (though if they can give some items to players, and/or accept items from them, it could be used for checking as well). Decaying objects may allow to measure time that way (aliases themselves could, but not if there's branching involved). Similarly, alias branching can depend on what's written on a paper, but only using predefined messages: by reading the papers aloud in front of NPCs that react by giving or taking objects in response.

Probably it won't be of much use, but it's potentially fun to play with.


Client-side setup

Quow's database (comes with Quow's MUSHclient plugins, available from http://quow.co.uk/) is handy to look up items and to read map data for speedwalking. Here is an SQLite view I use for item lookup:

create view shops_and_npcs as
select item_name, type, npc_name, sale_price, room_short from
       (select item_name, 'shop' as type, null as 'npc_name', sale_price, room_id
        from shop_items
        union
        select item_name, 'npc' as type, npc_name, null, room_id
        from npc_items natural inner join npc_info)
natural inner join rooms;

As a client, I use telnet running inside Emacs (shell-mode), via a proxy for speedwalking, with hi-lock-mode for highlighting, and the following minor mode for hunting, walking, library navigation:

;; -*- lexical-binding: t; -*-

(defun discworld-issue-command (cmd)
  (lambda ()
    (interactive)
    (comint-simple-send (get-buffer-process (current-buffer))
                        cmd)))

(defun discworld-library-enter ()
  (interactive)
  (setq discworld-north 'forward)
  (setq discworld-north-prev 'forward)
  (funcall (discworld-issue-command "verbose look"))
  (funcall (discworld-issue-command "north"))
  (discworld-keys-mode 1))

(defun discworld-library-revert ()
  (interactive)
  (setq discworld-north discworld-north-prev))

(defun discworld-library-move (where)
  (lambda ()
    (interactive)
    (setq discworld-north-prev discworld-north)
    (setq discworld-north
          (case where
            ('forward discworld-north)
            ('left (case discworld-north
                     ('forward 'right)
                     ('right 'backward)
                     ('backward 'left)
                     ('left 'forward)))
            ('right (case discworld-north
                      ('forward 'left)
                      ('right 'forward)
                      ('backward 'right)
                      ('left 'backward)))
            ('backward (case discworld-north
                         ('forward 'backward)
                         ('right 'left)
                         ('backward 'forward)
                         ('left 'right)))))
    (message "North: %s" (symbol-name discworld-north))
    (funcall (discworld-issue-command (symbol-name where)))))

(setq discworld-keys-mode-map
      (let ((map (make-sparse-keymap "Discworld keys")))
        ;; movement
        (define-key map "f" (discworld-issue-command "n"))
        (define-key map "p" (discworld-issue-command "ne"))
        (define-key map "w" (discworld-issue-command "nw"))
        (define-key map "t" (discworld-issue-command "e"))
        (define-key map "r" (discworld-issue-command "w"))
        (define-key map "c" (discworld-issue-command "s"))
        (define-key map "v" (discworld-issue-command "se"))
        (define-key map "x" (discworld-issue-command "sw"))
        ;; other
        (define-key map "s" (discworld-issue-command "ka"))
        (define-key map "z" (discworld-issue-command "loot"))
        (define-key map "a" (discworld-issue-command "lot"))
        (define-key map "g" (discworld-issue-command "g"))
        (define-key map "b" (discworld-issue-command "bc"))
        (define-key map "1" (discworld-issue-command "kl 1"))
        (define-key map "2" (discworld-issue-command "kl 2"))
        (define-key map "3" (discworld-issue-command "kl 3"))
        (define-key map "4" (discworld-issue-command "kl 4"))
        (define-key map "5" (discworld-issue-command "kl 5"))
        (define-key map "q" 'discworld-keys-mode)

        ;; right hand
        (define-key map "h" (discworld-issue-command "h"))
        (define-key map "n" (discworld-issue-command "con"))
        (define-key map "e" (discworld-issue-command "ctpa"))
        (define-key map [up] (discworld-library-move 'forward))
        (define-key map [down] (discworld-library-move 'backward))
        (define-key map [left] (discworld-library-move 'left))
        (define-key map [right] (discworld-library-move 'right))
        map))


(define-minor-mode discworld-keys-mode
  "Movement keys"
  :lighter " DWK"
  :keymap discworld-keys-mode-map
  )