Yangbo's Blog!

Artificial Intelligence Board Game.

Bitboards

April8

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.
3 Comments to

“Bitboards”

  1. Avatar April 23rd, 2010 at 0:10 Аношкин Says:

    На Вашем месте я бы обратился за помощью в поисковики.


  2. Avatar April 23rd, 2010 at 8:08 РўРёРјСѓСЂ Says:

    Совершенно верно! Мне кажется это отличная идея. Я согласен с Вами.


  3. Avatar April 28th, 2010 at 20:06 admin Says:

    AS3 search engine is under construction.but there is some pieces of code.


Email will not be published

Website example

Your Comment:

 

BLOG CALENDAR

September 2010
M T W T F S S
« Apr    
 12345
6789101112
13141516171819
20212223242526
27282930