Logo Search packages:      
Sourcecode: filler version File versions  Download package

static void friendless::games::filler::FillerModel::allocateFree ( FillerModel  model,
FillerPlayerSpace  space,
int  myBorder,
boolean[]  reachable 
) [inline, static, package]

Update the reachable array to determine whether each piece can ever be reached by me.

Definition at line 167 of file FillerModel.java.

References BORDER, friendless::games::filler::FillerPlayerSpace::border, friendless::games::filler::FillerPlayerSpace::counted, HIS_BORDER, friendless::games::filler::FillerPlayerSpace::listed, NO_NEIGHBOUR, friendless::games::filler::FillerPlayerSpace::resetListed(), SHARED_BORDER, and VACANT.

Referenced by allocateTypes().

                                 {
        //int hisBorder = BORDER + HIS_BORDER - myBorder;
        space.resetListed();
        int[] counted = space.counted;
        boolean[] listed = space.listed;
        int[] border = space.border;
        // build up the list of positions on the border
        int idx = 0;
        for (int i=0; i<FillerSettings.SIZE; i++) {
            if ((counted[i] == myBorder) || (counted[i] == SHARED_BORDER)) {
                listed[i] = true;
                border[idx++] = i;
            }
        }
        // process the positions on the border
        int[] ns = null;
        while (idx > 0) {
            // take a point which is currently on the border
            int p = border[--idx];
            switch (counted[p]) {
                case VACANT:
                case BORDER:
                case SHARED_BORDER:
                case HIS_BORDER:
                    reachable[p] = true;
                    ns = neighs[p];
                    for (int i=0; i<ns.length; i++) {
                        int q = ns[i];
                        if (q == NO_NEIGHBOUR) break;
                        if (!listed[q]) {
                            listed[q] = true;
                            border[idx++] = q;
                        }
                    }
                    break;
            }
        }
    }


Generated by  Doxygen 1.6.0   Back to index