OpenCores
URL https://opencores.org/ocsvn/connect-6/connect-6/trunk

Subversion Repositories connect-6

[/] [connect-6/] [trunk/] [BUILD_SCC/] [synth_src/] [state.cpp] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sumanta.ch
 
2
/*
3
 
4
connectk -- a program to play the connect-k family of games
5
Copyright (C) 2007 Michael Levin
6
 
7
This program is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation; either version 2
10
of the License, or (at your option) any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
21
*/
22
 
23
//#include "config.h"
24
//#include <gtk/gtk.h>
25
//#include <glib/gprintf.h>
26
//#include <stdlib.h>
27
//#include <stdio.h>
28
//#include <string.h>
29
//#include <math.h>
30
#include "./shared.h"
31
//#include "connectk.h"
32
 
33
/*
34
 *      Allocation chain
35
 */
36
 
37
#define IA 1103515245u
38
#define IC 12345u
39
#define IM 2147483648u
40
#define CHECK_RAND
41
//moved the following declaration to connect6_threat
42
//static unsigned int current_random = 0;
43
 
44
//from vpr uti.c code
45
/* Portable random number generator defined below.  Taken from ANSI C by  *
46
 * K & R.  Not a great generator, but fast, and good enough for my needs. */
47
 
48
 
49
void my_srandom(int seed,unsigned int *current_random)
50
{
51
    *current_random = (unsigned int)seed;
52
}
53
 
54
 
55
int my_irand(int imax,unsigned int current_random)
56
{
57
 
58
///* Creates a random integer between 0 and imax, inclusive.  i.e. [0..imax] */
59
//
60
//    int ival;
61
//
62
///* current_random = (current_random * IA + IC) % IM; */
63
//    current_random = current_random * IA + IC;  /* Use overflow to wrap */
64
//    ival = current_random & (IM - 1);   /* Modulus */
65
//      //float not synthesizable
66
//    //ival = (int)((float)ival * (float)(imax + 0.999) / (float)IM);
67
//    ival = (int)(ival * (imax + 1) / IM);
68
//
69
//#ifdef CHECK_RAND
70
//    if((ival < 0) || (ival > imax))
71
//        {
72
//            //printf("Bad value in my_irand, imax = %d  ival = %d\n", imax,
73
//            //       ival);
74
//            //exit(1);
75
//        }
76
//#endif
77
//
78
//    return (ival);
79
return(0);
80
}
81
 
82
 
83
//static void achain_init(AllocChain *ac)
84
//{
85
//        static unsigned int ids;
86
//
87
//        ac->free = FALSE;
88
//        ac->id = ids++;
89
//}
90
//
91
//AllocChain *achain_new(AllocChain **root, AllocFunc afunc)
92
//{
93
//        AllocChain *ac;
94
//
95
//        if (!*root) {
96
//                *root = afunc(NULL);
97
//                achain_init(*root);
98
//                (*root)->next = NULL;
99
//                return *root;
100
//        }
101
//        ac = *root;
102
//        for (;;) {
103
//                if (ac->free) {
104
//                        afunc(ac);
105
//                        achain_init(ac);
106
//                        return ac;
107
//                }
108
//                if (!ac->next)
109
//                        break;
110
//                ac = ac->next;
111
//        }
112
//        ac->next = afunc(NULL);
113
//        achain_init(ac->next);
114
//        ac->next->next = NULL;
115
//        return ac->next;
116
//}
117
//
118
//void achain_free(AllocChain *ac)
119
//{
120
//        if (!ac)
121
//                return;
122
//        ac->free = TRUE;
123
//}
124
//
125
//void achain_copy(const AllocChain *src, AllocChain *dest, gsize mem)
126
//{
127
//        if (!src || !dest || !mem) {
128
//                g_warning("NULL argument(s) to achain_copy");
129
//                return;
130
//        }
131
//        memcpy((char*)dest + sizeof (AllocChain),
132
//               (char*)src + sizeof (AllocChain), mem - sizeof (AllocChain));
133
//}
134
//
135
//static void achain_dealloc(AllocChain **root, gsize mem)
136
//{
137
//        AllocChain *ac = *root, *ac_next;
138
//
139
//        while (ac) {
140
//                ac_next = ac->next;
141
//                g_slice_free1(mem, ac);
142
//                ac = ac_next;
143
//        }
144
//        *root = NULL;
145
//}
146
 
147
 
148
//      Move Arrays
149
 
150
 
151
//AllocChain *aimoves_root = NULL;
152
gsize aimoves_mem = 0;
153
 
154
//AllocChain *aimoves_alloc(AllocChain *ac)
155
//{
156
//        //if (!ac)
157
//        //        ac = (AllocChain*)g_slice_alloc(aimoves_mem);
158
//        //memset((char*)ac + sizeof (AllocChain), 0, sizeof (AIMoves) -
159
//        //       sizeof (AllocChain));
160
//        //return ac;
161
//}
162
 
163
void aimoves_add(AIMoves *moves, const AIMove *move)
164
{
165
        int i;
166
 
167
        i = aimoves_find(moves, move->x, move->y);
168
        if (i < 0) {
169
                if (moves->len >= board_size * board_size)
170
                        //g_warning("Attempted to add a move to a full AIMoves");
171
                        //printf("Attempted to add a move to a full AIMoves");
172
                        return;
173
                else
174
                        moves->data[moves->len++] = *move;
175
        } else
176
                moves->data[i].weight += move->weight;
177
}
178
 
179
void aimoves_append(AIMoves *moves, const AIMove *move)
180
{
181
        int i;
182
 
183
        if (move->x >= board_size || move->y >= board_size)
184
                return;
185
        for (i = 0; i < moves->len; i++) {
186
                AIMove *aim = moves->data + i;
187
 
188
                if (aim->x == move->x && aim->y == move->y) {
189
                        aim->weight = move->weight;
190
                        return;
191
                }
192
        }
193
        if (moves->len >= board_size * board_size) {
194
                //g_warning("Attempted to append a move to a full AIMoves");
195
                //printf("Attempted to append a move to a full AIMoves");
196
                return;
197
        }
198
        moves->data[moves->len++] = *move;
199
}
200
 
201
int aimoves_compare(const void *a, const void *b)
202
{
203
        return ((AIMove*)b)->weight - ((AIMove*)a)->weight;
204
}
205
 
206
int aimoves_choose(AIMoves *moves, AIMove *move)
207
{
208
        //#pragma read_write_ports moves.data combined 3
209
        //#pragma internal_blockram moves
210
        //#pragma no_memory_analysis moves
211
        int i = 0, top = 0;
212
        #pragma bitsize i 4
213
        if (!moves || !moves->len)
214
                return 0;
215
        aimoves_sort(moves);
216
        for (top = 0; top < moves->len &&
217
             moves->data[top].weight == moves->data[0].weight; top++);
218
        if (top)
219
                //i = my_irand(top,current_random);//g_random_int_range(0, top);
220
                i=0;
221
 
222
        *move = moves->data[i];
223
        return 1;
224
}
225
//
226
//void aimoves_crop(AIMoves *moves, unsigned int n)
227
//{
228
//        if (moves->len < n)
229
//                return;
230
//        aimoves_shuffle(moves);
231
//        aimoves_sort(moves);
232
//        moves->len = n;
233
//}
234
//
235
//void aimoves_concat(AIMoves *m1, const AIMoves *m2)
236
//{
237
//        gsize max_len = board_size * board_size, len;
238
//
239
//        len = m2->len;
240
//        if (m1->len + len > max_len)
241
//                len = max_len - m1->len;
242
//        memcpy(m1->data + len, m2->data, len * sizeof (AIMove));
243
//        m1->len += len;
244
//}
245
//
246
//AIMoves *aimoves_dup(const AIMoves *moves)
247
//{
248
//        AIMoves *dup;
249
//
250
//        if (!moves)
251
//                return NULL;
252
//        dup = aimoves_new();
253
//        dup->len = moves->len;
254
//        memcpy(dup->data, moves->data, moves->len * sizeof (AIMove));
255
//        return dup;
256
//}
257
//
258
int aimoves_find(const AIMoves *moves, BCOORD x, BCOORD y)
259
{
260
        int i;
261
 
262
        if (moves)
263
                for (i = 0; i < moves->len; i++) {
264
                        const AIMove *aim = moves->data + i;
265
 
266
                        if (aim->x == x && aim->y == y)
267
                                return i;
268
                }
269
        return -1;
270
}
271
//
272
//void aimoves_range(AIMoves *moves, AIWEIGHT *min, AIWEIGHT *max)
273
//{
274
//        int i;
275
//
276
//        *min = AIW_MAX;
277
//        *max = AIW_MIN;
278
//        for (i = 0; i < moves->len; i++) {
279
//                if (moves->data[i].weight > *max)
280
//                        *max = moves->data[i].weight;
281
//                if (moves->data[i].weight < *min)
282
//                        *min = moves->data[i].weight;
283
//        }
284
//}
285
//
286
//void aimoves_merge(AIMoves *m1, const AIMoves *m2)
287
//{
288
//        int len = m1->len, i, j;
289
//
290
//        for (i = 0; i < m2->len; i++)
291
//                for (j = 0;; j++) {
292
//                        if (j >= len) {
293
//                                aimoves_append(m1, m2->data + i);
294
//                                break;
295
//                        }
296
//                        if (m1->data[j].x == m2->data[i].x &&
297
//                            m1->data[j].y == m2->data[i].y) {
298
//                                if (m2->data[i].weight > m1->data[j].weight)
299
//                                        m1->data[j].weight = m2->data[i].weight;
300
//                                break;
301
//                        }
302
//                }
303
//}
304
//
305
//char *aimove_to_string(const AIMove *aim)
306
//{
307
//        static char buffer[32];
308
//
309
//        g_snprintf(buffer, sizeof (buffer), "%s (%s)",
310
//                   bcoords_to_string(aim->x, aim->y),
311
//                   aiw_to_string(aim->weight));
312
//        return buffer;
313
//}
314
//
315
//void aimoves_print(const AIMoves *moves)
316
//{
317
//        int i;
318
//
319
//        if (!moves || !moves->len) {
320
//                g_print("(empty)");
321
//                return;
322
//        }
323
//        for (i = 0; i < moves->len; i++) {
324
//                const AIMove *aim = moves->data + i;
325
//
326
//                if (i)
327
//                        g_print(", ");
328
//                g_print("%s", aimove_to_string(aim));
329
//        }
330
//}
331
//
332
//void aimoves_remove_index_fast(AIMoves *moves, int i)
333
//{
334
//        if (moves->len > i)
335
//                moves->data[i] = moves->data[moves->len - 1];
336
//        moves->len--;
337
//}
338
//
339
//void aimoves_remove(AIMoves *moves, BCOORD x, BCOORD y)
340
//{
341
//        int i;
342
//
343
//        for (i = 0; i < moves->len; i++) {
344
//                AIMove *aim = moves->data + i;
345
//
346
//                if (aim->x == x && aim->y == y) {
347
//                        aimoves_remove_index_fast(moves, i);
348
//                        return;
349
//                }
350
//        }
351
//}
352
//
353
void aimoves_shuffle(AIMoves *moves,unsigned int current_random)
354
{
355
//        int i;
356
//
357
//        if (opt_det_ai)
358
//                return;
359
//
360
//        /* Fisher-Yates shuffle */
361
//        for (i = 0; i < moves->len; i++) {
362
//                int j;
363
//
364
//                j = my_irand(moves->len,current_random);//g_random_int_range(i, moves->len);
365
//                if (i != j) {
366
//                        AIMove tmp;
367
//
368
//                        tmp = moves->data[i];
369
//                        moves->data[i] = moves->data[j];
370
//                        moves->data[j] = tmp;
371
//                }
372
//        }
373
return;
374
}
375
 
376
 
377
//taken from http://cprogramminglanguage.net/c-bubble-sort-source-code.aspx
378
void swap(AIMove  *x,AIMove *y)
379
{
380
   AIMove temp;
381
   temp = *x;
382
   *x = *y;
383
   *y = temp;
384
}
385
void bublesort(AIMove *list, int n)
386
{
387
   int i,j;
388
   for(i=0;i<(n-1);i++)
389
      for(j=0;j<(n-(i+1));j++)
390
             if(list[j].weight < list[j+1].weight)
391
                    swap(&list[j],&list[j+1]);
392
}
393
//taken from http://cprogramminglanguage.net/c-bubble-sort-source-code.aspx
394
void aimoves_sort(AIMoves *moves)
395
{
396
        //qsort(moves->data, moves->len, sizeof (AIMove), aimoves_compare);
397
        bublesort(moves->data,moves->len);
398
 
399
}
400
 
