Bitboards
AS3 BitBoard(based-on BitVector) preview:
This is our ChineseChess as3 bitboard:
[R][K][B][O][M][O][B][K][R]
[0][0][0][0][0][0][0][0][0]
[0][C][0][0][0][0][0][C][0]
[P][0][P][0][P][0][P][0][P]
[0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0]
[p][0][p][0][p][0][p][0][p]
[0][C][0][0][0][0][0][C][0]
[0][0][0][0][0][0][0][0][0]
[r][k][b][o][m][o][b][k][r]
Operations:
and
public function and(value:BitBoard):BitBoard
{
var bb:BitBoard =
new BitBoard(this.column,this.row);
for(var h:int=0;h<_row;h++)
{
for(var w:int=0;w<_column;w++)
{
bb.setBitt(h,w,
Boolean((value.getBitt(h,w)&this.getBitt(h,w))));
}
}
return bb;
}
xor
public function xor(value:BitBoard):BitBoard
{
var bb:BitBoard =
new BitBoard(this.column,this.row);
for(var h:int=0;h<_row;h++)
{
for(var w:int=0;w<_column;w++)
{
bb.setBitt(h,w,
Boolean((value.getBitt(h,w)^this.getBitt(h,w))));
}
}
return bb;
}
or
public function or(value:BitBoard):BitBoard
{
var bb:BitBoard =
new BitBoard(this.column,this.row);
for(var h:int=0;h<_row;h++)
{
for(var w:int=0;w<_column;w++)
{
bb.setBitt(h,w,
Boolean((value.getBitt(h,w)|this.getBitt(h,w))));
}
}
return bb;
}
not
public function not():BitBoard
{
var bb:BitBoard =
new BitBoard(this.column,this.row);
for(var h:int=0;h<_row;h++)
{
for(var w:int=0;w<_column;w++)
{
bb.setBitt(h,w,
!Boolean(this.getBitt(h,w)));
}
}
return bb;
}
rotate
public function rotate90():BitBoard
{
var bb:BitBoard =
new BitBoard(_row,_column);
for(var w:int=0;w<_row;w++)
{
for(var h:int=0;h<_column;h++)
{
bb.setBitt(h,w,
Boolean(this.getBitt(w,h)));
}
}
return bb;
}
reverse
public function reverse():BitBoard
{
var bb:BitBoard =
new BitBoard(this.column,this.row);
for(var w:int=0;w<_column;w++)
{
for(var h:int=0;h<_row;h++)
{
bb.setBitt(h,w,
Boolean(this.getBitt(_row-h-1,w)));
}
}
return bb;
}
This page is wiki editable click here to edit this page.
На Вашем месте я бы обратился за помощью в поисковики.
Совершенно верно! Мне кажется это отличная идея. Я согласен с Вами.
AS3 search engine is under construction.but there is some pieces of code.