I've decided to port the game "Killbots" to TI-Basic. (Derived from BSD's "Robots") If you don't know what the game looks like, here's a refresher:

You're the @ sign, and you have to get rid of all the +s by crashing them into each other.

I'm about 75% done with the project, but I still have to code the bot collision code. Does anyone have an algorithm for efficiently deleting an item from a list? I need one for the collision bit. Here's a screenie of my current progress (It's actually faster than it seems):

Have you checked this thread? To delete an item from a list, you could use a For() loop and augment() to delete an element, but it's not really fast. I usually set the element's value to a predetermined value, like 0, and make my program so it treats those items like they are deleted.
souvik1997 wrote:
Have you checked this thread? To delete an item from a list, you could use a For() loop and augment() to delete an element, but it's not really fast. I usually set the element's value to a predetermined value, like 0, and make my program so it treats those items like they are deleted.

Hmm... why would you need the For() loop? And yes, I have seen AHelper's game, but I wanted something that wouldn't be in asm.
I suppose you don't really need the For() loop, you could use seq() instead. To delete item at location Q of list L1, you would do something like this:

Code:
augment({0},L1)->L1:Q+1->Q:augment(L1,{0}):augment(seq(Ans(X),X,1,Q-1),seq(Ans(X),X,Q+1,dim(Ans)->L1:seq(L1(X),X,2,dim(L1)-1->L1
That can be made _much_ more succinct. If Q is 1-indexed:

Code:
seq(L1(X+(X>=Q)),X,1,dim(L1)-1->L1
That's even shorter than my optimized version I was going to post Smile though I see how that would work.

Also, nice work forty-two Wink looking good.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement