Joining Tables Temporarily

This is perhaps an odd way to go about things, but I am creating several town name generators for my D&D game (so each race/culture has a unique naming style) and I've run into a bit of a problem. I Think I need to be able to combine tables for some of the deck picks. Let me give a bit of a sample of the tables to better illustrate.

Ok so on the following tables, as they are, it's quite simple. What I want is for the first pick to be from either start or middle. I could just have an interim table that chooses from either table, but that's going to throw the odds off, and I am unsure how well that would work with deckpicks. I could just have start repeat the contents of middle but that is bad programming technique (repetition is bad for maintenance) and would mess up the deck picks, giving the possibility of for example pigeon pigeon city. Or I could put them together and just use the combined table twice, but that gives me the possibility of for example one two city.

Is there any way I could, to extend the deck pick concept, put the two decks together, pick a card, then separate out all the cards from the first deck and then just draw from the remaining cards in the second deck?

Or alternatively is their a way to automatically weight a table with the sizes of a subtable? I realize I could do this manually, but it just feels ugly and hackish and bad programming practice.

I could also maybe cobble together some horrible kludge with subtable picks... maybe, it'd be ugly and hackish but at least not have things hardcoded that shouldn't be.

table: examplecity
[!start] [!middle] [!end]
table: start
one
two
red
blue

table: middle
outlaw
flea
pigeon
last
dry
vale
fish

table: end
city
town
gorge

Comments

  • On the first table, can you just do something this like so it picks from either the start or middle evenly?
    table: examplecity
    [!start] [!middle] [!end]
    [!middle] [!end]
    
  • I don't think that would get me the results that I want.While I have the idea of what I want clearly in my head, I'm not sure if I am explaining it very clearly. It would be something that would give a fairly similar result to changing start to:
    table: start
    one
    two
    red
    blue
    7 [!middle]

    Except without the issues that would have if I were to use start multiple times(I shouldn't be so that shouldn't be an issue) and without manually having to change the weight if I add entries to middle. If you happen to decide to do any updates to Inspiration Pad I would love it if you could something to the effect of ![start & middle] that would do this. Though admittedly this may just be due to programmer background leading me to try and do far more complicated things with this than it is intended for.
  • Its still not very clear to me what it is you are trying to do. Perhaps if you give a few example outputs of what you want and (more importantly) examples of what you are trying to avoid. But is sounds like you just need an intermediary table that can randomly do a deck pick off of either start or middle. Don't think of IPP as a programming language, its more like a regular expression engine.
  • The only problem with having the intermediary table is a matter of odds. Start is going to be drastically shorter than middle (middle presently has over 200 results, whereas I expect start to have no more than 20). If I understand how it works by default it will have an even chance of choosing either table, so the individual words from the smaller table are going to have a much higher representation than the ones from the larger table. With my example table with middle being approximately double the size of start, the word blue is going to be twice as common as pigeon, and the effect would be much more noticeable in the actual tables. What I want would be the exact same as:
    table: intermediate
    4 [!start]
    7 [!middle]

    I suppose this is the route I'll take, I'm just not a fan of the need to update the weights as the tables develop. I think at this point its just a matter of representation of individual words in the final results, but just in case here are a few good/bad examples.

    good:
    two fish town (one result from each table)
    dry pigeon gorge (different results from middle table)

    bad:
    pigeon pigeon city (same words twice)
    one two city (two results from start)

    Sorry for all the unclear explanations, but between aspergers and having had my head wrapped around 7 or so coding projects in 5 different languages, I haven't been so great at talking to humans lately :D (sidenote: dear gods why vbscript in fractal mapper)
  • I think the intermediary table would be the easiest way of doing this. Given the random nature of table results, I don't think it'd be very noticeable if the start and middle tables weren't balanced exactly.

    Another option is to add more than two items on the main table:
    table: examplecity
    5:[!start] [!end]
    10:[!start] [!middle] [!end]
    20:[!middle] [!end]
    
  • Well, this is an interesting problem. Here's the set of rules a I understand them:

    1) Three tables, "start", "middle", and "end"
    2) A town name always consists of three different words.
    3) The source tables for those words can only be [start or middle], [middle], [middle or end], in that order.
    4) Don't require hard-coding of anything

    It took some experimentation, but I think I've got it. Maybe this code will work for you.
    ; First, get the size of each table.  TableSize works by stepping through each item in the table until it comes up empty,
    ; then subtracting one from the current count.  This is of course super-hacky, and I'd love to hear about a better way.
    
    set: szStart=[@TableSize with 1, start]
    set: szMiddle=[@TableSize with 1, middle]
    set: szEnd=[@TableSize with 1, end]
    
    ; Here, pretend that the three tables are actually just one big table against which we want to roll three different numbers.  
    ; So for num2 and num3, use CantMatch to compare against what's previously been rolled, and roll again if necessary.
    
    set: num1={1d{{szStart}+{szMiddle}}}
    set: num2=[@CantMatch with 1d{szMiddle}+{szStart}, {num1}, -1]
    set: num3={[@CantMatch with 1d{{szMiddle}+{szEnd}}+{szStart}, {num1}, {num2}]-{szStart}}
    
    ; Compare the three different numbers to table sizes to see 
    ;    a) what table the number refers to  
    ;    b) what number to use on that table (called the revnum, or revised num)
    
    set: table1=[when]{num1}>{szStart}[do]middle[else]start[end]
    set: revnum1=[when]{num1}>{szStart}[do]{{num1}-{szStart}}[else]{num1}[end]
    set: revnum2={{num2}-{szStart}}
    set: table3=[when]{num3}>{szMiddle}[do]end[else]middle[end]
    set: revnum3=[when]{num3}>{szMiddle}[do]{{num3}-{szMiddle}}[else]{num3}[end]
    
    
    ; Armed with this information, fire away.
    
    table: TownName
    [#{revnum1} {table1}] [#{revnum2} middle] [#{revnum3} {table3}]
    
    table: CantMatch
    set: result={{$1}}
    [when]{result}={$2}[do][@CantMatch with {$1}, {$2}, {$3}][else][when]{result}={$3}[do][@CantMatch with {$1}, {$2}, {$3}][else]{result}[end][end]
    
    table: TableSize
    set: value=[#{$1} {$2}]
    [when]{length(value)}>0[do][@TableSize with {{$1}+1}, {$2}][else]{{$1}-1}[end]
    
    table: start
    one
    two
    red
    blue
    
    table: middle
    outlaw
    flea
    pigeon
    last
    dry
    vale
    fish
    
    table: end
    city
    town
    gorge
    
  • That's excellent, largando! :-)
  • Wow, that's pretty impressive largando. I think I follow what's going on, I'll have to give this another look when I'm better rested and have refamiliarized myself with IPP's code.

Leave a Comment