Page 1 of 1

SurpriseMeGameButton in the Lobby

Posted: 06 Oct 2007, 16:20
by PicassoCT
Just a button, you hit it, and the Lobby autojoins in the Background a open Game you have Map&Mod for, out places, teams you up and takes you in there once the shows starts...

Posted: 06 Oct 2007, 17:22
by AF
lot of these kinds of requests are randomly made by all sorts of people, but they don't carry it through.

devise an algorithm or 'process' describing how the lobby would decide which game and what teams to pick using if else statements. It doesn't have to be in any language just use plain English e.g:

Code: Select all

if there are any open battles then
    pick a battle
else
    tell the user off
end if
Start off simple then start breaking things up into smaller parts so the 'pick a battle line' becomes 'choose a battle' followed by 'join that battle' and so on.

This will increase the chances of you getting this feature by a huge amount.

Posted: 06 Oct 2007, 17:35
by lurker

Code: Select all

new "list" randomBattleList
for each battle: {
     if (battleOpen AND !locked AND haveMap AND haveMod) {
          add battle to randomBattleList
     }
}
if sizeof(randomBattleList) != 0 {
     pick a random battle from the "list" and join it
     //optional: pick a team based on some algorithm: todo later
}else{
     print("error.  no suitable battles found")
}
Does that work?

Posted: 06 Oct 2007, 17:47
by AF
its an improvement, and it needs finishing but its a very good start

Code: Select all

//optional: pick a team based on some algorithm: todo later
Someone fill in that bit.

Ill see about putting it in aflobby today. A little pseudo code goes a very very long long way.

Posted: 06 Oct 2007, 19:11
by lurker

Code: Select all

ChooseAlly(void) {
     if battle has startboxes {
          int playersPerTeam[number of startboxes]
          for each player that is not me{
               if ((ally number of player) <= 
                              (number of startboxes)) {
                    playersPerTeam[number of player]++
               }
          }
          int allyToJoin = 1
          for i, i < number of startboxes, i++ {
               if playersPerTeam[allyToJoin] >
                                  playersPerTeam[i] {
                    allyToJoin = i
               }
          }
          join allyToJoin
     }else{
         // default battle join behavior is fine; do nothing
     }
}
run ChooseAlly upon joining and when the startboxes change
This will join the first ally group with fewer players than ally 1, or, failing that, will join ally 1
and I forgot to add "and !passworded" in the post above

Posted: 07 Oct 2007, 09:38
by PicassoCT
lurker wrote:

Code: Select all

ChooseAlly(void) {
     if battle has startboxes {
          int playersPerTeam[number of startboxes]
          for each player that is not me{
               if ((ally number of player) <= 
                              (number of startboxes)) {
                    playersPerTeam[number of player]++
               }
          }
          int allyToJoin = 1
          for i, i < number of startboxes, i++ {
               if playersPerTeam[allyToJoin] >
                                  playersPerTeam[i] {
                    allyToJoin = i
               }
          }
          join allyToJoin
     }else{
         // default battle join behavior is fine; do nothing
     }
}
[/quote]

Maybee add a Timer : if GamewaitingTime is >3 Mins 
add CurrentBattle to NeverGoingtoStart.list
set randomBattlelist = 0. (Loop ?)

Sorry if this hurts some Coders feelings - has been years since i tryied to work with C++

Posted: 08 Oct 2007, 05:43
by MetalSkin
would be nice if it had a filter where it would only choose games where the average rank is above a certain threshold. Also a filter to restrict specific maps.

And then you may wish to add a filter to restrict certain hosts, or maybe host locations.

And then you may wish to ignore games if they contain people in a do not play list you have built.

I can do the pseudo code, but I'm in my lunch break and need to get back into it.

Posted: 08 Oct 2007, 11:10
by AF
lurkers code suffices, Ill implement it when I get back this afternoon. Adding more filters should just be a matter of adding if blocks with continue; statements inside in the for loop.

Posted: 12 Oct 2007, 22:13
by AF

Code: Select all

    private void SurpriseMeButtonActionPerformed(java.awt.event.ActionEvent evt) {
        ArrayList<CBattleInfo> randomBattleList = new ArrayList<CBattleInfo>();
        ArrayList<CBattleInfo> battles = jbm.battles;
        for (CBattleInfo i : battles) {
            if (!i.IsIngame() && !i.locked && !i.IsPassworded() && !i.isladdergame()) {// AND i.haveMap AND haveMod) {
                randomBattleList.add(i);
            }
        }
        if (!randomBattleList.isEmpty()) {
            //pick a random battle from the "list" and join it
            Random r = new Random();
            r.setSeed(randomBattleList.size());
            int i = r.nextInt(randomBattleList.size());
            JoinBattle(randomBattleList.get(i));
        } else {
            LM.Toasts.AddMessage("No suitable battles found");
        }
}
Will this suffice for now?

Posted: 13 Oct 2007, 00:09
by PicassoCT
Great Workx AF

Just one last Question - assuming this is happening in the Background after the Button has been hit - the Players in the BattleRoom can somehow call the Attention of the SurpriseButton Joiner if there arrises a Problem ?

Posted: 13 Oct 2007, 00:29
by AF
I'm not sure what you mean.

You click the button and it randomly joins a game opening the battle window.

Posted: 13 Oct 2007, 01:16
by BrainDamage
i think he means like a checkbox wich enables in the event handler

if event_battle_wich_satisfies_surprize_me == true && battlelist_focus == false && checkbox_warn_me_on_interesting_battle == true
{
messagbox "interesting battle opened, wanna join it? yes/no"
}

Posted: 13 Oct 2007, 01:19
by AF
oh, thats a different feature and needs a new thread

Posted: 13 Oct 2007, 01:40
by BrainDamage
nvm, re-reading it i got it wrong, he wanted a message in the case the battle that was pointed as interesting was changed if you lost focus & wasn't interesting anymore

like

if battle.focus == false && battle.have_joined_with_surprize_me && battle_no_more_interesting
{
messagebox "warning: the battle is no more interesting!"
}

Posted: 13 Oct 2007, 11:38
by Pendrokar
You could call the button "Instant Action"!