Line 346... |
Line 346... |
//FIFO_INTERFACE(queue,AIMove);
|
//FIFO_INTERFACE(queue,AIMove);
|
#pragma fifo_length pico_stream_input_queue 800
|
#pragma fifo_length pico_stream_input_queue 800
|
#pragma fifo_length pico_stream_output_queue 800
|
#pragma fifo_length pico_stream_output_queue 800
|
#pragma bandwidth pico_stream_input_queue 1
|
#pragma bandwidth pico_stream_input_queue 1
|
#pragma bandwidth pico_stream_output_queue 1
|
#pragma bandwidth pico_stream_output_queue 1
|
/*AIMoves*/int ai_threats(Board *board,AIMoves *moves,unsigned int *index)
|
/*AIMoves*/int ai_threats(Board board[5][16],int depth,int branch,AIMoves moves[5][16],index_array *index)
|
{
|
{
|
//#pragma read_write_ports board.data combined 2
|
//#pragma read_write_ports board.data combined 2
|
//#pragma internal_blockram board
|
//#pragma internal_blockram board
|
//#pragma no_memory_analysis board
|
//#pragma no_memory_analysis board
|
|
|
//#pragma internal_blockram move
|
//#pragma internal_blockram move
|
//#pragma no_memory_analysis move
|
//#pragma no_memory_analysis move
|
#pragma bitsize index 9
|
|
#pragma internal_fast index
|
#pragma internal_fast index
|
|
|
/////////* All threat functions work on this board */
|
/////////* All threat functions work on this board */
|
/*static*/ Board b;//={0,0,0,0,0,0,0,0,0,0,0,{{0}}} ;//= NULL;
|
/*static*/ Board b;//={0,0,0,0,0,0,0,0,0,0,0,{{0}}} ;//= NULL;
|
//#pragma read_write_ports b.data combined 2
|
//#pragma read_write_ports b.data combined 2
|
Line 374... |
Line 373... |
///*static*/ AIMoves moves;//={0,0,0,{{0,0,0}}};
|
///*static*/ AIMoves moves;//={0,0,0,{{0,0,0}}};
|
//#pragma read_write_ports moves.data combined 3
|
//#pragma read_write_ports moves.data combined 3
|
//#pragma internal_blockram moves
|
//#pragma internal_blockram moves
|
//#pragma no_memory_analysis moves
|
//#pragma no_memory_analysis moves
|
|
|
moves->len=0;
|
moves[depth][branch].len=0;
|
//AIMoves moves;
|
//AIMoves moves;
|
AIWEIGHT u_sum = 0;
|
AIWEIGHT u_sum = 0;
|
int i;
|
int i;
|
|
|
//b = board_new();
|
//b = board_new();
|
//Board b;
|
//Board b;
|
board_copy(board, &b);
|
board_copy(&board[depth][branch], &b);
|
|
|
/* Clear threat tallys */
|
/* Clear threat tallys */
|
//for (i = 0; i < connect_k; i++) {
|
//for (i = 0; i < connect_k; i++) {
|
// threat_counts.data[i][0] = 0;
|
// threat_counts.data[i][0] = 0;
|
// threat_counts.data[i][1] = 0;
|
// threat_counts.data[i][1] = 0;
|
Line 531... |
Line 530... |
AIMoves moves1;
|
AIMoves moves1;
|
moves1.len=0;
|
moves1.len=0;
|
#pragma internal_blockram moves1
|
#pragma internal_blockram moves1
|
/*moves = */ ai_marks(&bwrite, PIECE_THREAT(1),&moves1);
|
/*moves = */ ai_marks(&bwrite, PIECE_THREAT(1),&moves1);
|
//test(ready);
|
//test(ready);
|
streamsort(moves,index);
|
streamsort(&moves[depth][branch],index);
|
moves1.utility = u_sum;
|
moves1.utility = u_sum;
|
moves->utility = u_sum;
|
moves[depth][branch].utility = u_sum;
|
/*----------------------------
|
/*----------------------------
|
rewritten for hardware
|
rewritten for hardware
|
----------------------------*/
|
----------------------------*/
|
//if (!aimoves_choose(&moves1, move))
|
//if (!aimoves_choose(&moves1, move))
|
// return 0;
|
// return 0;
|
Line 685... |
Line 684... |
// }
|
// }
|
//
|
//
|
// }
|
// }
|
|
|
}
|
}
|
void streamsort(AIMoves *moves,unsigned int *index){
|
void streamsort(AIMoves *moves,index_array *index){
|
/* Insertion sort for streaming*/
|
/* Insertion sort for streaming*/
|
AIMove val;
|
AIMove val;
|
AIMove data[361]={{-1},{-1},{-1}};
|
AIMove data[361]={{-1},{-1},{-1}};
|
//unsigned int index[361];
|
//unsigned int index[361];
|
//#pragma bitsize index 9
|
//#pragma bitsize index 9
|
Line 735... |
Line 734... |
//index[j+1]=index[j];
|
//index[j+1]=index[j];
|
}
|
}
|
break;
|
break;
|
}
|
}
|
}
|
}
|
index[i]=len;
|
index->data[i]=len;
|
moves->data[i]=val;
|
moves->data[i]=val;
|
len++;
|
len++;
|
//cout<<"STREAMSORT"<<":";
|
//cout<<"STREAMSORT"<<":";
|
//}
|
//}
|
/*else*/ //{moves->len=len;break;}
|
/*else*/ //{moves->len=len;break;}
|
Line 801... |
Line 800... |
//#pragma no_memory_analysis moves
|
//#pragma no_memory_analysis moves
|
//#pragma read_write_ports moves.data combined 3
|
//#pragma read_write_ports moves.data combined 3
|
//#pragma internal_blockram moves
|
//#pragma internal_blockram moves
|
//#pragma no_memory_analysis moves
|
//#pragma no_memory_analysis moves
|
//AIMove move;
|
//AIMove move;
|
unsigned int index[1]={0};
|
index_array index={0};
|
//AIMoves *moves;
|
//AIMoves *moves;
|
moves.len=0;
|
moves.len=0;
|
/* Get all open tiles adjacent to any piece */
|
/* Get all open tiles adjacent to any piece */
|
/*moves =*/ enum_adjacent(b, 1,&moves,current_random);
|
/*moves =*/ enum_adjacent(b, 1,&moves,current_random);
|
if (moves.len){
|
if (moves.len){
|
aimoves_choose(&moves, move,&index[0]);
|
aimoves_choose(&moves, move,&index);
|
|
|
return ;//moves;
|
return ;//moves;
|
}
|
}
|
/* Play in the middle if there are no open adjacent tiles */
|
/* Play in the middle if there are no open adjacent tiles */
|
move->x = board_size / 2;
|
move->x = board_size / 2;
|