Ignore:
Timestamp:
10/13/07 19:56:29 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mtools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtools/MagicReversi.cc

    r8755 r8756  
    481481}
    482482
    483 Int_t MagicReversi::GetDirection(Int_t src, Int_t dst) const
    484 {
    485     const MGeomPix &pix1=(*fGeomCam)[dst];
    486     const MGeomPix &pix2=(*fGeomCam)[src];
    487 
    488     const Double_t x1 = pix1.GetX();
    489     const Double_t y1 = pix1.GetY();
    490 
    491     const Double_t x2 = pix2.GetX();
    492     const Double_t y2 = pix2.GetY();
    493 
    494     if (x1>=x2 && y1>y2) return kRightTop;
    495     if (x1>=x2 && y1<y2) return kRightBottom;
    496     if (x1<=x2 && y1>y2) return kLeftTop;
    497     if (x1<=x2 && y1<y2) return kLeftBottom;
    498     if (x1>x2)           return kRight;
    499     if (x1<x2)           return kLeft;
    500 
    501     return -1;
    502 }
    503 
    504 Int_t MagicReversi::GetNeighbor(Int_t idx, Int_t dir) const
    505 {
    506     MGeomPix &pix=(*fGeomCam)[idx];
    507 
    508     //
    509     // search for the neighbor in the given direction
    510     //
    511     int i;
    512     for (i=0; i<pix.GetNumNeighbors(); i++)
    513         if (GetDirection(idx, pix.GetNeighbor(i))==dir)
    514             return pix.GetNeighbor(i);
    515 
    516     return -1;
    517 }
    518 
    519483Bool_t MagicReversi::Flip(Int_t origidx, Bool_t flip)
    520484{
     
    523487    int test[6] = {0,0,0,0,0,0};
    524488
    525     for (int dir=kRightTop; dir<=kLeftTop; dir++)
     489    for (int dir=MGeomPix::kRightTop; dir<=MGeomPix::kLeftTop; dir++)
    526490    {
    527491        Int_t idx = origidx;
     
    530494        while (1)
    531495        {
    532             idx = GetNeighbor(idx, dir);
     496            idx = fGeomCam->GetNeighbor(idx, dir);
    533497            if (idx<0 || (*this)[idx].GetFillColor()==kEmpty)
    534498                break;
     
    547511    int cnt = 0;
    548512
    549     for (int dir=kRightTop; dir<=kLeftTop; dir++)
     513    for (int dir=MGeomPix::kRightTop; dir<=MGeomPix::kLeftTop; dir++)
    550514    {
    551515        Int_t idx = origidx;
     
    557521            for (int i=0; i<test[dir]; i++)
    558522            {
    559                 idx = GetNeighbor(idx, dir);
     523                idx = fGeomCam->GetNeighbor(idx, dir);
    560524
    561525                fUsrPts[(*this)[idx].GetFillColor()-kRed]--;
  • trunk/MagicSoft/Mars/mtools/MagicReversi.h

    r8755 r8756  
    1919{
    2020private:
    21     enum {
    22         kRightTop,
    23         kRight,
    24         kRightBottom,
    25         kLeftBottom,
    26         kLeft,
    27         kLeftTop
    28     };
    29 //    static const Int_t fColorBombs[7]; // colors for the hexagons
    30 
    3121    MGeomCam      *fGeomCam;       // pointer to camera geometry
    3222
     
    7363
    7464    Bool_t Flip(Int_t idx, Bool_t flip);
    75     Int_t  GetDirection(Int_t src, Int_t dst) const;
    76     Int_t  GetNeighbor(Int_t idx, Int_t dir) const;
    7765    Bool_t CheckMoves();
    7866
Note: See TracChangeset for help on using the changeset viewer.