almost random teleporter links

Questions and answers about the how and why of making maps.
Post Reply
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

almost random teleporter links

Post by optic delusion »

I want to make a map that forces players to a choke point, where there is a teleporter. I want that tele to randomly link to about 20 other teleporters. Those 20 teles can link randomly to each other, but none of them link back to the first teleporter.
How would I go about doing this?
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
trepan
Dev Wizard
Dev Wizard
Posts: 704
Joined: Fri Feb 21, 2003 7:50 pm

Re: almost random teleporter links

Post by trepan »

Ah, yes, the Monty Hall scenario :-)


Sample 2.0.x code:

Code: Select all

options
  -dddd  # enough to print the linkage table for 2.0.x
  -ms 10 # shots through teleporters will also be random
end


teleporter root
  position 0 0 0
end

teleporter t1
  position 100 30 0
end
teleporter t2
  position 100 10 0
end
teleporter t3
  position 100 -10 0
end
teleporter t4
  position 100 -30 0
end


link
  from root:f
  to   t*:f
end

link
  from root:b
  to   t*:b
end

link
  from t*:f
  to   t*:b
end

link
  from t*:b
  to   t*:f
end
Resultant linkage table:

Code: Select all

TELE(0): root
TELE(1): t1
TELE(2): t2
TELE(3): t3
TELE(4): t4
LINKSRC: root:f                          LINKDST: t*:f
LINKSRC: root:b                          LINKDST: t*:b
LINKSRC: t*:f                            LINKDST: t*:b
LINKSRC: t*:b                            LINKDST: t*:f
SRC   0f:  DSTS 1f 2f 3f 4f
SRC   0b:  DSTS 1b 2b 3b 4b
SRC   1f:  DSTS 1b 2b 3b 4b
SRC   1b:  DSTS 1f 2f 3f 4f
SRC   2f:  DSTS 1b 2b 3b 4b
SRC   2b:  DSTS 1f 2f 3f 4f
SRC   3f:  DSTS 1b 2b 3b 4b
SRC   3b:  DSTS 1f 2f 3f 4f
SRC   4f:  DSTS 1b 2b 3b 4b
SRC   4b:  DSTS 1f 2f 3f 4f
NOTE:
You don't need to use the ':[fb]' suffixes, the following also works:

Code: Select all

link
  from root*
  to   t*
end

link
  from t*
  to   t*
end
Which results in this linkage:

Code: Select all

TELE(0): root
TELE(1): t1
TELE(2): t2
TELE(3): t3
TELE(4): t4
LINKSRC: root*                           LINKDST: t*
LINKSRC: t*                              LINKDST: t*
SRC   0f:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   0b:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   1f:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   1b:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   2f:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   2b:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   3f:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   3b:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   4f:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
SRC   4b:  DSTS 1f 1b 2f 2b 3f 3b 4f 4b
User avatar
mrapple
Sergeant Major
Sergeant Major
Posts: 460
Joined: Wed May 27, 2009 11:59 am
Location: Unknown
Contact:

Re: almost random teleporter links

Post by mrapple »

Amazing!!!

I knew you could link a tele from * to * but I never knew wildcards could be used like that.

Very nice post trepan!
Image
trepan
Dev Wizard
Dev Wizard
Posts: 704
Joined: Fri Feb 21, 2003 7:50 pm

Re: almost random teleporter links

Post by trepan »

That's because you've obviously never bothered to read
through the bzw man page or the wiki documentation:

The wiki link:
http://my.bzflag.org/w/Link

From the SVN 2.0.x man page:

Code: Select all

  The Link object
       Adds a route to teleport a tank between two teleporters.

       # Teleporter names are terminated with either :f (forward)
       # or :b (backwards). The forwards link points to 0 degrees,
       # and the backwards link points to 180. Links are made by
       # pattern matching the teleporter names. The '*' and '?'
       # globbing characters can be used to make multiple matches.
       # If there are multiple matches for the "to" link, then the
       # destination will be selected randomly between the matches.
       # in-game.

       # NOTE: bzfs -d -d -d -d will print the linkage table.

       link
         name example_link
       # this will link all teleporters randomly to all other teleporters
         from *
         to   *
       end

       #  or,  to  link   between  known  teleporters  examp_tele1(front) and examp_tele2(back)

       link
         name  example_realLink
         from examp_tele1:f
         to examp_tele2:b
       end
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

Re: almost random teleporter links

Post by optic delusion »

Yeah, awesome post trepan. You even give two possible solutions! I knew there was a simple way to do it, and was wary of attempting the old trial and error and error approach. I'm getting itchy to try some 2.99 ideas.

Can't link these enough.
http://my.bzflag.org/bzfman.cgi?bzw.5.in
http://my.bzflag.org/bzfman3.cgi?bzw.5.in
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
Post Reply