Jump to content

Shadowing

Members
  • Posts

    722
  • Joined

  • Last visited

Posts posted by Shadowing

  1. Thanks for thee responses guys.

     

    Ya I meant spaced around its circumference. So together all 20 objects forms a circle.

     

    I think this is the formula I saw when I was trying to google it Barand.

     

    I'm confused about the theta part

    Do I use pie for that?

     

    Also not sure how this would give me 20 spaced out. But I guess the theta would determine that.

     

    so really I need 20 slices of pie and a object in the middle of each slice on the circumference.

     

    Maybe I need to find the circumference first then divide it out by 20.

    Then find what each one would be spaced out on the circumference.

    Then some how use that number with a formula to find my x and y?

  2. Every year I run into some math that is over my head lol.

     

    Say I have a circle with a radius of 600 and I want to place 20 objects around the circle perfectly spaced.

     

    I need to figure out what the x and y would be for each object.

  3. A new idea has arose.

    $planets = 10,000;
     
    $rate_pool = array(
    25 => .01,
    24 => .02,
    );
     
    $level_pool = array(
    25 => $planets * $rate_pool[25],
    24 => $planets * $rate_pool[24]
    );
    

    I'll random pull a key from $level_pool then i'll subtract from $level_pool and when one of them are empty I remove the element;

  4. Actually that idea doesn't work either. Cause then there will be like 20 level 10's close together in the galaxy.

     

    So I guess on that principal alone it has to be done with random functionsfunctions

     

    I'll just do that I guess. Unless someone has another idea

  5. I figured out a solution. Using the last 3 digits of every Id

     

    I can say every 100 is level 25 planets

    Every number between 99 and 97 is level 24 planets

     

     

    So 1% of planets would be lvl 25 and 2% would be lvl 24 etc

     

    Whatever I want set each level too. That's a simple solution. Idk why it took me so long to think that idea up

  6. Thanks for the reply requinix

     

    The problem I'm having isn't how to edit a MySQL data base :P

     

    It's figuring out a level of a planet so when I generate 10,000 planets or more each planet is given a level (1-25)

    After all 10,000 planets are inserted into the database. The end result will be that there is fewer level 2's than level 1's and so forth.

  7. Hey guys I have a script I need to build and I'm trying to figure out the most efficient way to do it.

     

    Say I have 1000 rows in mysql (planets).

    Each row has an auto increment id

    I need to cycle through each row and add what level the planet is(1-25). I also need the more higher level a planet is to be more rare in the Galaxy.

     

     

    After coming up with two ideas both not efficient enough. I woke up today with a new idea but I need some help in completing the idea of it.

     

     

    Since each row has its own Id. I'm thinking that can be used to determine rareness of the level. Hoping a math guy here at phofreaks knows of a way I can play on the math with the id.

     

    Thanks

  8. I notice today when i tried to log in through my nexus 7 tablet when clicking on the input field to type my log in information the tablet auto zooms in and pops my keyboard up like it should. The problem though is that it only allows me to type my user name in and scrolling down doesn't scroll the login box down with the rest of the page.

  9. and all i have to do is just add a WHERE clause to grab a certain alliance

     
    SELECT alliance, rank, total
    FROM (
        SELECT alliance,
        @row := @row+1,
        @rank := IF(totnet=@lasttot, @rank, @row) as rank,
        @lasttot := totnet as total
        FROM
            (
            SELECT alliance, SUM(networth) as totnet
            FROM test
            GROUP BY alliance
            ORDER BY SUM(networth) DESC
            ) as tot
            JOIN (SELECT @row:=0, @lasttot:=0,@rank:=0) AS init
        ) ranks WHERE alliance = 5
     
    

    works great

  10. Ahh thanks so much for doing that Barand i was sitting here trying to fill in my stuff on your other post in that other thread but that guy is using two differant tables

     

    My SQL isnt this high in level yet :P

     

    had to change the table to test instead of alliancetest but it works well. Thanks so much

     

    hopefully this example will help break me into understanding sql variables and statements with subqueries. Cause i would really like to beable to free hand write sql on that level

  11. I put together a test table

    CREATE TABLE test
     (
     id INT AUTO_INCREMENT PRIMARY KEY,
     alliance int(5),
     networth int(5)
     )
    
    INSERT INTO test (alliance,networth)
    VALUES(2,100),(2,150),
    (3,130),(3,70),(3,80),
    (4,300),(4,200),(4,100),(4,100),
    (5,100),(5,220),(5,180),
    (6,100),(6,220),(6,110),(6,120),(6,80)
    
  12. Thanks Barand I"m going to try that query out. I did solve the issue just using a 2nd query which was plan B but If that query works then im going to use that instead.

     

    I have another issue now though lol

    Im trying to do ranks with Alliances in my game.

     

    I need to do SUM(game.networth) and compare it to $users_alliance_stat for each alliance. I googled the heck out of this.

    This query almost works accept it doesnt count each alliance instead returns how many members are in the first alliance.

    What im trying to do is add up all the players networth that is in each alliance so I can figure out what rank a alliance is

     

     
    SELECT COUNT(*), SUM(game.networth) as sum_stat FROM game  GROUP BY alliance HAVING sum_stat > $users_alliance_stat
    

     

     

     

    an easier example that doesnt work with sql. But probably easier to understand what i'm trying to do

     

    SELECT COUNT(*) FROM game WHERE SUM(game.networth)  > $users_alliance_stat
    
  13. wierd i just noticed another problem if I do this in myphpadmin

    SELECT experience, id FROM game ORDER BY experience DESC
    

    it gives me a completly differant order then my pagination script which uses

    "SELECT experience,id FROM game ORDER BY experience DESC LIMIT $offset, $rowsperpage"
    
  14. ya thats the problem i have is ties. so when I select the persons rank it lines up where they are in the pagination.

     

    right now on my pagination script it just pulls in order if there is two users with the same experience points (for example) I'm not sure how mysql orders that if im doing order by experience DESC not sure how mysql decides who is next in line.

     

    My first idea was to use

    SELECT COUNT(*) FROM table WHERE points > players points

    but then i was like oh wait that won't work for ties.

     

    So thats the problem im having I need to pull the players exact rank as to where they would show up on my pagination script

     

     

    I can do this if i used another select like select all users who have the same experience as that player and then take that informtation to figure out how many players are ahead of that player but that just seem so lame to do that.

     

     

     

    I"m working on this new idea now that almost works but for some reason its off by like 4 some how haha no idea why

    SET @rownum := 0;
    SELECT rank, experience FROM ( 
                SELECT @rownum := @rownum + 1 AS rank, experience, id                   
                 FROM game ORDER BY experience DESC                   
    ) as result WHERE id= 3112
    
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.