Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #25  
Old 06-18-2008, 11:00 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Stryke View Post
Would this work?

PHP Code:
function onCreated()
{
  
this.start timevar2;
  
this.incompatability = {
                         {
23,46},
                         {
29,44},
                         {
45,96},
                         {
11,77},
                         {
2,32},
                         {
1,12},
                         {
13,69},
                         };
  
this.houselist NULL;
  for(
temp.i=0temp.i<100temp.i++)
  {
    
this.intA 0;
    
this.intB 0;
    while(!
this.intA && !this.intB)
    {
      
this.intA int(random(0,400));
      
this.intB int(random(0,400));
      for(
temp.j=0temp.j<100temp.j++)
      {
        if(
this.intA == this.houselist[temp.j][0])
          
this.int 0;
        else if(
this.intA == this.houselist[temp.j][1])
          
this.int 0;
        else if(
this.intB == this.houselist[temp.j][0])
          
this.int 0;
        else if(
this.intB == this.houselist[temp.j][1])
          
this.int 0;
        if(
this.intA == this.incompatibility[temp.j])
          if(
this.intB == this.incompatibility[temp.j])
            
this.int 0;
        else if(
this.intB == this.incompatibility[temp.j])
          if(
this.intA == this.incompatibility[temp.j])
            
this.int 0;
      }
      if(
this.intA == this.intB)
        
this.int 0;
    }
    
this.houselist.add({this.intA,this.intB});
  }
  
this.end timevar2;
}
savelog2("houseList.txt",this.houselist);
echo(
"Time: " this.end this.start); 
Time: 0.026829004

Damn that's slow compared to others lol
I didn't try it, but, like said, anything using random will not work well with larger numbers.
__________________
Reply With Quote
 

Tags
programming-exercise


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 06:24 PM.


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