perl 的人气太差。罢了罢了。找本perl自己搞定

dust 2001-07-25 06:03:48
...全文
179 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
111222 2001-07-26
  • 打赏
  • 举报
回复
有tk游戏的演示么?我感兴趣!
isaxu 2001-07-26
  • 打赏
  • 举报
回复
对呀,人气差要我们共同来努力呀!
我是刚刚注册进来的,看到有perl一块地盘高兴的不得了
netken 2001-07-26
  • 打赏
  • 举报
回复
先放个扫雷,hoho

#!/usr/bin/perl
# NetKen.

use Tk;

$max = 15;#line number
$bomb = 20;#Bomb! number

$win = MainWindow->new( "-title"=>"Perl/Tk 扫雷!" );

startbutton();
label();

MainLoop();

sub startbutton {
$start_room = $win->Frame()->pack( '-side'=>'top' );
$start_button = $start_room->Button ( "-text"=>"START" , "-width"=>$max , "-height"=>1 , "-font"=>"-adobe-helvetica-bold-b-narrow--18-180-80-80-p-80-iso8859" , "-foreground"=>"red" , "-command"=>\&start )->pack ( "-side"=>"top" );
};

sub start {
$start_button->destroy();
format_array();
level();
};

sub restart {
for (my $i=0;$i<$max ;$i++)
{
my $n_i = "$i";$n_i = "0$i" if $i<10;
my $button_room_name = "button_room"."$i";
${$button_room_name}->destroy();
for (my $j=0;$j<$max ;$j++) {
my $n_j = "$j";$n_j = "0$j" if $j<10;
my $button_name = "button".$n_i.$n_j;
undef ${$button_name};
}
}

$start_button->configure ( "-text"=>"START" , "-command"=> \&start );
};

sub label {
$label = $win->Label ( "-text"=>"Kick Bomb! - START!" , "-width"=>($max-1)*2 , "-height"=>2 , "-font"=>"-adobe-verdana-bold-r-narrow--18-180-80-80-p-80-iso8859")->pack( "-side"=>"top" );
};

sub format_array {
undef @array;
for (my $k=0;$k<$bomb+1 ;$k++) {
srand(rand($max*100));
my $number = rand($max*100);
$number=int($number);
$number+=$max if $number<$max;
my $i = $number % $max;
my $j = int(( $number - $j ) / $max);
$array[$i][$j] = "0";
}
for (my $i=0;$i<$max ;$i++ ) {
for (my $j=0;$j<$max ;$j++ ) {
if ($array[$i][$j] eq "0") {
$array[$i-1][$j]++ if $i>0 and $array[$i-1][$j] ne "0";
$array[$i+1][$j]++ if $i<$max-1 and $array[$i+1][$j] ne "0";
$array[$i][$j-1]++ if $j>0 and $array[$i][$j-1] ne "0";
$array[$i][$j+1]++ if $j<$max-1 and $array[$i][$j+1] ne "0";
$array[$i-1][$j-1]++ if $i>0 and $j>0 and $array[$i-1][$j-1] ne "0";
$array[$i+1][$j+1]++ if $i<$max-1 and $j<$max-1 and $array[$i+1][$j+1] ne "0";
$array[$i-1][$j+1]++ if $i>0 and $j<$max-1 and $array[$i-1][$j+1] ne "0";
$array[$i+1][$j-1]++ if $i<$max-1 and $j>0 and $array[$i+1][$j-1] ne "0";
}
}
}
};

sub level {
for (my $i=0;$i<$max ;$i++)
{
my $n_i = "$i";$n_i = "0$i" if $i<10;
my $button_room_name = "button_room"."$i";
$eval .= '$'."$button_room_name".'=$win->Frame()->pack("-side"=>"top");';
for (my $j=0;$j<$max ;$j++) {
my $n_j = "$j";$n_j = "0$j" if $j<10;
my $button_name = "button".$n_i.$n_j;
$eval .= '$'."$button_name".'=$'."$button_room_name".'->Button("-text"=>"?","-width"=>1,"-height"=>1,"-command"=>[\&change_button,'."$i,$j".'])->pack("-side"=>"left");';
}
}
eval $eval;
undef $eval;
};

# 如果为 null ,则 flat ,如果有数字 则 ridge
sub change_button {
my $i = shift;
my $j = shift;
my $n_i = "$i";$n_i = "0$i" if $i<10;
my $n_j = "$j";$n_j = "0$j" if $j<10;
if ($array[$i][$j] eq "0") {
gameover();
} else {
unless ($array[$i][$j]) {
disp_blank($i,$j);
} else {
${"button".$n_i.$n_j}->configure ( "-text"=>"$array[$i][$j]" , "-relief"=>"ridge" );
}
}
};