401
//void aimoves_subtract(AIMoves *m1, const AIMoves *m2)
402
//{
403
//        int i, j;
404
//
405
//        for (i = 0; i < m1->len; i++)
406
//                for (j = 0; j < m2->len; j++)
407
//                        if (m1->data[i].x == m2->data[j].x &&
408
//                            m1->data[i].y == m2->data[j].y) {
409
//                                aimoves_remove_index_fast(m1, i--);
410
//                                break;
411
//                        }
412
//}
413
//
414
//const char *aiw_to_string(AIWEIGHT w)
415
//{
416
//        static char buffer[32];
417
//
418
//        switch (w) {
419
//        case AIW_WIN:
420
//                return "WIN";
421
//        case AIW_LOSE:
422
//                return "LOSS";
423
//        case AIW_NONE:
424
//                return "NONE";
425
//        default:
426
//                break;
427
//        }
428
//        if (w > 0)
429
//                g_snprintf(buffer, sizeof (buffer), "%010d (10^%.2f)", w,
430
//                           log10((double)w));
431
//        else if (w < 0)
432
//                g_snprintf(buffer, sizeof (buffer), "%010d (-10^%.2f)", w,
433
//                           log10((double)-w));
434
//        return buffer;
435
//}
436
 
437
/*
438
 *      Boards
439
 */
440
 
441
//Board board;
442
//AllocChain *board_root = NULL;
443
//int board_size=19, board_stride=21, move_no, move_last,
444
//    connect_k = 6, place_p = 2, start_q = 1;
445
//int opt_det_ai=1;
446
//gsize board_mem = 0;
447
 
448
//Player players[PIECES] = {
449
//        { PLAYER_HUMAN, SEARCH_NONE, 0 },
450
//        { PLAYER_HUMAN, SEARCH_NONE, 0 },
451
//        { PLAYER_HUMAN, SEARCH_NONE, 0 },
452
//};
453
//
454
//static GPtrArray *history = NULL;
455
 
456
static void board_init(Board *b)
457
{
458
//        memset((char*)b + sizeof (AllocChain), 0, sizeof (Board) -
459
//               sizeof (AllocChain));
460
int i,j;
461
for(i=0;i<board_stride;i++)
462
        b->data[i][0]=PIECE_ERROR;
463
for(i=0;i<board_stride;i++)
464
        b->data[i][board_stride-1]=PIECE_ERROR;
465
for(j=0;j<board_stride;j++)
466
        b->data[0][j]=PIECE_ERROR;
467
for(j=0;j<board_stride;j++)
468
        b->data[board_stride-1][j]=PIECE_ERROR;
469
for(i=1;i<board_stride-1;i++)
470
        for(j=1;j<board_stride-1;j++)
471
                b->data[i][j]=PIECE_NONE;
472
 
473
        //b->ac=(const AllocChain )0;   
474
        b->moves_left=0;
475
        b->parent =0;
476
        b->won    =0;
477
        b->win_x1 =0;
478
        b->win_y1 =0;
479
        b->win_x2 =0;
480
        b->win_y2 =0;
481
        b->turn   =0;
482
        b->move_x =0;
483
        b->move_y =0;
484
}
485
 
486
//AllocChain *board_alloc(AllocChain *ac)
487
//{
488
//        //Board *b = (Board*)ac;
489
//        //int i;
490
//
491
//        ///* Clear the old board */
492
//        //if (b) {
493
//        //        for (i = 1; i <= board_size; i++)
494
//        //                memset(b->data + board_stride * i + 1, 0,
495
//        //                       board_size * sizeof (PIECE));
496
//        //        board_init(b);
497
//        //        return (AllocChain*)b;
498
//        //}
499
//
500
//        ///* New boards are allocated with a 1-tile wide boundary of PIECE_ERROR
501
//        //   around the edges */
502
//        //b = (Board*)g_slice_alloc0(board_mem);
503
//        //memset(b->data, PIECE_ERROR, sizeof (PIECE) * board_stride);
504
//        //for (i = 1; i <= board_size; i++) {
505
//        //        b->data[i * board_stride] = PIECE_ERROR;
506
//        //        memset(b->data + board_stride * i + 1, 0,
507
//        //               board_size * sizeof (PIECE));
508
//        //        b->data[(i + 1) * board_stride - 1] = PIECE_ERROR;
509
//        //}
510
//        //memset(b->data + board_stride * (board_stride - 1), PIECE_ERROR,
511
//        //       sizeof (PIECE) * board_stride);
512
//        //board_init(&b);
513
//        //return (AllocChain*)b;
514
//}
515
 
