SurpriseMeGameButton in the Lobby

SurpriseMeGameButton in the Lobby

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10452
Joined: 24 Jan 2006, 21:12

SurpriseMeGameButton in the Lobby

Post 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...
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post 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?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Post 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
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10452
Joined: 24 Jan 2006, 21:12

Post 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++
MetalSkin
Posts: 77
Joined: 31 Aug 2007, 02:42

Post 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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post 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?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10452
Joined: 24 Jan 2006, 21:12

Post 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 ?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I'm not sure what you mean.

You click the button and it randomly joins a game opening the battle window.
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Post 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"
}
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

oh, thats a different feature and needs a new thread
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Post 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!"
}
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Post by Pendrokar »

You could call the button "Instant Action"!
Post Reply

Return to “Feature Requests”