sub disp_blank {
my $i = shift;
my $j = shift;

my $m_i = "$i";$m_i = "0$i" if $i<10;
my $m_j = "$j";$m_j = "0$j" if $j<10;

${"button".$m_i.$m_j}->configure ( "-text"=>"$array[$i][$j]" , "-relief"=>"flat" );

if ($i>0 and $array[$i-1][$j] eq "" ) {
my $num_i = $i-1;
my $n_i = "$num_i";$n_i = "0$num_i" if $num_i<10;
my $n_j = "$j";$n_j = "0$j" if $j<10;
my $state = ${"button".$n_i.$n_j}->cget ( "-relief" );
disp_blank($i-1,$j) unless $state eq "flat";
}
if ( $j>0 and $array[$i][$j-1] eq "" ) {
my $num_j = $j-1;
my $n_i = "$i";$n_i = "0$i" if $i<10;
my $n_j = "$num_j";$n_j = "0$num_j" if $num_j<10;
my $state = ${"button".$n_i.$n_j}->cget ( "-relief" );
disp_blank($i,$j-1) unless $state eq "flat";
}
if ( $i<$max-1 and $array[$i+1][$j] eq "" ) {
my $num_i = $i+1;
my $n_i = "$num_i";$n_i = "0$num_i" if $num_i<10;
my $n_j = "$j";$n_j = "0$j" if $j<10;
my $state = ${"button".$n_i.$n_j}->cget ( "-relief" );
disp_blank($i+1,$j) unless $state eq "flat";
}
if ( $j<$max-1 and $array[$i][$j+1] eq "" ) {
my $num_j = $j+1;
my $n_i = "$i";$n_i = "0$i" if $i<10;
my $n_j = "$num_j";$n_j = "0$num_j" if $num_j<10;
my $state = ${"button".$n_i.$n_j}->cget ( "-relief" );
disp_blank($i,$j+1) unless $state eq "flat";
}


};

sub gameover {
for (my $i=0;$i<$max ;$i++ ) {
for (my $j=0;$j<$max ;$j++ ) {
my $n_i = "$i";$n_i = "0$i" if $i<10;
my $n_j = "$j";$n_j = "0$j" if $j<10;
${"button".$n_i.$n_j}->configure ( "-text"=>"X" , "-foreground"=>"red" , "-background"=>"black" ) if $array[$i][$j] eq "0";
}
}
$start_button = $start_room->Button ( "-text"=>"RESTART" , "-width"=>$max , "-height"=>1 , "-font"=>"-adobe-helvetica-bold-b-narrow--18-180-80-80-p-80-iso8859" , "-foreground"=>"red" , "-command"=>\&restart )->pack ( "-side"=>"top" );
$label->configure ( "-text"=>"Bomb... Oh~ u r FAILED!" );
};
netken 2001-07-25
  • 打赏
  • 举报
回复
最好的办法就是看man,hoho
也可以看看learning tk,我这里有几个自己用perl tk写的小游戏,若赶兴趣的话
我可以贴上来
iamxxg 2001-07-25
  • 打赏
  • 举报
回复
是呀,谁讲讲TK呀,我想知道
netken 2001-07-25
  • 打赏
  • 举报
回复
既然我们都在perl版里,为什么不想想怎样提高这里的人气?
不要总是把perl局限在一个cgi的小圈子中啊,
要知道perl的功能强大的很
(以上不针对任何人)
milson 2001-07-25
  • 打赏
  • 举报
回复
要是有这样一本好书,我也不来这里了。
阿鹏兄 2001-07-25
  • 打赏
  • 举报
回复
是呀。
内容概要:本文围绕基于Basisformer模型的时间序列锂离子电池SOC(State of Charge,荷电状态)预测展开研究,利用PyTorch框架实现深度学习模型的构建与训练。通过将历史充放电数据作为输入,Basisformer能够有效捕捉电池状态的动态变化特征,提升SOC预测精度。文中详细介绍了模型结构设计、数据预处理流程、训练策略及实验结果分析,并与传统方法进行对比,验证了该方法在复杂工况下的优越性与鲁棒性。该研究不仅展示了Basisformer在时序建模中的潜力,也为电池管理系统提供了高精度的状态估计解决方案。; 适合人群:具备一定Python编程基础和深度学习理论知识,熟悉PyTorch框架,从事电池管理系统、新能源汽车或智能预测方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于电动汽车、储能系统等领域的电池SOC高精度实时估算;②为电池健康管理(BMS)提供可靠的状态输入;③推动深度学习在时间序列预测中的实际落地,提升现有预测模型的泛化能力与稳定性; 阅读建议:建议读者结合标题为【锂电池SOC估计】【PyTorch】基于Basisformer时间序列锂离子电池SOC预测研究(python代码实现)的资源,重点研读所提供的Python代码,深入理解数据处理方式与模型网络结构的设计思路,尝试调整超参数以观察对预测性能的影响,从而全面掌握Basisformer在时序建模中的优势、适用边界及工程化实现路径。

2,203

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 CGI
社区管理员
  • CGI社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