This is not a tutorial in editing perl scripts. You should know what you are doing.
Find this code:
- Code: Select all
my %styles=(
12 => \&top_style12,
);
and edit it to look like this:
- Code: Select all
my %styles=(
12 => \&top_style12,
99 => \&top_style99,
);
Find subroutine top_style12
- Code: Select all
sub top_style12 {
# I know this subroutine is messy. Real chessd server code is a little
# less "blech," but it doesn't have to worry about converting Yahoo!
# peculiarities to something usable by ICS interfaces.
my $table=shift;
my $board=$table->[7];
my @bd=$board->style12;pop @bd;
(@bd == 8) or return -1;
my %opts=%{$table->[1]};
my($time,$inc)=($opts{'tt'}/60000,$opts{'it'}/1000);
my $wtime=int(&top_timeleft($table,0)/1000);
my $btime=int(&top_timeleft($table,1)/1000);
my %bo=%{$board};
my $moves=int(@{$bo{'moves'}}/2)+1;
my($white,$black)=map {$_->[0] || '_EMPTY_'} @{$table}[3,4];
my $relation=0;
$white=~s/[^a-z0-9_]/_/gi;
$black=~s/[^a-z0-9_]/_/gi;
if ($white eq '_EMPTY_' or $black eq '_EMPTY_') {
$relation=-3;
} if ($table->[3]==$pme or $table->[4]==$pme) {
my $iamblack=($table->[4]==$pme);
if ($bo{'turn'}==$iamblack) {
$relation=1;
} else {
$relation=-1;
}
}
# Separate variable is useful for debugging style12 problems.
my $s12=sprintf("\n<12> ".
#bd tn ep wcswclbcsbcldr # wn bn rl timincwm bm wt bt mv vc mt ds fp
"%s %s %d %d %d %d %d %d %d %s %s %d %d %d %d %d %d %d %d %s %s %s 0\n",
join(' ',@bd), # position
qw(W B)[$bo{'turn'}], # turn (W/B)
@bo{'dpush', # en passant file
'castlewh','castlewa', # white can castle short/long
'castlebh','castleba'}, # black can castle short/long
0, # last reversible move (in half-moves) TODO
$table->[0], # game number
$white, # white's name
$black, # black's name
$relation, # my relation to the game
$time, # initial time
$inc, # increment
$board->strength, # white and black's strength
$wtime, # white's clock
$btime, # black's clock
$moves, # move number (not half-move)
$bo{'desc'}, # verbose coordinate notation of last move FIXME
'0:00', # time to make last move TODO
$bo{'algebraic'}, # descriptive notation of last move TODO
);
print $s12; # Not iprint - we don't want this to wrap!
prompt;
return 0;
}
Leave this subroutine alone but right under it, insert this new subroutine:
- Code: Select all
sub top_style99 { #Testing something ... like instant moves
# I know this subroutine is messy. Real chessd server code is a little
# less "blech," but it doesn't have to worry about converting Yahoo!
# peculiarities to something usable by ICS interfaces.
my $table=shift;
my $board=$table->[7];
my @bd=$board->style12;pop @bd;
(@bd == 8) or return -1;
my %opts=%{$table->[1]};
my($time,$inc)=($opts{'tt'}/60000,$opts{'it'}/1000);
my $wtime=0;
my $btime=int(&top_timeleft($table,1)/1000);
my %bo=%{$board};
my $moves=int(@{$bo{'moves'}}/2)+1;
my($white,$black)=map {$_->[0] || '_EMPTY_'} @{$table}[3,4];
my $relation=0;
$white=~s/[^a-z0-9_]/_/gi;
$black=~s/[^a-z0-9_]/_/gi;
if ($table->[3]==$pme or $table->[4]==$pme) {
my $iamblack=($table->[4]==$pme);
if ($bo{'turn'}==$iamblack) {
$relation=1;
} else {
$relation=-1;
}
} elsif ($white eq '_EMPTY_' or $black eq '_EMPTY_') {
$relation=-3;
}
# Separate variable is useful for debugging style12 problems.
my $s12=sprintf("\n<12> ".
#bd tn ep wcswclbcsbcldr # wn bn rl timincwm bm wt bt mv vc mt ds fp
"%s %s %d %d %d %d %d %d %d %s %s %d %d %d %d %d %d %d %d %s %s %s 0\n",
join(' ',@bd), # position
qw(W B)[$bo{'turn'}], # turn (W/B)
@bo{'dpush', # en passant file
'castlewh','castlewa', # white can castle short/long
'castlebh','castleba'}, # black can castle short/long
0, # last reversible move (in half-moves) TODO
$table->[0], # game number
$white, # white's name
$black, # black's name
$relation, # my relation to the game
$time, # initial time
$inc, # increment
$board->strength, # white and black's strength
$wtime, # white's clock
$btime, # black's clock
$moves, # move number (not half-move)
$bo{'desc'}, # verbose coordinate notation of last move FIXME
'0:00', # time to make last move TODO
$bo{'algebraic'}, # descriptive notation of last move TODO
);
print $s12; # Not iprint - we don't want this to wrap!
prompt;
return 0;
}
Now that section of the script should look like this:
- Code: Select all
sub top_style12 {
# I know this subroutine is messy. Real chessd server code is a little
# less "blech," but it doesn't have to worry about converting Yahoo!
# peculiarities to something usable by ICS interfaces.
my $table=shift;
my $board=$table->[7];
my @bd=$board->style12;pop @bd;
(@bd == 8) or return -1;
my %opts=%{$table->[1]};
my($time,$inc)=($opts{'tt'}/60000,$opts{'it'}/1000);
my $wtime=int(&top_timeleft($table,0)/1000);
my $btime=int(&top_timeleft($table,1)/1000);
my %bo=%{$board};
my $moves=int(@{$bo{'moves'}}/2)+1;
my($white,$black)=map {$_->[0] || '_EMPTY_'} @{$table}[3,4];
my $relation=0;
$white=~s/[^a-z0-9_]/_/gi;
$black=~s/[^a-z0-9_]/_/gi;
if ($white eq '_EMPTY_' or $black eq '_EMPTY_') {
$relation=-3;
} if ($table->[3]==$pme or $table->[4]==$pme) {
my $iamblack=($table->[4]==$pme);
if ($bo{'turn'}==$iamblack) {
$relation=1;
} else {
$relation=-1;
}
}
# Separate variable is useful for debugging style12 problems.
my $s12=sprintf("\n<12> ".
#bd tn ep wcswclbcsbcldr # wn bn rl timincwm bm wt bt mv vc mt ds fp
"%s %s %d %d %d %d %d %d %d %s %s %d %d %d %d %d %d %d %d %s %s %s 0\n",
join(' ',@bd), # position
qw(W B)[$bo{'turn'}], # turn (W/B)
@bo{'dpush', # en passant file
'castlewh','castlewa', # white can castle short/long
'castlebh','castleba'}, # black can castle short/long
0, # last reversible move (in half-moves) TODO
$table->[0], # game number
$white, # white's name
$black, # black's name
$relation, # my relation to the game
$time, # initial time
$inc, # increment
$board->strength, # white and black's strength
$wtime, # white's clock
$btime, # black's clock
$moves, # move number (not half-move)
$bo{'desc'}, # verbose coordinate notation of last move FIXME
'0:00', # time to make last move TODO
$bo{'algebraic'}, # descriptive notation of last move TODO
);
print $s12; # Not iprint - we don't want this to wrap!
prompt;
return 0;
}
sub top_style99 { #Testing something ... like instant moves
# I know this subroutine is messy. Real chessd server code is a little
# less "blech," but it doesn't have to worry about converting Yahoo!
# peculiarities to something usable by ICS interfaces.
my $table=shift;
my $board=$table->[7];
my @bd=$board->style12;pop @bd;
(@bd == 8) or return -1;
my %opts=%{$table->[1]};
my($time,$inc)=($opts{'tt'}/60000,$opts{'it'}/1000);
my $wtime=0;
my $btime=int(&top_timeleft($table,1)/1000);
my %bo=%{$board};
my $moves=int(@{$bo{'moves'}}/2)+1;
my($white,$black)=map {$_->[0] || '_EMPTY_'} @{$table}[3,4];
my $relation=0;
$white=~s/[^a-z0-9_]/_/gi;
$black=~s/[^a-z0-9_]/_/gi;
if ($table->[3]==$pme or $table->[4]==$pme) {
my $iamblack=($table->[4]==$pme);
if ($bo{'turn'}==$iamblack) {
$relation=1;
} else {
$relation=-1;
}
} elsif ($white eq '_EMPTY_' or $black eq '_EMPTY_') {
$relation=-3;
}
# Separate variable is useful for debugging style12 problems.
my $s12=sprintf("\n<12> ".
#bd tn ep wcswclbcsbcldr # wn bn rl timincwm bm wt bt mv vc mt ds fp
"%s %s %d %d %d %d %d %d %d %s %s %d %d %d %d %d %d %d %d %s %s %s 0\n",
join(' ',@bd), # position
qw(W B)[$bo{'turn'}], # turn (W/B)
@bo{'dpush', # en passant file
'castlewh','castlewa', # white can castle short/long
'castlebh','castleba'}, # black can castle short/long
0, # last reversible move (in half-moves) TODO
$table->[0], # game number
$white, # white's name
$black, # black's name
$relation, # my relation to the game
$time, # initial time
$inc, # increment
$board->strength, # white and black's strength
$wtime, # white's clock
$btime, # black's clock
$moves, # move number (not half-move)
$bo{'desc'}, # verbose coordinate notation of last move FIXME
'0:00', # time to make last move TODO
$bo{'algebraic'}, # descriptive notation of last move TODO
);
print $s12; # Not iprint - we don't want this to wrap!
prompt;
return 0;
}
I made a very little modification to this subroutine just to compensate for a change I made in one of the support modules. I also noted that apparently style12 is only for whites player, so remember that.
Thanks to zappa_engine for the code.
Cheers,









News