d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Coding Irc Bot In Java
12Next
Add Reply New Topic New Poll
Member
Posts: 2,064
Joined: Feb 10 2007
Gold: 107.00
Jan 18 2013 08:58pm
Right now we're working on a scrim bot like C9DL (a DotA matchmaker) and we're stuck at an issue where calling the array list for ELO or MMR and sorting it to balance teams we need the ELO or MMR to link to the player names and we can't figure out how to do this.

If anyone has any insight how to link two arrays while sorting help would be much appreciated.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 18 2013 09:04pm
I dunno if this will help at all or if I understand the problem fully but would a binary tree work for this? Fields for player name/mmr.....use the sorting algorithm and have it sort based on MMR? Left branch for lower mmr right branch for higher mmr.

Then just use a tree search function to retrieve a players name etc maybe?
Member
Posts: 2,064
Joined: Feb 10 2007
Gold: 107.00
Jan 18 2013 09:16pm
I don't understand what you mean by binary tree (since I do not code for a living) but here's a full explanation of where we are at.

To better explain the full situation. First of all it is a bot in mIRC that allows people to sign up for scrims.

1. Players will sign up until 10 players.
2. Bot closes off the sign ups and allows no more people to sign.
3. The bot takes the current players and matches them with their current ELO.

This is where bad things happen.

4. The bot sorts the MMR, but the players need to still be in the array with their respective MMRs after the sort is finished.

The arrays will be 2x10, 10 players, 10 MMRs.

What ideally would be the plan (but no idea how to code it) is have the first original 2x10 with each player and MMR in one array, copy over the MMR to another and sort it in a 2x10 and call the data by matching MMRs with their respective names. No idea if this will work I'm mainly trying to figure out a way for the programmer to work with this as coding I know is not that strong, especially in Java.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 18 2013 09:28pm
well a binary tree is just a data structure used for programming and if you have some sort of defined # you can use to sort it with they become very useful. (Pretty efficient algorithm to sort)

I am not quite sure how to code them in java.

The tree is composed of 'nodes' which contain data - different fields (ints, strings etc). The tree class contains methods to access these nodes, insert nodes sort them etc.

The idea (to me) would be to make 2 fields minimum - an integer to contain the persons MMR/ELO and a string to contain their name.

Then each node of the tree would contain a name + mmr value and you could modify a sorting algorithm to just sort based on the mmr int value.

For making matches you could just match a node with its parent or something maybe.


I dunno it seems like it would make more sense than using a 2x10 array that you have to sort twice?

This post was edited by Eep on Jan 18 2013 09:29pm
Member
Posts: 2,064
Joined: Feb 10 2007
Gold: 107.00
Jan 18 2013 09:57pm
How would you go about writing a binary tree or starting it? Started to do some reading on it.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 18 2013 10:26pm
Quote (Nagello @ Jan 18 2013 10:57pm)
How would you go about writing a binary tree or starting it?  Started to do some reading on it.


I think most popular languages ( java, c++, c# etc ) probably have a structure library you can just implement that includes a template class + all the good methods. I can't, however, tell you how to modify the methods unless you have access to the source code or whatever.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jan 18 2013 10:40pm
maybe i'm confused, but i dont know why you mentioned binary tree. it sounds like he just wants to sort an array of objects by different criteria. if you're using java, look into Comparator
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 18 2013 10:45pm
Quote (carteblanche @ Jan 18 2013 11:40pm)
maybe i'm confused, but i dont know why you mentioned binary tree. it sounds like he just wants to sort an array of objects by different criteria. if you're using java, look into Comparator


it sounded to me like he was having issues with sorting because he had an array with nothing but ints (the mmr) and an other array with names and he needed them to be connected some how. I figured if you just did a tree you could have each node contain both sets of data.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jan 18 2013 10:59pm
Quote (Eep @ Jan 18 2013 11:45pm)
it sounded to me like he was having issues with sorting because he had an array with nothing but ints (the mmr) and an other array with names and he needed them to be connected some how. I figured if you just did a tree you could have each node contain both sets of data.


that's what i think his problem is too. and i still dont see why you want to use a binary tree. instead of a "node", just use a class and a normal array / arraylist and use a Comparator
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 19 2013 12:37am
Quote (carteblanche @ Jan 18 2013 11:59pm)
that's what i think his problem is too. and i still dont see why you want to use a binary tree. instead of a "node", just use a class and a normal array / arraylist and use a Comparator


well I am biased towards trees because they are one of the things I have worked with successfully in class.

I still don't know enough about arrays yet.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll