~ubuntu-branches/ubuntu/gutsy/grhino/gutsy

« back to all changes in this revision

Viewing changes to iter.cc

  • Committer: Bazaar Package Importer
  • Author(s): Bart Martens
  • Date: 2007-04-02 20:38:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070402203809-fxyqqtkhj9ou03dy
Tags: upstream-0.16.0
ImportĀ upstreamĀ versionĀ 0.16.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        iter.cc         Iterators
 
3
        Copyright (c) 2000, 2001, 2003 Kriang Lerdsuwanakij
 
4
        email:          lerdsuwa@users.sourceforge.net
 
5
 
 
6
        This program is free software; you can redistribute it and/or modify
 
7
        it under the terms of the GNU General Public License as published by
 
8
        the Free Software Foundation; either version 2 of the License, or
 
9
        (at your option) any later version.
 
10
 
 
11
        This program is distributed in the hope that it will be useful,
 
12
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
        GNU General Public License for more details.
 
15
 
 
16
        You should have received a copy of the GNU General Public License
 
17
        along with this program; if not, write to the Free Software
 
18
        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
*/
 
20
 
 
21
#include "iter.h"
 
22
 
 
23
// FIXME: Iterator data are shared and not thread-safe.
 
24
 
 
25
int     empty_endgame_size;
 
26
empty_endgame_entry *empty_endgame_head;
 
27
empty_endgame_entry empty_endgame_order[NUM_MOVE];
 
28
 
 
29
void init_endgame_iterator(byte_board_info *board, empty_endgame_info &info)
 
30
{
 
31
        int     count = 0;
 
32
        board_full_endgame_iterator     iter;
 
33
        iter.init_pos();
 
34
 
 
35
        info.empty_endgame_head = 0;
 
36
        do {
 
37
                if (board->is_empty(iter.pos)) {
 
38
                        if (!count)
 
39
                                info.empty_endgame_head = info.empty_endgame_order;
 
40
                        else
 
41
                                info.empty_endgame_order[count-1].next = &(info.empty_endgame_order[count]);
 
42
 
 
43
                        info.empty_endgame_order[count].pos = iter.pos;
 
44
                        info.empty_endgame_order[count].next = 0;
 
45
                        count++;
 
46
                }
 
47
        } while (iter.next());
 
48
        info.empty_endgame_size = count;
 
49
}
 
50