This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
Author Message
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 28 Mar 2009 06:29:30 pm    Post subject:

I have a few, but I was hoping you guys can think of something. You see, let's say I have these 2 strings:


Code:
"Foe QQ is badly poisoned!→Str0
"SQUIRTLE→Str1


I want a program that outputs [font="Courier New"]Str0
with "[font="Courier New"]SQUIRTLE" in place of "[font="Courier New"]QQ" so that it reads "[font="Courier New"]Foe SQUIRTLE is badly poisoned!"

It needs to be as small and as fast as possible in BASIC, so the process is virtually unnoticed. I think there might be commands other than [font="Courier New"]sub( that might help get this done, but I don't think I know them all. You guys have any ideas?

I'm also theorizing some sort of program to break up sentences so they don't overrun the text box, as well as a way to variably display such text Laughing so help on that would also be appreciated.

A little more off-topic, but what advice do you guys have on AI? I haven't even started working on that beyond a few notes, as good AI may take a while in BASIC
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 28 Mar 2009 06:41:13 pm    Post subject:

Would it always be the phrase "Foe QQ..." or is for any arbitrary string that contains "QQ"?
Back to top
ticalcnoah


Member


Joined: 28 Oct 2007
Posts: 153

Posted: 28 Mar 2009 06:48:25 pm    Post subject:

Here's the code for your first problem.

Code:
:"Foe QQ is badly poisoned!→Str0
:"SQUIRTLE→Str1
:instring(str0,"QQ
:sub(str0,1,Ans-1)+Str1+sub(str0,Ans+1,length(str0)-Ans

The attached file deals with text displaying input is str1 then press down to continue.


Last edited by Guest on 28 Mar 2009 06:51:22 pm; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 28 Mar 2009 07:25:06 pm    Post subject:

Now, what if "QQ" is at the beginning/end of a string?
Back to top
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 28 Mar 2009 07:34:56 pm    Post subject:

ticalcnoah wrote:
Here's the code for your first problem.

Code:
:"Foe QQ is badly poisoned!→Str0
 :"SQUIRTLE→Str1
 :instring(str0,"QQ
 :sub(str0,1,Ans-1)+Str1+sub(str0,Ans+1,length(str0)-Ans

The attached file deals with text displaying input is str1 then press down to continue.


Awesome. Thanks for the code, I forgot completely about [font="Courier New"]instring(
Laughing
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 28 Mar 2009 07:39:11 pm    Post subject:

Weregoose wrote:
Now, what if "QQ" is at the beginning/end of a string?

The program go boom!


Code:
:"Foe QQ badly poisoned!→Str0
:"SQIRTLE→Str1
:inString(Str0,"QQ→S
:If Ans=1:Then
:Str0:Else
:sub(Str0,1,Ans-1)+Str0
:End
:If S+1≠length(Str0
:Ans+sub(Str0,S+1,length(Str0)-S
Back to top
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 29 Mar 2009 12:21:10 am    Post subject:

oh yeah, i didn't think of that....

but then again, I wasn't working on it this second anyway :P

a tad more complicated than i hoped, but no biggie
Back to top
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 29 Mar 2009 12:52:23 am    Post subject:

(any one of the following)
:"Foe QQ is badly poisoned→Str0
:"Go QQ→Str0
:"QQ's attack missed→Str0

:"SQIRTLE→Str1
:inString(Str0,"QQ→S
:If S=1
:Str1+sub(Str0,3,length(Str0)-2
:If S=length(Str0)-1
:sub(Str0,1,length(Str0)-2
:If S>1 and S<length(Str0)-1
:sub(Str0,1,S-1)+Str1+sub(Str0,S+2,length(Str0)-S-2

So, am I sort of getting this?


Last edited by Guest on 29 Mar 2009 12:53:22 am; edited 1 time in total
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 29 Mar 2009 02:51:59 am    Post subject:

I would just store a buffer character to both sides of the string, make the replacement, and then sub( out the good stuff afterward:

"QQ→Str0
"SQUIRTLE→Str1
inString(Str0,"QQ→I
"?"+Str0+"?
sub(Ans,1,I)+Str1+sub(Ans,I+3,length(Ans)-I-2
sub(Ans,2,length(Ans)-2

A new task would be to replace multiple instances of "QQ" within a string.


Last edited by Guest on 11 Jul 2010 05:57:30 pm; edited 1 time in total
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 29 Mar 2009 10:11:25 am    Post subject:

Since you don't have it at the end of the string, you can get rid of that last If S+1... (but still add on the Ans+sub(Str0...)

Last edited by Guest on 11 Jul 2010 05:57:48 pm; edited 1 time in total
Back to top
mr. sir


Newbie


Joined: 21 Feb 2008
Posts: 41

Posted: 29 Mar 2009 10:44:33 am    Post subject:

Like in a hangman game!

I made one of these once, let's see if I can remember the code:


Code:
:" "+Str0+" "→Str0
:instring(Str0,"QQ"→N
:While N≠0
:sub(Str0,1,N-1)+Str1+sub(Str0,N+2,length(Str0)-N-1)→Str0
:instring(Str0,"QQ",N+1→N
:End
:sub(Str0,2,length(Str0)-2→Str0


I think this will work... Yes, it works. You just have to make sure that there is a "QQ" in the string.

EDIT: I fixed it, now it doesn't matter if there is a "QQ" in the string or not.


Last edited by Guest on 29 Mar 2009 10:49:03 am; edited 1 time in total
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 29 Mar 2009 10:48:07 am    Post subject:

I don't think the Repeat loop is necessary (I'm guessing the point of the Repeat loopis to deal with multiple occurrences of the string?).
Back to top
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 29 Mar 2009 10:58:18 am    Post subject:

Weregoose wrote:
I would just store a buffer character to both sides of the string, make the replacement, and then sub( out the good stuff afterward:

"QQ→Str0
"SQUIRTLE→Str1
inString(Str0,"QQ→I
"?"+Str0+"?
sub(Ans,1,I)+Str1+sub(Ans,I+3,length(Ans)-I-2
sub(Ans,2,length(Ans)-2

A new task would be to replace multiple instances of "QQ" within a string.


I like that! It's small and it's probably fast. Thanks, gooseman


Last edited by Guest on 11 Jul 2010 05:57:01 pm; edited 1 time in total
Back to top
mr. sir


Newbie


Joined: 21 Feb 2008
Posts: 41

Posted: 29 Mar 2009 11:19:29 am    Post subject:

Simplethinker: Yeah, I was replying to Weregoose's challenge. How would you do it without a while loop?
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 29 Mar 2009 11:29:08 am    Post subject:

mr. sir wrote:
Simplethinker: Yeah, I was replying to Weregoose's challenge. How would you do it without a while loop?

Whoops, I didn't notice Goose's challenge Neutral. I thought you had just pasted your code from the hangman game. As for the challenge, I don't think you can do it without a loop (or Goto/Lbl) since there's no equivalent version of seq( for strings.
Back to top
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 29 Mar 2009 07:24:31 pm    Post subject:

I don't think there will be much call for that in Pokemon. Phrases in general are pretty short in this game. I don't recall seeing a phrase in Pokemon that had it twice.
Back to top
JoeYoung


Advanced Member


Joined: 15 Nov 2008
Posts: 316

Posted: 07 Apr 2009 10:20:18 pm    Post subject:

Well, since I never made a Pokemon progress topic, guess I'll post some of my progress here :D

I have made humongous leaps and bounds concerning SAVE AND GAME DATA! It's awesome, for me :)

All of this data is stored in the archive anyway, so it really won't get in the way or slow down the program. All data is stored in a series of strings.

For example. all SPECIES data of all Pokemon takes up less than 24000b. This includes type, evolution, base stats, learnable attacks, TM/HM compatibility and more! For individual Pokemon data, it takes up less than 120b per Pokemon. This includes your party, your PC box, and the singular pokemon you may store at the daycare, approximately 250 pokemon, which stores to less than 30000b. the data of each individual pokemon includes it's species, level, DVs, EVs, attacks, trainer info, some status-related stuff like remaining HP, PP, or status, and now with Nickname support!

There are various other sets of data I'm working on. Enemy Trainer data is about 100b apiece, though I'm not sure how many trainers will be present. either way, there'll be plenty of em :D

There's also some battle data for the active pokemon, and the character data for yourself is about 600b (large, I know, but it also contains data for all of your items). there are many things that aren't finished yet, however. attack data and event data are far from it.
Back to top
TI-newb


Member


Joined: 24 Dec 2008
Posts: 158

Posted: 28 Apr 2009 07:56:01 pm    Post subject:

Wow, sounds exciting.
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement