Jump to content
  • 0

Best Way For Randomly Split


Question

Posted (edited)

Hello guys!

 

Im trying to find the best way to split 3 Vectors...

 

example:

public static Vector<L2PcInstance> players = new Vector<>();

Contains 50 players.

 

I want to split them to 25 - 25 but not taking 1 by 1 .. i want randomly selection in the next 2 vectors

public static Vector<L2PcInstance> vec1 = new Vector<>();
public static Vector<L2PcInstance> vec2 = new Vector<>();

Im always missing something and the result isnt correct. Someone can help me? 

Thank you!!!

Edited by melron

Recommended Posts

  • 0
Posted

Alright then im doing it wrong... And im asking again now, Even if i will use a list to store them ....

Then i have to do the same thing to suffle them right?.......... :D

 

Forget about vectors.. lets say i have list ... i want just the way for a random split for 2 other lists...

You can use the 

Collections.shuffle(list)

to suffle the list.

After you add the elements onto the list use it to suffle it.

  • 0
Posted

Hello guys!

 

Im trying to find the best way to split 3 Vectors...

 

example:

public static Vector<L2PcInstance> players = new Vector<>();

Contains 50 players.

 

I want to split them to 25 - 25 in the next 2 vectors

public static Vector<L2PcInstance> vec1 = new Vector<>();
public static Vector<L2PcInstance> vec2 = new Vector<>();

Im always missing something and the result isnt correct. Someone can help me? 

Thank you!!!

show code

  • 0
Posted (edited)

show code

What code do you need? i havent ready code that working thats why im asking for help...

 

players = 50 players

 

vec1 = 0

vec2 = 0;

 

how i can randomly split the players to vec1 & vec2.

 

Sorry for no posting my code but i think its rly useless since im looking the way for a split

Correct me if im wrong

 

Edit: Actually i havent something to show you.. i just want to create this code 

Edited by melron
  • 0
Posted (edited)

Bla bla bla, you afraid of people leeching your code? If i don't see the code you ain't take your answer.

 

