Let's play some boardgame!
Perl, 188 180 + 2 = 182 bytes
Wuhuu, got to use goto
.
@q=/.(?!$)/g,next if$w=$e=!@q;for(@F){a:$w+=$_;$_=$q[$w];/</?($_=-1,goto a):/X/?$e++:/#/?$w=0:!$_&&last;$e++}$r+=$"lt$r?-$w:$w;$t+=$"lt$t?-$e:$e-1}{say$w>@q?$t<0?B:A:!$r?0:$r<0?B:A
Requires -a
and -E
|-M5.010
:
$ echo $'>-<-<#<-<-<-<-$\n5 4 2\n1 1 1' | perl -M5.010 boardgame.pl
B
Somewhat ungolfed version:
#!/usr/bin/perl -a
# Read all but last char from the board into an array
@board = /.(?!$)/g,next if $pos = $turns = !@board;
for (@F) {
a:
$pos+=$_;
$_=$board[$pos];
/</?($_=-1,goto a):
/X/?$turns++:
/#/?$pos=0:
# End of Game (Victory!)
!$_&&last;
$turns++
}
# Make sure '$pos_diff' and '$turns_diff' are not zero by checking against [:space:]
# ' ' is less than 0 on the ascii table
$pos_diff += $"lt$pos_diff ? -$pos : $pos;
$turns_diff += $"lt$turns_diff ? -$turns : $turns-1;
}{
say $pos>@board?
$turns_diff<0?B
:A
:
!$pos_diff?0:
$pos_diff<0?B:
A