URL
https://opencores.org/ocsvn/connect-6/connect-6/trunk
Subversion Repositories connect-6
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 11 to Rev 12
- ↔ Reverse comparison
Rev 11 → Rev 12
/connect-6/trunk/BUILD_SCC/scc_scripts/run_imp_search.tcl
0,0 → 1,52
set SYNTH_SRC "synth_src" |
set_project_params -directory ./ |
set_project_params -results myboard.txt |
set_project_params -sources "${SYNTH_SRC}/connect6.cpp ${SYNTH_SRC}/connect6_synth.cpp ${SYNTH_SRC}/main.cpp ${SYNTH_SRC}/q.cpp ${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/util.cpp ${SYNTH_SRC}/search_bfs.cpp" |
set_project_params -headers "${SYNTH_SRC}/connect6.h ${SYNTH_SRC}/connect6_synth.h ${SYNTH_SRC}/q.hpp ${SYNTH_SRC}/shared.h ${SYNTH_SRC}/threats.h ${SYNTH_SRC}/util.h" |
|
if [file exists imp_search] { delete_implementation imp_search } |
create_implementation imp_search |
|
set_implementation_params -systemc_source no |
set_implementation_params -memory_return_path_external_delay 0% |
set_implementation_params -memory_forward_path_external_delay 0% |
set_implementation_params -instream_forward_path_external_delay 0% |
set_implementation_params -import_tcab "imp_threat" |
set_implementation_params -sccompiler_args "-DDONT_VERIFY_PPAID" |
set_implementation_params -outstream_return_path_external_delay 0% |
set_implementation_params -appfiles "${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/search_bfs.cpp " |
set_implementation_params -proc df_search |
set_implementation_params -memory_forward_boundary_register infer |
set_implementation_params -cppcompiler_args "-g -DPICO_SYNTH -fpermissive" |
set_implementation_params -techlib altera-cyclone3 |
set_implementation_params -device ep3c25-ea144-7 |
set_implementation_params -memory_return_boundary_register infer |
set_implementation_params -cexec_args "-port /dev/ttyS0 -player L" |
set_implementation_params -host_memory_access never,,, |
set_implementation_params -init_data_registers yes |
set_implementation_params -outstream_forward_path_external_delay 0% |
set_implementation_params -build_tcab yes |
set_implementation_params -reset_data_registers yes |
set_implementation_params -instream_return_path_external_delay 0% |
set_implementation_params -clock_freq 50 |
set_implementation_params -allow_latency_violation no |
set_implementation_params -tcab_deployment conditional_outputs:yes |
#setvar preprocess_auxopts "-Xmax_loops_for_jamming=15" |
#set_implementation_params -user_supplied_fpga_memory_read_write_ports separate |
#set_implementation_params -internal_blockram_memory_read_write_ports separate |
|
|
|
setvar schedule_auxopts "-j" |
|
csim -golden -cexec_args "-port /dev/ttyS0 -player L" |
preprocess |
csim -preprocess -cexec_args "-port /dev/ttyS0 -player L" |
schedule |
csim -schedule -cexec_args "-port /dev/ttyS0 -player L" |
synthesize |
#csim -synthesize -dump_memory_access_trace -sim_after_synth_phase 5 |
create_rtl_package |
#vlogsim -online -detailed_perf_report |
#set_implementation_params -simulator modelsim |
#vlogsim -offline -dotasks 1-30 |
/connect-6/trunk/BUILD_SCC/scc_scripts/run_imp_line.tcl
1,6 → 1,6
set_project_params -directory ./ |
set_project_params -results myboard.txt |
set_project_params -sources "synth_src/connect6.cpp synth_src/connect6_synth.cpp synth_src/main.cpp synth_src/q.cpp synth_src/state.cpp synth_src/threats.cpp synth_src/util.cpp" |
set_project_params -sources "synth_src/connect6.cpp synth_src/connect6_synth.cpp synth_src/main.cpp synth_src/q.cpp synth_src/state.cpp synth_src/threats.cpp synth_src/util.cpp synth_src/search_bfs.cpp" |
set_project_params -headers "synth_src/connect6.h synth_src/connect6_synth.h synth_src/q.hpp synth_src/shared.h synth_src/threats.h synth_src/util.h" |
set_project_params -cache_result_files no |
set_project_params -cache_data_files yes |
/connect-6/trunk/BUILD_SCC/scc_scripts/run_imp_threat.tcl
1,6 → 1,6
set_project_params -directory ./ |
set_project_params -results myboard.txt |
set_project_params -sources "synth_src/connect6.cpp synth_src/connect6_synth.cpp synth_src/main.cpp synth_src/q.cpp synth_src/state.cpp synth_src/threats.cpp synth_src/util.cpp" |
set_project_params -sources "synth_src/connect6.cpp synth_src/connect6_synth.cpp synth_src/main.cpp synth_src/q.cpp synth_src/state.cpp synth_src/threats.cpp synth_src/util.cpp synth_src/search_bfs.cpp" |
set_project_params -headers "synth_src/connect6.h synth_src/connect6_synth.h synth_src/q.hpp synth_src/shared.h synth_src/threats.h synth_src/util.h" |
set_project_params -cache_result_files no |
set_project_params -cache_data_files yes |
/connect-6/trunk/BUILD_SCC/scc_scripts/run_imp_window.tcl
1,6 → 1,6
set_project_params -directory ./ |
set_project_params -results myboard.txt |
set_project_params -sources "synth_src/connect6.cpp synth_src/connect6_synth.cpp synth_src/main.cpp synth_src/q.cpp synth_src/state.cpp synth_src/threats.cpp synth_src/util.cpp" |
set_project_params -sources "synth_src/connect6.cpp synth_src/connect6_synth.cpp synth_src/main.cpp synth_src/q.cpp synth_src/state.cpp synth_src/threats.cpp synth_src/util.cpp synth_src/search_bfs.cpp" |
set_project_params -headers "synth_src/connect6.h synth_src/connect6_synth.h synth_src/q.hpp synth_src/shared.h synth_src/threats.h synth_src/util.h" |
set_project_params -cache_result_files no |
set_project_params -cache_data_files yes |
/connect-6/trunk/BUILD_SCC/scc_scripts/run_imp_adjacent.tcl
1,7 → 1,7
set SYNTH_SRC "synth_src" |
set_project_params -directory ./ |
set_project_params -results myboard.txt |
set_project_params -sources "${SYNTH_SRC}/connect6.cpp ${SYNTH_SRC}/connect6_synth.cpp ${SYNTH_SRC}/main.cpp ${SYNTH_SRC}/q.cpp ${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/util.cpp" |
set_project_params -sources "${SYNTH_SRC}/connect6.cpp ${SYNTH_SRC}/connect6_synth.cpp ${SYNTH_SRC}/main.cpp ${SYNTH_SRC}/q.cpp ${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/util.cpp ${SYNTH_SRC}/search_bfs.cpp" |
set_project_params -headers "${SYNTH_SRC}/connect6.h ${SYNTH_SRC}/connect6_synth.h ${SYNTH_SRC}/q.hpp ${SYNTH_SRC}/shared.h ${SYNTH_SRC}/threats.h ${SYNTH_SRC}/util.h" |
|
if [file exists imp_adjacent] { delete_implementation imp_adjacent } |
/connect-6/trunk/BUILD_SCC/scc_scripts/run_imp_connect.tcl
1,7 → 1,7
set SYNTH_SRC "synth_src" |
set_project_params -directory ./ |
set_project_params -results myboard.txt |
set_project_params -sources "${SYNTH_SRC}/connect6.cpp ${SYNTH_SRC}/connect6_synth.cpp ${SYNTH_SRC}/main.cpp ${SYNTH_SRC}/q.cpp ${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/util.cpp" |
set_project_params -sources "${SYNTH_SRC}/connect6.cpp ${SYNTH_SRC}/connect6_synth.cpp ${SYNTH_SRC}/main.cpp ${SYNTH_SRC}/q.cpp ${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/util.cpp ${SYNTH_SRC}/search_bfs.cpp" |
set_project_params -headers "${SYNTH_SRC}/connect6.h ${SYNTH_SRC}/connect6_synth.h ${SYNTH_SRC}/q.hpp ${SYNTH_SRC}/shared.h ${SYNTH_SRC}/threats.h ${SYNTH_SRC}/util.h" |
|
if [file exists imp_connect] { delete_implementation imp_connect } |
11,10 → 11,10
set_implementation_params -memory_return_path_external_delay 0% |
set_implementation_params -memory_forward_path_external_delay 0% |
set_implementation_params -instream_forward_path_external_delay 0% |
set_implementation_params -import_tcab "imp_threat imp_adjacent" |
set_implementation_params -import_tcab "imp_search imp_adjacent" |
set_implementation_params -sccompiler_args "-DDONT_VERIFY_PPAID" |
set_implementation_params -outstream_return_path_external_delay 0% |
set_implementation_params -appfiles "${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/connect6_synth.cpp" |
set_implementation_params -appfiles "${SYNTH_SRC}/state.cpp ${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/search_bfs.cpp ${SYNTH_SRC}/connect6_synth.cpp" |
set_implementation_params -proc connect6ai_synth |
set_implementation_params -memory_forward_boundary_register infer |
set_implementation_params -cppcompiler_args "-g -DPICO_SYNTH -fpermissive" |
/connect-6/trunk/BUILD_SCC/synth_src/search_bfs.cpp
0,0 → 1,284
|
/* |
|
connectk -- UMN CSci 5512W project |
|
*/ |
|
//#include "config.h" |
//#include <string.h> |
//#include <glib.h> |
//#include <iostream> |
//#include <stdio.h> |
#include "./shared.h" |
#include "pico.h" |
//#include "../connectk.h" |
|
/* Variables required to check for cache hits */ |
//static int cache_id = -1, cache_depth = -1, cache_branch = -1; |
//static SEARCH cache_search = -1; |
//static AIMoves *cache_moves = NULL; |
//static AIWEIGHT cache_best; |
//static Player *cache_player; |
//static AIFunc cache_func; |
//static BCOORD cache_size; |
|
int ai_stop=0; |
int mini(int x,int y){ |
return (x<=y)?x:y; |
} |
int maxi(int x,int y){ |
return (x>=y)?x:y; |
} |
static AIWEIGHT df_search(Board *b, AIMoves *moves,unsigned int *index, Player *player, |
int depth, int cache_index, |
PIECE searched, AIWEIGHT alpha, AIWEIGHT beta) |
/* Depth is in _moves_ */ |
{ |
#pragma bitsize index 9 |
#pragma internal_fast index |
unsigned int index1[361]={0}; |
#pragma bitsize index 9 |
#pragma internal_fast index |
int i, j; |
Board b_next[5][16]; |
#pragma internal_blockram b_next |
AIMoves moves_next[5][16]; |
#pragma internal_fast moves_next |
int branch=player->branch; |
|
|
|
///* Search only the top moves beyond the minimum */ |
////aimoves_sort(moves); |
//if (moves->len > player->branch) { |
// //for (i = player->branch; i < moves->len; i++) |
// // if (moves->data[i].weight != moves->data[0].weight) |
// // break; |
// //moves->len = i; |
// moves->len = player->branch; |
//} |
|
/* No moves left -- its a draw */ |
for(i=0;i<branch;i++){ |
moves_next[0][0].data[i].x=moves->data[i].x; |
moves_next[0][0].data[i].y=moves->data[i].y; |
moves_next[0][0].data[i].weight=moves->data[i].weight; |
} |
moves_next[0][0].utility=moves->utility; |
moves_next[0][0].len=branch; |
|
if (moves->len < 1) //"(%s)", bcoords_to_string(aim->x, aim->y)); |
|
return AIW_DRAW; |
board_copy(b, &b_next[0][0]); |
|
/* Search each move available in depth first order */ |
for(j=0;j<depth;j++){ |
int k,branches=1; |
for(k=0;k<j+1;k++) branches*=branch; |
//int branches=(player->branch)^j; |
//printf("branches %d\n",branches); |
for (i = 0; i < branches; i++) { |
AIMove *aim = moves_next[j][i>>1].data + (i % branch); |
|
board_copy(&b_next[j][i>>1], &b_next[j+1][i]); |
|
/* Did we get a bad move? */ |
//if (!piece_empty(piece_at(&b_next[j+1][i], aim->x, aim->y))) { |
// //g_warning("DFS utility function suggested a bad move " |
// //"(%s)", bcoords_to_string(aim->x, aim->y)); |
// //printf("bad move\n"); |
// continue; |
//} |
|
/* Already searched here? */ |
///////////////////////////if (piece_at(&b_next[j+1][i], aim->x, aim->y) == searched){ |
/////////////////////////// moves_next[j+1][i].utility=moves_next[j+1][i>>1].utility; |
/////////////////////////// continue; |
///////////////////////////} |
///////////////////////////place_piece_type(&b_next[j+1][i], aim->x, aim->y, searched); |
|
//b_next = board_new(); |
place_piece(&b_next[j+1][i], aim->x, aim->y); |
AIWEIGHT next_alpha = alpha, next_beta = beta; |
//AIFunc func; |
|
|
/* Player has changed */ |
if (b_next[j+1][i].moves_left <= 0) { |
b_next[j+1][i].moves_left = place_p; |
b_next[j+1][i].turn = other_player(b->turn); |
searched++; |
next_alpha = -beta; |
next_beta = -alpha; |
} |
b_next[j+1][i].moves_left--; |
|
/* Did we win? */ |
|
if (check_win_full(&b_next[j+1][i], aim->x, aim->y,0,0,0,0)){ |
aim->weight = AIW_WIN; |
moves_next[j+1][i].utility=AIW_WIN; |
|
}else if(moves_next[j][i>>1].utility==AIW_WIN || moves_next[j][i>>1].utility==-AIW_WIN ){ |
moves_next[j+1][i].utility=AIW_WIN; |
/* Otherwise, search deeper */ |
}else { |
|
//func = ai(player->ai)->func; |
//if (!func) { |
// g_warning("DFS player has no AI function"); |
// return moves->utility; |
//} |
//moves_next = func(b_next); |
ai_threats(&b_next[j+1][i],&moves_next[j+1][i],&index1[0]); |
|
//aim->weight = df_search(&b_next, &moves_next, index,player, |
// depth - 1, next_ci, searched, |
// next_alpha, next_beta); |
//aimoves_free(moves_next); |
} |
if (b_next[j+1][i].turn != b->turn) |
moves_next[j+1][i].utility=-moves_next[j+1][i].utility; |
//if (moves_next[j+1][i].utility >= AIW_WIN) |
// moves_next[j+1][i].utility=AIW_WIN; |
|
/* Debug search */ |
//if (opt_debug_dfsc) { |
// for(j = MAX_DEPTH - depth; j > 0; j--) |
// //g_print("-"); |
// //g_print("> d=%d, %s, u=%d, a=%d, b=%d %s\n", |
// // depth, bcoords_to_string(aim->x, aim->y), |
// // aim->weight, alpha, beta, |
// // piece_to_string(b->turn)); |
//} |
|
//board_free(b_next); |
if (aim->weight > alpha) { |
alpha = aim->weight; |
//cache_set(cache_index, aim); |
|
/* Victory abort */ |
if (alpha >= AIW_WIN) |
return AIW_WIN; |
|
/* Alpha-beta pruning */ |
if (alpha >= beta) |
return alpha; |
} |
//printf("%d %d %d\n",j,i,moves_next[j+1][i].utility); |
} |
} |
for(j=depth-1;j>0;j--){ |
int k,branches=1; |
for(k=0;k<j+1;k++) branches*=branch; |
//int branches=(player->branch)^j; |
//printf("branches %d player %d\n",branches,b_next[j+1][i].turn); |
for (i = 0; i < branches; i=i+2) { |
if (b_next[j+1][i].turn != b->turn) |
moves_next[j][i>>1].utility=maxi(moves_next[j+1][i].utility,moves_next[j+1][i+1].utility); |
else |
moves_next[j][i>>1].utility=mini(moves_next[j+1][i].utility,moves_next[j+1][i+1].utility); |
//printf("%d %d\n",moves_next[j+1][i].utility,moves_next[j+1][i+1].utility); |
} |
} |
for(i=0;i<branch;i++){ |
moves->data[i].weight=moves_next[1][i].utility; |
} |
|
return alpha; |
} |
|
int search(const Board *b, AIMove *move, Player *player) |
{ |
AIMoves moves; |
#pragma internal_blockram moves |
Board copy; |
#pragma internal_blockram copy |
unsigned int index[361]={0}; |
#pragma bitsize index 9 |
#pragma internal_fast index |
//AIFunc move_func = ai(player->ai)->func; |
|
/* Player is not configured to search */ |
//if (player->search == SEARCH_NONE) |
// return; |
|
/* Moves list does not need to be searched */ |
//if (moves->len <= b->moves_left) { |
//// if (opt_debug_dfsc) |
//// g_debug("DFS no choice abort"); |
// return; |
//} |
|
///* Board size changed, cache is invalidated */ |
//if (board_size != cache_size) |
// cache_moves = NULL; |
//cache_size = board_size; |
|
///* Cache hit, last or same board */ |
//if (player->cache && cache_moves && cache_moves->len && |
// cache_search == player->search && |
// cache_depth == player->depth && |
// cache_player == player && |
// cache_func == move_func && |
// cache_branch == player->branch) { |
// if (b->parent && cache_id == b->parent->ac.id) { |
// aimoves_remove(cache_moves, b->parent->move_x, |
// b->parent->move_y); |
// cache_id = b->ac.id; |
// } |
// if (cache_id == b->ac.id && cache_moves->len) { |
// if (cache_moves->len) { |
// aimoves_copy(cache_moves, moves); |
// if (opt_debug_dfsc) |
// g_debug("DFS cache HIT"); |
// return; |
// } |
// aimoves_free(cache_moves); |
// cache_moves = NULL; |
// } |
//} |
|
/* Cache miss */ |
//if (opt_debug_dfsc) |
// g_debug("DFS cache MISS"); |
//cache_id = b->ac.id; |
//if (!cache_moves) |
// cache_moves = aimoves_new(); |
//cache_moves->len = 0; |
//cache_best = AIW_MIN; |
//copy = board_new(); |
board_copy(b, ©); |
ai_threats(©,&moves,&index[0]); |
|
//if (player->search == SEARCH_DFS) { |
df_search(©, &moves, &index[0],player, player->depth, 0, |
PIECE_SEARCHED, AIW_LOSE, AIW_WIN); |
//printf("%d %d \n",moves.data[0].weight,moves.data[1].weight); |
int ret_val; |
ret_val=aimoves_choose(&moves, move,&index[0]); |
if (!ret_val) |
return 0; |
else return 1; |
// if (cache_moves->len) |
// aimoves_copy(cache_moves, moves); |
//} else { |
// board_free(copy); |
// g_warning("Unsupported search type %d", player->search); |
// return; |
//} |
//board_free(copy); |
|
///* Debug DFS search */ |
//if (opt_debug_dfsc) |
// dfs_cache_dump(); |
|
///* Save params so we can check if we have a hit later */ |
//cache_player = player; |
//cache_search = player->search; |
//cache_depth = player->depth; |
//cache_branch = player->branch; |
//cache_func = move_func; |
} |
connect-6/trunk/BUILD_SCC/synth_src/search_bfs.cpp
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: connect-6/trunk/BUILD_SCC/synth_src/connect6_synth.cpp
===================================================================
--- connect-6/trunk/BUILD_SCC/synth_src/connect6_synth.cpp (revision 11)
+++ connect-6/trunk/BUILD_SCC/synth_src/connect6_synth.cpp (revision 12)
@@ -173,7 +173,7 @@
//#pragma num_iterations(1,2,2)
//#pragma unroll
Player player;
- player.depth=3;
+ player.depth=4;
player.branch=2;
for(i=myboard.moves_left;i>0;i--){
//aimoves_free(&moves);
Index: connect-6/trunk/BUILD_SCC/synth_src/search.cpp
===================================================================
--- connect-6/trunk/BUILD_SCC/synth_src/search.cpp (revision 11)
+++ connect-6/trunk/BUILD_SCC/synth_src/search.cpp (revision 12)
@@ -32,9 +32,10 @@
int i, j;
/* Halt and depth abort */
- if (ai_stop || depth < 1)
+ if (ai_stop || depth < 1){
+ printf("dpeth %d %d\n",depth,moves->utility);
return moves->utility;
-
+ }
/* Alpha-beta sanity check */
if (alpha >= beta) {
//g_warning("DFS alpha-beta failed sanity check");
@@ -45,10 +46,11 @@
/* Search only the top moves beyond the minimum */
//aimoves_sort(moves);
if (moves->len > player->branch) {
- for (i = player->branch; i < moves->len; i++)
- if (moves->data[i].weight != moves->data[0].weight)
- break;
- moves->len = i;
+ // for (i = player->branch; i < moves->len; i++)
+ // if (moves->data[i].weight != moves->data[0].weight)
+ // break;
+ // moves->len = i;
+ moves->len=player->branch;
}
/* No moves left -- its a draw */
@@ -106,7 +108,7 @@
// return moves->utility;
//}
//moves_next = func(b_next);
- printf("depth %d branch %d player %d moves_left %d alpha %d MOVE %d %d \n",depth,i,b_next.turn,b_next.moves_left,alpha,aim->y+1,aim->x+1);
+ //printf("depth %d branch %d player %d moves_left %d alpha %d MOVE %d %d \n",depth,i,b_next.turn,b_next.moves_left,alpha,aim->y+1,aim->x+1);
ai_threats(&b_next,&moves_next,index);
aim->weight = df_search(&b_next, &moves_next, index,player,
@@ -149,6 +151,7 @@
{
AIMoves moves;
Board copy;
+ #pragma internal_blockram copy
unsigned int index[361]={0};
//AIFunc move_func = ai(player->ai)->func;
@@ -207,6 +210,7 @@
//if (player->search == SEARCH_DFS) {
df_search(©, &moves, &index[0],player, player->depth, 0,
PIECE_SEARCHED, AIW_LOSE, AIW_WIN);
+ printf("%d %d \n",moves.data[0].weight,moves.data[1].weight);
int ret_val;
ret_val=aimoves_choose(&moves, move,&index[0]);
if (!ret_val)
/connect-6/trunk/BUILD_SCC/synth_src/threats.cpp
356,6 → 356,8
|
//#pragma internal_blockram move |
//#pragma no_memory_analysis move |
#pragma bitsize index 9 |
#pragma internal_fast index |
|
/////////* All threat functions work on this board */ |
/*static*/ Board b;//={0,0,0,0,0,0,0,0,0,0,0,{{0}}} ;//= NULL; |
371,7 → 373,7
//#pragma no_memory_analysis b |
///*static*/ AIMoves moves;//={0,0,0,{{0,0,0}}}; |
//#pragma read_write_ports moves.data combined 3 |
#pragma internal_blockram moves |
//#pragma internal_blockram moves |
//#pragma no_memory_analysis moves |
|
moves->len=0; |
524,8 → 526,8
/*---------------------------------------------------------------------------*/ |
//board_copy(&b,&b_marks); |
//unsigned int index[max_size]={0}; |
#pragma bitsize index 9 |
#pragma internal_fast index |
//#pragma bitsize index 9 |
//#pragma internal_fast index |
AIMoves moves1; |
moves1.len=0; |
#pragma internal_blockram moves1 |
639,7 → 641,7
/*AIMoves*/ void ai_marks(Board *b, PIECE minimum,AIMoves *moves) |
{ |
//#pragma read_write_ports b.data combined 2 |
#pragma internal_blockram b |
//#pragma internal_blockram b |
//#pragma no_memory_analysis b |
//AIMoves *moves = aimoves_new(); |
//AIMoves moves; |
690,8 → 692,8
AIMove val; |
AIMove data[361]={{-1},{-1},{-1}}; |
//unsigned int index[361]; |
#pragma bitsize index 9 |
#pragma internal_fast index |
//#pragma bitsize index 9 |
//#pragma internal_fast index |
int i,j,k; |
unsigned int len=0; |
moves->data[0].weight=-100; |
/connect-6/trunk/BUILD_SCC/synth_src/shared.h
281,7 → 281,7
|
typedef int AIWEIGHT; |
/* Type for AI move weights (utilities) */ |
#pragma bitsize AIWEIGHT 64 |
#pragma bitsize AIWEIGHT 32 |
|
typedef struct { |
AIWEIGHT weight; |
/connect-6/trunk/BUILD_SCC/synth_src/connect6.cpp
206,7 → 206,7
highx = x; |
highy = y; |
currenthigh = temp; |
highRandom = 1;//rand(); |
highRandom =1;// rand(); |
} |
// If a tie happens, pseudo-randomly choose one between them |
if (temp == currenthigh && temp != 0){ |
/connect-6/trunk/BUILD_SCC/synth_src/state.cpp
252,8 → 252,8
// } |
//} |
// return 0; |
if(!moves|| !moves->len) return 0; |
else {*move=moves->data[i];return 1;} |
//if(!moves|| !moves->len) return 0; |
//else {*move=moves->data[i];return 1;} |
|
|
} |
598,6 → 598,7
x += dx; |
y += dy; |
} |
/* this two lines create problem in synthesis preprocess ?? */ |
if (out) |
*out = p; |
return i; |
608,22 → 609,23
{ |
int i, c1, c2, xs[] = {1, 1, 0, -1}, ys[] = {0, 1, 1, 1}; |
PIECE type; |
PIECE p; |
|
type = piece_at(b, x, y); |
if (type != PIECE_BLACK && type != PIECE_WHITE) |
return FALSE; |
for (i = 0; i < 4; i++) { |
c1 = count_pieces(b, x, y, type, xs[i], ys[i], 0); |
c2 = count_pieces(b, x, y, type, -xs[i], -ys[i], 0); |
c1 = count_pieces(b, x, y, type, xs[i], ys[i], &p); |
c2 = count_pieces(b, x, y, type, -xs[i], -ys[i], &p); |
if (c1 + c2 > connect_k) { |
if (x1) |
*x1 = x + xs[i] * (c1 - 1); |
if (y1) |
*y1 = y + ys[i] * (c1 - 1); |
if (x2) |
*x2 = x - xs[i] * (c2 - 1); |
if (y2) |
*y2 = y - ys[i] * (c2 - 1); |
//if (x1) |
// *x1 = x + xs[i] * (c1 - 1); |
//if (y1) |
// *y1 = y + ys[i] * (c1 - 1); |
//if (x2) |
// *x2 = x - xs[i] * (c2 - 1); |
//if (y2) |
// *y2 = y - ys[i] * (c2 - 1); |
return TRUE; |
} |
} |
/connect-6/trunk/BUILD_SCC/synth_src/main.cpp
219,7 → 219,7
connect6ai(board,AI_colour,move); |
movecount++; |
cout<<"AI MOVE: "<<move[0]<<move[1]<<move[2]<<move[3]<<endl; |
//if(movecount >=20) return 0 ; //reducing length of simulation |
if(movecount >=20) return 0 ; //reducing length of simulation |
winning_colour = check_for_win(board); |
if (winning_colour == AI_colour){ |
cout<<"AI has won! " << movecount << " moves " << "Exiting."<<endl; |
/connect-6/trunk/BUILD_SCC/Makefile
27,7 → 27,7
${GCC} -c -g -pg ${SYNTH_SRC}/state.cpp |
|
search.o:${SYNTH_SRC}/search.cpp ${SYNTH_SRC}/shared.h |
${GCC} -c -g -pg ${SYNTH_SRC}/search.cpp |
${GCC} -c -g -pg ${SYNTH_SRC}/search_bfs.cpp -o search.o |
threats.o:${SYNTH_SRC}/threats.cpp ${SYNTH_SRC}/shared.h |
${GCC} -c -g -pg ${SYNTH_SRC}/threats.cpp |
q.o:${SYNTH_SRC}/q.cpp ${SYNTH_SRC}/shared.h |
78,7 → 78,11
sed -s 's/\\TCAB_NAME/ai_adjacent/g' ${SYNTH_SRC}/main.cpp.base >${SYNTH_SRC}/main.cpp |
${SCC} ${SCC_SCRIPTS}/run_imp_adjacent.tcl |
echo "Done" > imp_adjacent.tag |
imp_connect.tag: imp_threat.tag imp_adjacent.tag |
imp_search.tag: imp_threat.tag |
sed -s 's/\\TCAB_NAME/search/g' ${SYNTH_SRC}/main.cpp.base >${SYNTH_SRC}/main.cpp |
${SCC} ${SCC_SCRIPTS}/run_imp_search.tcl |
echo "Done" > imp_search.tag |
imp_connect.tag: imp_search.tag imp_adjacent.tag |
sed -s 's/\\TCAB_NAME/connect6ai_synth/g' ${SYNTH_SRC}/main.cpp.base >${SYNTH_SRC}/main.cpp |
${SCC} ${SCC_SCRIPTS}/run_imp_connect.tcl |
echo "Done" > imp_connect.tag |