516
void board_clean(Board *b)
517
{
518
        int y, x;
519
 
520
        for (y = 0; y < board_size; y++)
521
                for (x = 0; x < board_size; x++)
522
                        if (piece_at(b, x, y) >= PIECES)
523
                                place_piece_type(b, x, y, PIECE_NONE);
524
}
525
 
526
//void set_board_size(unsigned int size)
527
//{
528
//        //if (board_size == size)
529
//        //        return;
530
//        ////draw_marks(NULL, FALSE);
531
//        //achain_dealloc(&board_root, board_mem);
532
//        achain_dealloc(&aimoves_root, aimoves_mem);
533
//        //board_size = size;
534
//        //board_stride = size + 2;
535
//        //board_mem = sizeof (Board) + board_stride * board_stride *
536
//        //            sizeof (PIECE);
537
//        aimoves_mem = sizeof (AIMoves) + size * size * sizeof (AIMove);
538
//}
539
 
540
//Board *board_at(unsigned int move)
541
//{
542
//        if (move >= history->len)
543
//                return NULL;
544
//        return (Board*)g_ptr_array_index(history, move);
545
//}
546
 
547
int count_pieces(const Board *b, BCOORD x, BCOORD y, PIECE type, int dx, int dy,
548
                 PIECE *out)
549
{
550
        int i;
551
        PIECE p = PIECE_NONE;
552
 
553
        if (!dx && !dy)
554
                return piece_at(b, x, y) == type ? 1 : 0;
555
        for (i = 0; x >= 0 && x < board_size && y >= 0 && y < board_size; i++) {
556
                p = piece_at(b, x, y);
557
                if (p != type)
558
                        break;
559
                x += dx;
560
                y += dy;
561
        }
562
        if (out)
563
                *out = p;
564
        return i;
565
}
566
 
567
gboolean check_win_full(const Board *b, BCOORD x, BCOORD y,
568
                        BCOORD *x1, BCOORD *y1, BCOORD *x2, BCOORD *y2)
569
{
570
        int i, c1, c2, xs[] = {1, 1, 0, -1}, ys[] = {0, 1, 1, 1};
571
        PIECE type;
572
 
573
        type = piece_at(b, x, y);
574
        if (type != PIECE_BLACK && type != PIECE_WHITE)
575
                return FALSE;
576
        for (i = 0; i < 4; i++) {
577
                c1 = count_pieces(b, x, y, type, xs[i], ys[i], 0);
578
                c2 = count_pieces(b, x, y, type, -xs[i], -ys[i], 0);
579
                if (c1 + c2 > connect_k) {
580
                        if (x1)
581
                                *x1 = x + xs[i] * (c1 - 1);
582
                        if (y1)
583
                                *y1 = y + ys[i] * (c1 - 1);
584
                        if (x2)
585
                                *x2 = x - xs[i] * (c2 - 1);
586
                        if (y2)
587
                                *y2 = y - ys[i] * (c2 - 1);
588
                        return TRUE;
589
                }
590
        }
591
        return FALSE;
592
}
593
 
594
///* Convert a boord coordinate to alpha representation */
595
//const char *bcoord_to_alpha(BCOORD x)
596
//{
597
//        static char buf[2][32];
598
//        static int which;
599
//        int i, divisor = 26;
600
//
601
//        which = !which;
602
//        for (i = 0; i < sizeof (buf[which]) - 1; i++) {
603
//                div_t result;
604
//
605
//                result = div(x, divisor);
606
//                buf[which][i] = 'a' + result.rem * 26 / divisor;
607
//                if (i)
608
//                        buf[which][i]--;
609
//                x -= result.rem;
610
//                if (!x)
611
//                        break;
612
//                divisor *= 26;
613
//        }
614
//        buf[which][i + 1] = 0;
615
//        return g_strreverse(buf[which]);
616
//}
617
 