Byeee  :-[

Yea u found it! 

as im saying....

Edit: Actually i havent something to show you.. i just want to create this code

 

i havent ready code to show you im just want find this way to split...

To explain it again:

 

players using the command .example

When the list 'players' collect 50 people the registration will close.

 

after that i want to split the players in these 2 vectors randomly so i can continue work with them...

i think you can understand what i mean.. i wanna start making something...

 

atm the code is here but as i said isnt showing something... You dont need these..

 

Open registrations

 

 

protected void openRegistrations()
   {  
       state = State.REGISTER;
       Broadcast.announceToOnlinePlayers(".::Event::.");
       Broadcast.announceToOnlinePlayers("In one minute registration will be close!");
       ThreadPoolManager.getInstance().scheduleGeneral(new checkRegist(), 60000 );
   } 

 

 

check registrations

Event.java

 

 

protected void Registrations()
    {
	   try
	   {
	       state=State.LOADING;
	       
	       if(players.isEmpty() || players.size() < 50)
	       {
	           Broadcast.announceToOnlinePlayers("Event aborted due to innactivity!");
	           clean();
	           return;
	       }
	       Broadcast.announceToOnlinePlayers("In 30 seconds players will shuffle");
	       ThreadPoolManager.getInstance().scheduleGeneral(new shuffle, 30000 ); 
	   }
	   catch (Exception e)
	   {
		   _log.warning("Error event" + e.getMessage());
	   }
	   
    } 

 

 

 

Say2.java

 

 

checkCommand(_text,activeChar);
		       if(_text.equalsIgnoreCase(".example") || _text.equalsIgnoreCase(".example"))
		           return;

 

 

 

checkCommand in Say2.java

 

 

static void checkCommand(String text,L2PcInstance player)
	   {
	       if(text.equalsIgnoreCase(".example"))
	       {
	           if(Event.players.contains(player))
	           {
	               player.sendMessage("You have already registed to the event.");
	               return;
	           }
	           if(Event.state == Event.State.INACTIVE)
	               return;
	           if(Event.state != Event.State.REGISTER)
	           {
	               player.sendMessage("Event has already started.");
	               return;
	           }
	           Event.players.add(player);
	           player.sendMessage("You registed to the event!!");
	           return;
	       }

 

 

 

And in shuffle i want to make this split... So??

Edited by melron
  • 0
Posted (edited)

Why the fuck you use vector ?

i updated my previous post you can take a look

Edited by melron
  • 0
Posted (edited)

I don't know why you want use vector. Probably you want create 3 teams which is bad lel. You need create teamHolders no vectors but even if you want create vectors i won't go against it.

 

Make a for to all elements of players and use a variable i and check if i > 15 to add the player into vector 1 (then do i++) else add player into vector 2

if this is what you want.

for (int i=0; i <= players.size();)
{
   if (i<=15)
      vectorplayers1.add(players.get(i));
   else
      vectorplayers2.add(players.get(i));
   i++;
}

something like this maybe? i don't even know vector i dont use it.

 

Just giving you the idea on how to split into 3 vectors

Edited by AccessDenied
  • 0
Posted (edited)

I don't know why you want use vector. Probably you want create 3 teams which is bad lel. You need create teamHolders no vectors but even if you want create vectors i won't go against it.

 

Make a for to all elements of players and use a variable i and check if i > 15 to add the player into vector 1 (then do i++) else add player into vector 2

if this is what you want.

for (int i=0; i <= players.size();)
{
   if (i<=15)
      vectorplayers1.add(players.get(i));
   else if (i>15 && i<=30)
      vectorplayers2.add(players.get(i));
   else
      vectorplayers3.add(players.get(i));
   i++;
}

something like this maybe? i don't even know vector i dont use it.

 

Just giving you the idea on how to split into 3 vectors

Thank you for your help, I want 2 teams (the players vector will be clean after the split)

im trying to use a kind of shuffle ... with your way its like the first 25 players go to team1 and the others go to team 2.. i want random selection :/

 

p.s if i can do this one with a better way i will not say no :D

 

But if i will use a list or something , I  should do the same method as im searching now... Am i wrong?

Edited by melron
  • 0
Posted

Thank you for your help, I want 2 teams (the players vector will be clean after the split)

im trying to use a kind of suffle ... with your way its like the first 25 players go to team1 and the others go to team 2.. i want random selection :/

 

p.s if i can do this one with a better way i will not say no :D

 

But if i will use a list or something , I  should do the same method as im searching now... Am i wrong?

 

Making teams don't even use vectors or arrays lel 

what if u need 5 teams u will make 5 vectors? you use sets stored into 1 array.

  • 0
Posted (edited)

Making teams don't even use vectors or arrays lel 

what if u need 5 teams u will make 5 vectors? you use sets stored into 1 array.

Alright then im doing it wrong... And im asking again now, Even if i will use a list to store them ....

Then i have to do the same thing to shuffle them right?.......... :D

 

Forget about vectors.. lets say i have list ... i want just the way for a random split for 2 other lists...

Edited by melron
  • 0
Posted

You can use the 

Collections.shuffle(list)

to suffle the list.

After you add the elements onto the list use it to suffle it.

Thank you!

Guest
This topic is now closed to further replies.


  • Posts

    • 冬天是享受优惠、省钱的好时机。 首次下单时使用促销码 SOCNET 即可获得 15% 折扣 ,适用于全场商品! 前往商店(网站) 前往商店(Telegram 机器人)
    • Winter is the time to save with benefits. Activate the promo code SOCNET on your first order and get a 15% discount on the entire assortment! Go to the store (website) Go to the store (Telegram bot)
    • Winter is the time to save with benefits. Activate the promo code SOCNET on your first order and get a 15% discount on the entire assortment! Go to the store (website) Go to the store (Telegram bot)
    • L2 Kings    Stage 1 – The Awakening Dynasty and Moirai Level Cap: 83 Gear: Dynasty -Moirai & Weapons (Shop for Adena + Drop from mobs/instances ) Masterwork System: Available (Neolithics S required with neolithics u can do armor parts foundation aswell) Class Cloaks: Level 1 - Masterwork sets such us moirai/dynasty stats are boosted also vesper(stage 2) Olf T-Shirt: +6 (fails don’t reset) safe is +2 Dolls: Level 1 Belts: Low & Medium Enchant: Safe +3 / Max +8 / Attribution Easy in Moirai-Dynasty . Main Zones: Varka Outpost: Easy farm, Adena, EXP for new players = > 80- 100kk hour Dragon Valley: Main farm zone — , 100–120kk/hour Weapon Weakness System active (all classes can farm efficiently) Archers get vampiric auto-hits vs mobs Dragon Valley Center: Main Party Zone — boosted drops (Blessed enchants, Neolithics chance) => farm like 150-200kk per hour. Dragon Valley North: Spoil Zone (Asofe + crafting materials for MW) Primeval Isle: Safe autofarm zone (low adena for casual players) ==> 50kk per hour Forge of the Gods & Imperial Tomb: Available from Stage 1 (lower Adena reward in compare with Dragon Valley) Hellbound also avaliable from stage 1 In few words all zones opened but MAIN farm zone with boosted adena and drops is Dragon valley also has more mobs Instances: Zaken (24h Reuse) → Instead of Vespers drop Moirai , 100% chance to drop 1 of 9 dolls lvl 1, Zaken 7-Day Jewelry Raid Bosses (7 RBs): Drop Moirai Parts + Neolithic S grade instead of Vespers parts that has 7 Rb Quest give Icarus Weapons Special Feature 7rb bosses level up soul crystals aswell. Closed Areas : Monaster of SIlence, LOA, ( It wont have mobs) / Mahum Quest/Lizardmen off) Grand Epics: Unlocked on Day 4 of Stage 1 → Antharas, Valakas, Baium, AQ, etc ================================================================================= Stage 2 – Rise of Vespers Level Cap: 85 Gear: Moirai Armors (Adena GM SHOP / Craft/ Drop) Weapons: Icarus Cloaks: Level 2 Olf: +8 Dolls: Level 2 Belts: High & Top Enchant: Safe +3 / Max +8 Masterwork can be with Neolithics S84 aswell but higher so craft will be usefull aswell. 7 Raid Boss Quest Updated: Now works retail give vesper weapons 7rb Bosses Drops : Vespers Instances: Zaken : Drops to retail vespers + the dolls and the extra items that we added on stage 1 New Freya Instance: Added — drops vespers and instead of mid s84 weapons will drop vespers . Extra drops Blessed Bottle of Freya - drops 100% chance 1 of 9 dolls. Farm Areas Dragon Valley remains main farm New Zone : Lair of Antharas (mobs nerfed and added drop Noble stone so solo players can farm too) New Party Zone : LOA Circle   ============================================================================   Stage 3 – The Vorpal ERA Gear: Vorpal Unclock Cloaks: Level 3 Olf: +10 (max cap) Dolls: Level 3 Enchant: Safe +3 / Max +12 Farm Zones : Dragon Valley Center Scorpions becomes a normal solo zone (no longer party zone) Drops:   LOA & Knorik → Mid Weapons avaliable in drop New Party Zone Kariks Instances: Easy Freya Drops Mid Weapons Frintezza Release =================================================================================     Stage 4 – Elegia Era (Final Stage) Elegia Unlock Gear: Elegia Weapons: Elegia TOP s84 ( farmed via H-Freya/ Drops ) Cloaks: Level 5 Dolls: Level 3 (final bonuses) Enchant: Safe +6 / Max +16 Instances: Hard Freya → Drops Elegia Weapons + => The Instance will drop 2-3 parts for sure and also will be able to Join with 7 people . Party Zone will have also drop chances for elegia armor parts and weapons but small   Events (Hourly): Win: 50 Event Medals + 3 GCM + morewards Lose: 25 Medals + 1 GCM + more rewards Tie: 30 Medals + 2 GCM + more rewards   ================================================================================ Epic Fragments Currency Participating in Daily Bosses mass rewarding all players Participating in Instances (zaken freya frintezza etc) all players get reward ================================================================================ Adena - Main server currency (all items in gm shop require adena ) Event Medals (Festival Adena) - Event shop currency Donation coins you can buy with them dressme,cosmetics and premium account Epic Fragments you can buy with them fake epic jewels Olympiad Tokens you can buy many items from olympiad shop (Hero Coin even items that are on next stages) Olympiad Win = 1000 Tokens / Lose = 500 Tokens ================================================================================= Offline Autofarm Allows limited Offline farming requires offline autofarm ticket that you get by voting etc ================================================================================= Grand Epics have Specific Custom NPC that can spawn Epics EU/LATIN TIME ZONE ================================================================================= First Olympiad Day 19 December First Heroes 22 December ( 21 December Last day of 1st Period) After that olympiad will be weekly. ================================================================================= Item price and economy Since adena is main coin of server and NOT donation coins we will always add new items in gm shop with adena in order to burn the adena of server and not be inflation . =================================================================================        
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock