Author Topic: Advanced Math in Output( and Text( ?  (Read 7197 times)

0 Members and 1 Guest are viewing this topic.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Advanced Math in Output( and Text( ?
« on: April 28, 2011, 03:44:08 pm »
In a further attempt to speed up text-based games, I'm working to add some code for Correlation to compute arguments inside of ln( and e^(.  This will happen only if your arguments are simple, otherwise Ti-Basic will compute the arguments.

By default I'll allowing addition, subtraction, multiplication, variables, abs( substrings, parenthesis, Ans, L1-L6, Martices, strings and temporary strings.  For instance, this would be totally valid:

Output(2M,17-Ans,L1(Ans

I know that these appear a lot in games.  However, is there anything else that you guys use A LOT?  Please vote, and give suggestions of your own if you think of them.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Advanced Math in Output( and Text( ?
« Reply #1 on: April 28, 2011, 07:35:32 pm »
Division, definitely. sin( and cos( occasionally (for circular structures).




Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #2 on: April 28, 2011, 07:47:12 pm »
I forgot to mention, by the way, I'm not going to add int( because all parameters except strings will be turned into integers anyways.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #3 on: April 28, 2011, 08:06:03 pm »
What about iPart(? XP
Yeah, usually the only times I use sin( and cos( are for circular things. I like to use log(, often, but that is usually to find the number of digits in an integer. Maybe you could make log( do that instead? (meaning find the number of digits, minus 1)

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #4 on: April 28, 2011, 08:10:43 pm »
I've actually never heard of times when people would need the number of digits for Output( and Text(.  Can you enlighten me, please? :)

Just a reminder, you can still use ln( and e^( if you have really weird functions, they just won't be super-duper quick.

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #5 on: April 28, 2011, 08:11:18 pm »
Centering text, right justifying text. If it's a number you need to know how far to place it out from the side.
There's something about Tuesday...


Pushpins 'n' stuff...


Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #6 on: April 28, 2011, 08:12:37 pm »
Centering text, right justifying text. If it's a number you need to know how far to place it out from the side.
Yes, exactly :) I also use it when I am making math programs that output results in a more pretty way :)

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #7 on: April 28, 2011, 08:13:08 pm »
Hmmm...Never thought of that.  Okay, I'll put in log( for that.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #8 on: April 28, 2011, 08:16:48 pm »
Cool, that will be great! As an example, if I know a number is an integer and I want to right justify it so the last number is in the ninth column:
Code: [Select]
Output(1,iPart(10-log(Ans)),Ans

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Advanced Math in Output( and Text( ?
« Reply #9 on: April 28, 2011, 08:33:00 pm »
What about just sending the entire argument string to the OS to evaluate?




Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #10 on: April 28, 2011, 08:34:01 pm »
What about just sending the entire argument string to the OS to evaluate?

The OS does it by default, but it's too slow.  I'm making this a faster one, since most people don't use Anova( or Sort( or other complex ones like that

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #11 on: April 28, 2011, 08:35:54 pm »
You are trying to parse things yourself, for speed, right?

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #12 on: April 28, 2011, 08:38:35 pm »
What about just sending the entire argument string to the OS to evaluate?

The OS does it by default, but it's too slow.  I'm making this a faster one, since most people don't use Anova( or Sort( or other complex ones like that

Anova(? I don't even have that o.O
There's something about Tuesday...


Pushpins 'n' stuff...


Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #13 on: April 28, 2011, 08:39:14 pm »
You are trying to parse things yourself, for speed, right?

Exactly.  The problem is order of operations will be left-to-right (excluding parenthesis), so converting old games will be slightly tricker now.

Btw, slightly off topic, but thanks Runer112 for reminding me of using the stack to help out with this

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Advanced Math in Output( and Text( ?
« Reply #14 on: April 28, 2011, 08:42:52 pm »
For infix parsing, convert to postfix first. It makes your life SO much easier. But left-to-right parsing would be even easier than that, I suppose...
There's something about Tuesday...


Pushpins 'n' stuff...