618
//// Get a string representation of board x/y coordinates (d7, h16, etc)
619
//const char *bcoords_to_string(BCOORD x, BCOORD y)
620
//{
621
//        static char buf[2][32];
622
//        static int which;
623
//
624
//        which = !which;
625
//        g_snprintf(buf[which], sizeof (buf[which]), "%s%d",
626
//                   bcoord_to_alpha(x), board_size - y);
627
//        return buf[which];
628
//}
629
//
630
/* Convert a string representation to coordinates */
631
void string_to_bcoords(const char *str, BCOORD *x, BCOORD *y)
632
{
633
        *x = 0;
634
        *y = 0;
635
        while (*str && *str >= 'a' && *str <= 'z') {
636
                *x *= 26;
637
                *x += *str - 'a';
638
                str++;
639
        }
640
        while (*str && *str >= '0' && *str <= '9') {
641
                *y *= 10;
642
                *y += *str - '0';
643
                str++;
644
        }
645
        if (*y)
646
                *y = board_size - *y;
647
}
648
 
649
const char *piece_to_string(PIECE piece)
650
{
651
        switch (piece) {
652
        case PIECE_WHITE:
653
                return "White";
654
        case PIECE_BLACK:
655
                return "Black";
656
        case PIECE_NONE:
657
                return "None";
658
        case PIECE_ERROR:
659
                return "Error";
660
        default:
661
                return "Mark";
662
        }
663
}
664
 
665
char piece_to_char(PIECE piece)
666
{
667
        switch (piece) {
668
        case PIECE_WHITE:
669
                return 'W';
670
        case PIECE_BLACK:
671
                return 'B';
672
        case PIECE_NONE:
673
                return '_';
674
        case PIECE_ERROR:
675
                return 'E';
676
        default:
677
                return 'M';
678
        }
679
}
680
 
681
//char *search_to_string(SEARCH s)
682
//{
683
//        switch (s) {
684
//        case SEARCH_NONE:
685
//                return "No search";
686
//        case SEARCH_DFS:
687
//                return "Depth first search";
688
//        case SEARCHES:
689
//                break;
690
//        }
691
//        return "Unknown";
692
//}
693
 
694
//void go_to_move(unsigned int move)
695
//{
696
//        Board board2;
697
//
698
//        if (!history)
699
//                history = g_ptr_array_sized_new(32);
700
//        if (move > history->len)
701
//                move = history->len;
702
//        if (move == history->len) {
703
//                //board2 = board_new();
704
//                if (&board)
705
//                        board_copy(&board, &board2);
706
//                g_ptr_array_add(history, &board2);
707
//                board2.parent = &board;
708
//        } else
709
//                //board2 = (Board*)g_ptr_array_index(history, move);
710
//        //&board = &board2;
711
//        move_no = move;
712
//        if (move_no > move_last)
713
//                move_last = move_no;
714
//}
715
 
716
//void clear_history(unsigned int from)
717
//{
718
//        int i;
719
//
720
//        if (!history)
721
//                return;
722
//        if (from >= history->len) {
723
//                g_warning("Attempted to clear future history");
724
//                return;
725
//        }
726
//        for (i = from; i < history->len; i++)
727
//                board_free(g_ptr_array_index(history, i));
728
//        g_ptr_array_remove_range(history, from, history->len - from);
729
//        move_last = from;
730
//}
731
/* Clear the board and history for a new game */
732
void new_game(Board *board,unsigned int size)
733
{
734
        //tree_view_clear(1);
735
        //clear_history(0);
736
        //set_board_size(size);
737
        //board = NULL;
738
        //go_to_move(0);
739
        //move_last=0;
740
        //move_no=0;
741
        board_init(board);
742
        board->moves_left = start_q;
743
        board->turn = PIECE_BLACK;
744
        //draw_board();
745
        //stop_ai();
746
        //setup_move();
747
}
748
void board_copy(const Board *from, Board *to){
749
int i,j;
750
for(i=0;i<board_stride;i++)
751
        for(j=0;j<board_stride;j++)
752
                to->data[i][j]=from->data[i][j];
753
 
754
        to->ac= from->ac;
755
        to->moves_left= from->moves_left;
756
        to->parent =    from->parent;
757
        to->won    =    from->won;
758
        to->win_x1 =    from->win_x1;
759
        to->win_y1 =    from->win_y1;
760
        to->win_x2 =    from->win_x2;
761
        to->win_y2 =    from->win_y2;
762
        to->turn   =    from->turn;
763
        to->move_x =    from->move_x;
764
        to->move_y =    from->move_y;
765
 
766
 
767
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.