Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5969775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:16:43+00:00 2026-05-22T20:16:43+00:00

i know virtually no java but i’m trying to learn some for this project.

  • 0

i know virtually no java but i’m trying to learn some for this project. I am trying to modify a program called GyaPickupBot which is basically a “pick up game” bot on IRC where players can type: !add in order to get added to a list of players who want to play a game and once enough players !add the bot announces the ip of the game server (i.e. quake server) that the game is to be played on. right now, when the specified number of players !add and the game launches, the bot only lists the players who previously !add’ed before the max number of players was reached. I would like for it to divide all of the players who have !add’ed up into 2 random teams of equal size. I have already done the random part using Collections.shuffle but I have no idea how to divide the players into 2 equally sized teams. I emailed the author who is based in Japan a few weeks ago and he finally replied this morning with some very vague hints on how to do this:

Well… at this time, I don’t have much motivation to maintain this code.
I can only suggest you some hints.

private boolean handleReady(String channel, String sender, String login, String hostname, String message) {
boolean isUpdate = false;
String readyGameID = mgr.getReadyGameID();
if (null != readyGameID) {
// *** add some code here to choose teams and store that result to string variable. something like: "team1: ,,,, team2: ,,,,,"
// *** you can get players list by mgr.getPlayers(readyGameID) in order to divide players to 2 teams randomly 

for (String ch : getChannels()) {
sendMessage(ch, mgr.getPickupReadyString(readyGameID));
// sendNotice(ch, mgr.getPickupReadyString(readyGameID));
// *** then, send that string to channel
}
mgr.setLastGame(Calendar.getInstance().getTimeInMillis(), mgr.getPickupReadyString(readyGameID));
ArrayList<String> players = mgr.getPlayers(readyGameID);
for (String nick : players) {
sendNotice(nick, mgr.getPickupReadyPMString(readyGameID));
// *** and send that string to players too
}
isUpdate = mgr.clearPlayers(players);
}
return isUpdate;

I know this is probably more than what is asked on here, but I’m really trying to learn this but I can’t figure it out and any help would be appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:16:44+00:00Added an answer on May 22, 2026 at 8:16 pm

    The code below is untested, but should give you an idea on how to proceed. Good luck.

    // retrieve all players
    ArrayList<String> players = mgr.getPlayers(readyGameID);
    // randomize the list
    Collections.shuffle(players);
    // instantiate two arraylists for the teams
    ArrayList<String> teamRed = new ArrayList<String>();
    ArrayList<String> teamBlue = new ArrayList<String>();
    
    // add the first half of players to teamRed
    teamRed.addAll(players.subList(0, players.size() / 2 + players.size()%2));
    // and the second half to teamBlue
    teamBlue.addAll(players.subList(players.size() / 2 + players.size()%2, players.size()));
    
    // now do whatever you need to do with the two teams
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty sure I know the answer to this, but short of a virtual
I want to know, how sockets are implemented in the Java Virtual Machine. Is
We all know what virtual functions are in C++, but how are they implemented
I know python functions are virtual by default. Let's say I have this: class
I know that I can share files using Shared Folders in Virtual PC, but
so I'm currently trying to make an OpenID provider. I've tried using two Java
I'm currently writing an iPhone application which gets some data from the user and
OK, this should really be asked to someone from Google, but I just want
I know virtually nothing about F#. I don’t even know the syntax, so I
Virtually every language I know of is basically a variation on a theme: you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.