Table cell optimization question

Hi all!

So I've got a table with nearly 700 rows that I want to update just about constantly. I've actually made all of the change table behaviors but whenever I trigger them (with an 'every x seconds' timer) it really slows down the game. Is there a better way to do this? I'm wondering if maybe I should rearrange the table to have just 1 row and put all of the values in a bunch of columns, this way I can use just 1 change table behavior to update everything (since that behavior only allows for 1 row to be edited, but multiple columns). Would that run significantly more smooth?

Comments

  • unbeatenpixelunbeatenpixel Game Developer Member, PRO Posts: 568

    I wonder too.How can we do table optimization?

    Check out my games on the App Store!

    Wordgraphy / Polycolor / 20 Seconds / Minimal Maze

  • AdrenalineAdrenaline Member Posts: 523

    Bump for the morning experts

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited July 2014

    Hi @Adrenaline Hello, I am a pretend morning expert :wink:

    Interesting question, and your thought concerning making the table search columns and not rows... my thinking there is, there wouldn't be any difference in speed...

    To your full table update/search in a Timer - surely, I'm thinking, that's what's slowing it down... wondering why you need the Timer at all for this?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • colandercolander Member Posts: 1,610

    Anything you can do to streamline your code and improve your logic would help. If you have too much going on at once you will get a performance hit. Search for optimisation tips there is a thread with a bunch of things you can do to streamline your project and performance.

    Look for ways to cut down on the amount of updating you are doing to the tables and how much you are doing each time.

  • AdrenalineAdrenaline Member Posts: 523

    @colander‌ Yeah, that's what I'm trying to do :disappointed:

    @gyroscope‌ My game allows for players to make choices that change the layout of the table with each move. After each move, there's a possibility that they arranged pieces in certain 'winning combos' that will result in some points and the removal of those pieces.
    It's not as simple as a match-3 game, but if that's what you're imagining - you're not far off.
    So, in the background, I've got another table that pulls from the layout of pieces and builds all of the possible combos in play. I compare THIS table to a large table of winning combos to see if the player just scored anything on that particular turn. That's why I need to update the table constantly, and I'm using a timer to do so. Does that make any sense?

  • AdrenalineAdrenaline Member Posts: 523

    I'm gonna try to add in some rules to only update sections of the table when necessary. <--- easier said than done

    I'll report back if it's still no good

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited July 2014

    Hi @Adrenaline Thanks for more info about what your after achieving ... think I've got it clear; the following is how I would approach it - not tested but I'm certain it would be a relatively quick search.

    For my example:
    • Integer attribute called Go for triggering the search to start
    • Integer attribute called ACount set to 1, another called BCount set to 1
    • text attribute called TempCombo
    • I've called your first Table - TableOne; Called your 2nd Table - TableTwo

    For TableOne that is built "that pulls from the layout of pieces and builds all of the possible combos in play" as you say, I'd suggest making each entry as a Text attribute.

    Explain further: you've got one particular combination (I'm guessing here because still not 100% certain how your system is set up without seeing the rules), let's say it's 2,7,25,9 then use tableCellValue to change the first row value of TableOne as exactly that - 2,7,25,9 - and so on for the other rows of TableOne. So when this first table is built/ready, you've got all rows with your user combinations as text.

    Now make sure your column of rows of TableTwo showing the 700 winning combinations is text attribute values as well.

    Rules something like (starting with making Go to 1 when you want to kick off the process):

    Rule: When BCount = 701 and ACount < 21 -- being your max. num. of rows TableTwo and max.num of TableOne + 1
    Change Attribute BCount to 1
    Change Attribute ACount to ACount + 1
    Otherwise
    Change Attribute Go to 0
    
    Rule: When attribute Go is 1 and BCount < 701 and ACount < 21
    Change Attribute TempCombo to tableCellValue(TableOne,ACount,1)
    Rule: -- nested-- When TempCombo ≠ tableCellValue(TableTwo,BCount,1)
    Change Attribute BCount to BCount+1
    Change Attribute Go to 2
    Otherwise
    ---do your stuff because there's a matching combination
    
    Rule: When Go = 2
    Change Attribute Go to 1
    

    The above is untested but I think I've got the logic correct - if not, hope you get the idea. (+hope I haven't misunderstood what you're after and it helps).

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • AdrenalineAdrenaline Member Posts: 523

    thank you @gyroscope‌ ! I really appreciate you taking the time to not only consider my problem, but also share your ideas. I think I follow it as I read it. Still need to try to implement it in my game and test. Again, thank you!

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    You're welcome, @Adrenaline. :smile:

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.