Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^2: Team Player Timeline

by aartist (Monk)
on Jun 21, 2015 at 00:12 UTC ( #1131309=note: print w/replies, xml ) Need Help??

in reply to Re: Team Player Timeline
in thread Team Player Timeline

Thanks. I am looking for particular algorithm or mechanism to solve this type of problem in general.

Replies are listed 'Best First'.
Re^3: Team Player Timeline
by aaron_baugher (Curate) on Jun 21, 2015 at 00:44 UTC

    I doubt there's "an algorithm" for what you want to do. At least nothing more specific than, "Get the data you want into a structure and display it." In the first place, it'll depend on how the data is stored: by game, by player, some other way?

    To visualize the timelines of the players focused on a particular game, my first thought is something like a candlestick graph that extends above and below a line representing the current game, where you can see how many games before and after this one a player was in. But whether that's a good choice would depend on how often players change. If players often play a single game and leave again, that'd be a pretty useless graph.

    Aaron B.
    Available for small or large Perl jobs and *nix system administration; see my home node.

      Thanks. That is a very useful direction. I am looking for some sort of flow with game number (on X axis) and Players on Y axis such that I can see a subset of N players played in window W of total games G ( For example: Games in current Year). I am developing more ideas.

        Okay, if a 2-D chart of games to players will work, see what you think of this. The subroutine will handle any number of players, games, and players/game, as long as there are always the same number of players like you mentioned, and it displays a simple ASCII chart of a window between two numbered games. There's no error checking, and the formatting could get messed up with long names, but I think it does the basics.

        #!/usr/bin/env perl use 5.010; use warnings; use strict; use List::Util qw(max first); my @players = qw( Adam Bob Clay Dan Ed Frank George ); my @games = ( [1,2,3,4], [2,3,4,5], [2,4,5,6], [2,4,6,7], [2,4,6,7], [3,4,6,7], [1,3,4,7] ); chart( \@players, \@games, 2, 4 ); # print a chart from game 2 to 4 chart( \@players, \@games, 1, 7 ); # print a chart of all 7 games sub chart { my $players = shift; # players array my $games = shift; # games array my $start = shift; # start game my $end = shift; # end game my $pl = max map { length $_ } @$players; say '-' x 40; for my $p ( 1..@$players ){ printf "%-${pl}s | ", $players->[$p-1]; for( $start..$end ){ print is_in($p,$games->[$_-1]) ? 'X ' : ' '; } say ''; } say '-' x 40; printf "%-${pl}s | ", ' '; print "$_ " for $start..$end; say ''; } sub is_in { return first { $_ == $_[0] } @{$_[1]}; }

        Aaron B.
        Available for small or large Perl jobs and *nix system administration; see my home node.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1131309]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-10-22 22:30 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (122 votes). Check out past polls.