return $self;
}
+sub trace_shoot
+{
+ my $self=shift;
+ my ($property)=@_;
+ push @{$self->{trace_shoot}},$property;
+}
sub get_color
{
$self->{current_player}=0;
$self->{player_count}=@{$self->{player}};
$self->{active_player_count}=$self->{player_count};
+ $self->{trace_shoot_data}={};
$self->callback('init');
}
{
$self->{current_shoot}={mult=>$mult,number=>$number};
$self->{current_shoot_count}++;
- return $self->callback('shoot',$mult,$number);
+ my $result = $self->callback('shoot',$mult,$number);
+ for my $trace_prop ( @{$self->{trace_shoot}})
+ {
+ push @{$self->{trace_shoot_data}{$self->{current_player}}},$self->get_current_player()->{$trace_prop};
+ }
+ return $result;
} else {
return 0;
}
}
+sub plot_trace_shoot
+{
+ my $self=shift;
+ my $datastr;
+ for my $player_num (keys %{$self->{trace_shoot_data}})
+ {
+ $datastr.=$self->get_player($player_num)->{name}.':';
+ $datastr.= join ',',@{$self->{trace_shoot_data}{$player_num}};
+ $datastr.="\n";
+ }
+ chomp $datastr;
+ my $plotter;
+ open($plotter,"|./plot.py") or return;
+ print $plotter $datastr;
+ close $plotter;
+}
+
sub shout_last_shoot
{
my $self=shift;
next_player=>\&next_player,
before_shoot=>\&print_score,
init=>\&init,
+ end_game=>\&Dart::plot_trace_shoot,
}
);
+$dart->trace_shoot('score');
exit $dart->run();
### ===============================
sub init
{
my $self=shift;
-
for my $player_idx (0..($self->{player_count}-1))
{
$self->get_player($player_idx)->{score} = $maxScore;
--- /dev/null
+#!/usr/bin/env python
+
+import fileinput
+import numpy
+import pylab
+labels=[];
+for line in fileinput.input():
+ (label,foo,datastr)=line.partition(":")
+ labels.append(label)
+ data = numpy.array(datastr.split(","))
+ pylab.plot(range(len(data)),data,label=label)
+ pylab.hold(True)
+
+pylab.legend()
+pylab.show()
+
stty -echo
ssh dart killall ttyread 2>&1
ssh dart ttyread /dev/ttyDart >$FIFO &
+cd $MYPATH
$MYPATH/eet $FIFO | perl -I $MYPATH $MYPATH/dart-$mode.pl $* | $MYPATH/../dart-sounds/src/dart-sounds $MYPATH/../dart-sounds/media > /dev/null
rm -rf $FIFO_D