mIRC Home    About    Download    Register    News    Help

Print Thread
#186118 17/09/07 07:20 PM
Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
I'm in the process of making a 'favoritizer' script. Basically I want it to give me choices between 2 items (of a list I entered) and make a list based on those choices. Right now I got something fairly simple, which just replaces items if a lower ranked item is valued higher than a higher ranked item. Anyway, this is it:

;;;;; Variables ;;;;
Alias -l Nickname { return AMBot }
Alias -l ServerAndPort { return irc.utonet.org:6667 }
Alias -l Channel { return #AM }

On *:start:.nick $nickname | .server $serverandport -j $channel
On *:text:*:?:{
if ($1 == !File) && ($2) {
if (!$isfile($2)) { msg $nick File ' $+ $2 ' does not exist | halt }
Set %file. [ $+ [ $nick ] ] $2
msg $nick Loaded ' $+ $2 '. To start, please type !start
}
if ($1 == !start) {
kk $nick
}
if ($1 == !1) {
if (!%file. [ $+ [ $nick ] ]) { msg $nick You did not select a file | halt }
var %file = %file. [ $+ [ $nick ] ] , %1 = %tmp.1. [ $+ [ $nick ] ] , %2 = %tmp.2. [ $+ [ $nick ] ]
if (%2 < %1) { var %z1 = $read(%file,%1) , %z2 = $read(%file,%2) | write -l [ $+ [ %2 ] ] %file %z1 | write -l [ $+ [ %1 ] ] %file %z2 }
kk $nick
}

if ($1 == !2) {
if (!%file. [ $+ [ $nick ] ]) { msg $nick You did not select a file | halt }
var %file = %file. [ $+ [ $nick ] ] , %1 = %tmp.1. [ $+ [ $nick ] ] , %2 = %tmp.2. [ $+ [ $nick ] ]
if (%2 > %1) { var %z1 = $read(%file,%1) , %z2 = $read(%file,%2) | write -l [ $+ [ %2 ] ] %file %z1 | write -l [ $+ [ %1 ] ] %file %z2 }
kk $nick
}

}
alias kk {
var %z = %file. [ $+ [ $1 ] ]
:s
var %i = $r(1,$lines(%z))
var %ii = $r(1,$lines(%z))
if (%i == %ii) { goto s }
set %tmp.1. [ $+ [ $1 ] ] %i
set %tmp.2. [ $+ [ $1 ] ] %ii
msg $1 12!1 : $read(%z,%i) 14( $+ %i $+ ) • 6!2 : $read(%z,%ii) 14( $+ %ii $+ )
}

Now, that does work flawless, but it's very time consuming. Say a list has 100 items, the chance of it bringing up say item 13 and 14 will be very small. So I could choose for hours and hours and still not get a perfect ranking.

I'm trying to think of ideas to fix this, possibly have the script remember relations, so if I rank 14 over 7, but I've previously ranked 9 over 14, it'll place item 14 at 10 rather than 7. I hope that makes any sense.

I've come up with squat, my scripting is not advanced enough to do things like that, so I turn here for help. Any kind of advice works, even a whole different script would work, perhaps even an existing one. Hell, if you have an html, php or javascript.. I'd happily take it.

Thank in advance.

Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Interesting! Looks like a human bubble sort routine with which you push the highest ranked item to the end of the file. For my understanding, is this a ranking system for music songs or favorite holiday destinations? Well, never mind, your problem is that you pick two items randomly. Is there any reason for? If not you should do as follows (suppose you have 10 items):
- present items 1 and 2, ask for ranking and switch them if necessary
- then present items 2 and 3 and ask again (and switch again)
- then present items 3 and 4 and ask again (and switch again)
- and so on until you have presented (and maybe switched) items 9 and 10
Now, the highest ranked item is at place 10. So in the next ranking round do the same as stated above, BUT stop at presenting item 8 and 9 since item 10 already is ranked correctly. In the next round you stop at 7+8, then at 6+7, until you only have to present items 1 and 2. Good luck!

Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
You're right, it's made for ranking songs or albums. I have in fact thought of your solution, but with over a hundred songs it would also become very tedious. I'm looking for something a little more sophisticated.

Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Ehm .. I don't want to offend you, but random picking is not sophisticated at all :s Bubble sorting is quite efficient. The number of compares is approximately equal to 0,5.n.n (5000 compares for 100 items). The most efficient method takes about n.ln(n) compares (almost 500 compares for 100 items), but I don't know how to script that. Maybe Google knows?

Edit: hmz .. the method I suggested is indeed very tedious. Maybe you should pick the first song to be presented at random and always the next song as the second one. Ehm .. suppose you pick item 48 first then this should be presented together with 49. I hope you understand ...

Last edited by noMen; 17/09/07 08:31 PM.
Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
I didn't mean to offend you either, I know my method is very tedious as well, which is why I'm looking for an alternative.

Your second solution is also something I thought of, sorry for not including that in the topic, but I'm not sure how to make this and it's still a little tedious in my opinion.

Basically, a very smart script should be able to compile a list once every song has been compared to another one once, I think. If relations are taken into account, and everything is compared.. if not once, then it should at least work in 2 or 3 times. But I have no idea how to write such a script, or if it's even possible.

Edit: I've tried googling, but I couldn't get anything, so I wrote something in the only scripting language I know..

Last edited by Noeptolemos; 17/09/07 09:26 PM.
Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Originally Posted By: Noeptolemos
Basically, a very smart script should be able to compile a list once every song has been compared to another one once, I think. If relations are taken into account, and everything is compared.. if not once, then it should at least work in 2 or 3 times.


This can be scripted easily, but "has been compared to another one" is a very rough method. Or, if you meant "has been compared to each one" this would even be more tedious.

It must be possible to script a less tedious comparing mechanism, but that will not give you the perfect ranking. If I get an idea I will let you know.

Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Lol, I think I got an acceptable method. It is like the bubble sort method I explained before, but this time you should "divide" your file into groups of 10 songs, pick a random song from the first group, have it compared with a random song from the second group (and switched), then take a random song from the second group and have it compared with a random song of the third group, etc. After nine compares (with 100 songs), you start over again with group 1 and 2. You should also remember for each nick and file which groups he compared the last time he was online. After a few rounds you will have a rough ranking order. Maybe 10 round (=90 compares) should give you an acceptable order.

Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
Originally Posted By: noMen
Lol, I think I got an acceptable method. It is like the bubble sort method I explained before, but this time you should "divide" your file into groups of 10 songs, pick a random song from the first group, have it compared with a random song from the second group (and switched), then take a random song from the second group and have it compared with a random song of the third group, etc. After nine compares (with 100 songs), you start over again with group 1 and 2. You should also remember for each nick and file which groups he compared the last time he was online. After a few rounds you will have a rough ranking order. Maybe 10 round (=90 compares) should give you an acceptable order.


I would indeed have a rough ranking order, but the groups of 10 would still have no particular order, so I'd need to run another script of your first idea to get those into the right order. All in all, still quite a lot of work when you have a lot of songs. Still, that's the best idea so far. smile

Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Originally Posted By: Noeptolemos

, but the groups of 10 would still have no particular order,

I don't agree with you since items will be transferred from one group to another.

Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
Originally Posted By: noMen
Originally Posted By: Noeptolemos

, but the groups of 10 would still have no particular order,

I don't agree with you since items will be transferred from one group to another.


Yes, but after you've had a few rounds, every item will be in the right group but the groups won't be ordered properly because they aren't compared to each other.

Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
Please Noeptolemos, make a choice: have the perfect ranking and a tedious job, òr have a global ranking in short time .... cool

Last edited by noMen; 18/09/07 09:48 AM.
Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
I know.. but I don't want to make the choice, I want a script that does both! grin

Last edited by Noeptolemos; 18/09/07 10:39 AM.
Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
Bump! I implemented some new stuff with advice from NoMen but I'm still looking for a better solution.

Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
There is another way Noeptolemos ... you could record the previous and the next ranked song with each song. Let's say songs 3, 9, 4 and 5 were ranked in that order, you will have something like this:
0 - 3 - 9
3 - 9 - 4
9 - 4 - 5
4 - 5 - 999999
When somebody places song 4 above 9, you should change the links as follows:

0 - 3 - 4
3 - 4 - 9
4 - 9 - 4
4 - 5 - 999999

Nice job to script smile

Joined: Dec 2005
Posts: 23
N
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Dec 2005
Posts: 23
Any idea how to do that though? :P

Joined: Jan 2006
Posts: 111
N
Vogon poet
Offline
Vogon poet
N
Joined: Jan 2006
Posts: 111
ehm ... I gave the wrong example and it won't work anyhow ... I'll think about it again


Link Copied to Clipboard