SurpriseMeGameButton in the Lobby
Moderator: Moderators
SurpriseMeGameButton in the Lobby
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...
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:
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.
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
This will increase the chances of you getting this feature by a huge amount.
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")
}
its an improvement, and it needs finishing but its a very good start
Someone fill in that bit.
Ill see about putting it in aflobby today. A little pseudo code goes a very very long long way.
Code: Select all
//optional: pick a team based on some algorithm: todo later
Ill see about putting it in aflobby today. A little pseudo code goes a very very long long way.
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
and I forgot to add "and !passworded" in the post above
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++
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.
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.
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");
}
}
- BrainDamage
- Lobby Developer
- Posts: 1164
- Joined: 25 Sep 2006, 13:56
- BrainDamage
- Lobby Developer
- Posts: 1164
- Joined: 25 Sep 2006, 13:56
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!"
}
like
if battle.focus == false && battle.have_joined_with_surprize_me && battle_no_more_interesting
{
messagebox "warning: the battle is no more interesting!"
}