Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-09-2006, 05:20 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
My baby

PHP Code:
function onFactorSynDiv(equation) {
  
this.result "";
  
this.equation equation;
  
this.oequation equation;
  
this.factors "";
  
temp.checkfactor this.equation[this.equation.size()-1];
  for (
abs(temp.checkfactor)*-1<= abs(temp.checkfactor); a++) {
    if ((
temp.checkfactor a) == int(temp.checkfactor a)) {
      if (
== 0) continue;
      if (
temp.used.index(temp.checkfactor a) == -1) {
        
this.factors.add(temp.checkfactor a);
        
temp.used.add(temp.checkfactor a);
      }
    }
  }

  
onSyntheticDivision(this.factors[0],this.equation);
}

function 
NextDiv() {
  
this.factors.delete(0);
  if (
this.factors.size() > 0onSyntheticDivision(this.factors[0],this.equation);
  else {
    if (
this.result == "") {
      echo(
ParseEquation(this.equationSPC "cannot be factored by this method.");
      return;
    }
    echo(
ParseEquation(this.oequation));
    echo(
"Divided down to" SPC this.result);
    if (
this.equation.size() > 0) {
      if (
this.equation[0] != 1) {
        echo(
ParseEquation(this.equationSPC "is left over.");
      }
    }
    echo(
"Result:" SPC this.result ParseEquation(this.equation));
  }
}

function 
onSyntheticDivision(factor,equation) {
  if ((
equation[equation.size()-1] / factor) != int(equation[equation.size()-1] / factor)) {
    
NextDiv();
    return;
  }
  
temp.arr1 = new[equation.size()];
  
temp.arr2 = new[equation.size()];
  
  
temp.arr2[0] = equation[0];
  
  for (
1equation.size(); a++) {
    
temp.arr1[a] = temp.arr2[a-1] * factor;
    
temp.arr2[a] = temp.arr1[a] + equation[a];
  }
  if (
temp.arr2[temp.arr2.size()-1] == 0) {
    
temp.arr2.delete(temp.arr2.size()-1);
    
this.equation temp.arr2;
    
this.result @= "(x";
    if ((
factor*-1) < 0this.result @= " - ";
    else 
this.result @= " + ";
    
this.result @= abs(factor) @ ")";
  }
  
NextDiv();
}

function 
ParseVar(factor) {
  if (
factor 0) return "+" factor;
  else return 
factor;
}

function 
ParseEquation(equation) {
  for (
0equation.size(); e++) {
    if (
equation[e] == 0) continue;
    if (
equation.size() - 1) {
      if (
abs(equation[e]) == 1temp.toreturn @= "x";
      else 
temp.toreturn @= abs(equation[e]) @ "x";
    }
    else 
temp.toreturn @= abs(equation[e]);
    if (
equation.size() - 2temp.toreturn @= "^" equation.size() - e;
    if (
equation.size() - 1) {
      if (
equation[e] < 0temp.toreturn @= " - ";
      else 
temp.toreturn @= " + ";
    }
  }
  if (
temp.toreturn == 1) return "";
  return 
temp.toreturn;

Synthetic division, anyone?
Reply With Quote
  #2  
Old 04-09-2006, 05:26 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Huh? It's just a calculator.
__________________
Reply With Quote
  #3  
Old 04-09-2006, 05:31 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
>:|
Can your calculator factor x^2 + 5x + 6!?

Of course it can by finding the zero values, but can it actually give (x+2)(x+3) at once?
Reply With Quote
  #4  
Old 04-09-2006, 06:59 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Yen
>:|
Can your calculator factor x^2 + 5x + 6!?
Yea.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #5  
Old 04-09-2006, 11:46 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
So can my calculator, nothing special. I can even make games with mine! (seriously!)
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 04-09-2006, 11:50 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by xXziroXx
So can my calculator, nothing special.
Nah, I still think it's nice though. And it's special on Graal. I never saw one before (on Graal).

Goob job Yen!
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #7  
Old 04-09-2006, 12:24 PM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
Kinda makes me wish I could script... well I can but only a little in GS1, when it comes to GS2 I havn't got a chance.
Reply With Quote
  #8  
Old 04-09-2006, 05:13 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
nice
Reply With Quote
  #9  
Old 04-09-2006, 05:20 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Just what I always wanted, a factor tool that can't handle fraction factors
Reply With Quote
  #10  
Old 04-09-2006, 06:03 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by Python523
Just what I always wanted, a factor tool that can't handle fraction factors
Great! I'll be sure to sign on Graal to use a calculator when my TI runs out of battery. I hope you update this calculator to perform multivariable calculus functions.
__________________
Reply With Quote
  #11  
Old 04-09-2006, 06:51 PM
Damix2 Damix2 is offline
RED SQUARE CLUB
Join Date: Nov 2003
Location: NY-what's better?
Posts: 3,577
Damix2 will become famous soon enough
Quote:
Originally Posted by Yen
>:|
Can your calculator factor x^2 + 5x + 6!?

Of course it can by finding the zero values, but can it actually give (x+2)(x+3) at once?
Yes.
__________________
Reply With Quote
  #12  
Old 04-09-2006, 07:33 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
My calculator can't.
I feel gimp..
BRB slitting wrists.
Reply With Quote
  #13  
Old 04-11-2006, 02:34 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Yen
My calculator can't.
I feel gimp..
BRB slitting wrists.
Go spend $200 on a TI calculator
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #14  
Old 04-12-2006, 01:25 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
I have one.

It can't do factors as far as I know, though.
Reply With Quote
  #15  
Old 04-12-2006, 01:43 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Ugh I hate stacks.
Reply With Quote
  #16  
Old 04-12-2006, 06:27 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
... so am I the only one who loves programming
but hates math?
Reply With Quote
  #17  
Old 04-12-2006, 09:38 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by Prozac
... so am I the only one who loves programming
but hates math?
nope, i despised all my math classes.
Reply With Quote
  #18  
Old 04-12-2006, 04:20 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Yen, you should just make a stack loader that will take in for a string of numbers and operators... and perhaps make some sort of interpretation for variable names.
Reply With Quote
  #19  
Old 04-12-2006, 06:01 PM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
since there is talk of a data structure (a stack)
let's see a gscript bubble sort
or better yet
a red-black threaded binary search tree
(the data structure used on most operating systems to store and access information on hard drives)
Reply With Quote
  #20  
Old 04-12-2006, 06:06 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Prozac
since there is talk of a data structure (a stack)
let's see a gscript bubble sort
or better yet
a red-black threaded binary search tree
(the data structure used on most operating systems to store and access information on hard drives)
ewww @ bubblesort... takes too long... ewwwwww
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:57 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.