亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? staticeval.java

?? Eclipse高級(jí)編程3源碼(書本源碼)
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/***
 * Hex-7
 *  Version 2.0
 * www.mazeworks.com
 *
 *  Copyright (c) 2002 David Herzog
 *  All Rights Reserved.
 */
package com.bdaum.Hex.game;

/******** STATIC EVAL ********
   static evaluator function - produces an integer value for
   any given board position for either side
*/   
public final class StaticEval {
   static final int WIN_VALUE=100000,
                    SW=1, SE=2, E=3, NE=4, NW=5, W=6, 
                    SW_B=7, S_B=8, SE_B=9, NE_B=10, N_B=11, NW_B=12 ;
   // board areas
   static final int[][] WhiteAreas = { {3,4,4,4,4,4,3},
                                       {3,2,2,2,2,2,3},
                                       {3,2,1,1,1,2,3},
                                       {3,2,1,0,1,2,3},
                                       {3,2,1,1,1,2,3},
                                       {3,2,2,2,2,2,3},
                                       {3,4,4,4,4,4,3} },
                        BlackAreas = { {3,3,3,3,3,3,3},
                                       {4,2,2,2,2,2,4},
                                       {4,2,1,1,1,2,4},
                                       {4,2,1,0,1,2,4},
                                       {4,2,1,1,1,2,4},
                                       {4,2,2,2,2,2,4},
                                       {3,3,3,3,3,3,3} } ;
   private boolean isFullChainWhite, isFullChainBlack ;
   private int stack[]=new int[25], stackPtr=0 ;
   // weights 
   private int A0x, A1x, A2x, A3x, A4x, B1x, B2x, L0x, L1x, E1x, E2x, C1x, C2x, C4x, C5x, 
               chainBaseX, chainPctX ;
   // parametric function values
   private int wA0, wA1, wA2, wA3, wA4, bA0, bA1, bA2, bA3, bA4,
               w2Bridge, b2Bridge, w1Bridge, b1Bridge, w1Link, b1Link, w0Link, b0Link,
               w2Edge, w1Edge, b2Edge, b1Edge,
               wChainLink, wChainBridge, wLinkPct, bChainLink, bChainBridge, bLinkPct,
               w5Chain, w4Chain, w2Chain, w1Chain, b5Chain, b4Chain, b2Chain, b1Chain,
               wVal, bVal ;
   private Board bd ;
   private Game game ;

   // constructor
   public StaticEval(Board bd,Game game) { 
      this.bd = bd; 
      this.game = game ;
   }
   // initializes weights and function values
   private void initValues() {
      A0x = 8 ; A1x = 4 ; A2x = 2 ; A3x = 1 ; A4x = 0 ;
      B2x = 8 ; B1x = 4 ; L1x = 3 ; L0x = 0 ; E2x = 4 ; E1x = 2 ;
      C5x = 500 ; C4x = 240 ; C2x = 175 ; C1x = 110 ;

      chainBaseX = 1000 ; chainPctX = 90 ;
      isFullChainWhite = isFullChainBlack = false ;
      wLinkPct = bLinkPct = 0 ;

      wA0 = wA1 = wA2 = wA3 = wA4 = 0 ; 
      bA0 = bA1 = bA2 = bA3 = bA4 = 0 ; 
      w2Bridge = b2Bridge = w1Bridge = b1Bridge = 0 ;
      w1Link = b1Link = w0Link = b0Link = 0 ;
      w2Edge = b2Edge = w1Edge = b1Edge = 0 ;
      wChainLink = wChainBridge = 0 ;
      bChainLink = bChainBridge = 0 ;
      w5Chain = w4Chain = w2Chain = w1Chain = 0 ;
      b5Chain = b4Chain = b2Chain = b1Chain = 0 ;
   }
   // main evaluation method
   int eval(int evalColor) { 

      // first see if it's all over
      if (bd.isWin(evalColor)) return WIN_VALUE ;
      else if (bd.isWin(game.getOtherColor(evalColor))) return -WIN_VALUE ;
      // no win, start eval
      initValues() ;
      // calculate value of chains
      calcChains() ;
      // calculate value for each hex
      calcHex() ;
      // now add everything up
      wVal = (A0x*wA0)+(A1x*wA1)+(A2x*wA2)+(A3x*wA3)+(A4x*wA4) ;
      wVal += (B2x*w2Bridge)+(B1x*w1Bridge)+(L1x*w1Link)+(L0x*w0Link)+
              (E2x*w2Edge)+(E1x*w1Edge) ;
      wVal += (C5x*w5Chain)+(C4x*w4Chain)+(C2x*w2Chain)+(C1x*w1Chain) ;
      if (isFullChainWhite) wVal += chainBaseX + (chainPctX * wLinkPct) ; 

      bVal = (A0x*bA0)+(A1x*bA1)+(A2x*bA2)+(A3x*bA3)+(A4x*bA4) ;
      bVal += (B2x*b2Bridge)+(B1x*b1Bridge)+(L1x*b1Link)+(L0x*b0Link)+
              (E2x*b2Edge)+(E1x*b1Edge) ;
      bVal += (C5x*b5Chain)+(C4x*b4Chain)+(C2x*b2Chain)+(C1x*b1Chain) ;
      if (isFullChainBlack) bVal += chainBaseX + (chainPctX * bLinkPct) ; 
      // and send it back, negamax-style
      return (evalColor==Game.WHITE)? 
         (int)(wVal - bVal) : (int)(bVal - wVal) ;
   }
   // look for chains
   private void calcChains() {

      bd.clearVisited() ;
      // White
      for (int j=0; j<4; j++) {
         for (int i=0; i<Game.SIZE; i++) {
         
            if ((bd.isWhite(i,j))&&(!bd.isVisited(i,j))) {
               stackPtr = wChainLink = wChainBridge = 0 ;
               // first check for valid start
               if (isOpen(i,j,NE)) {
                  bd.setVisited(i,j,true) ;
                  switch (searchChainWhite(i,j)) {
                     // full chain
                     case 8: if (j==0) wChainLink++ ;
                             else wChainBridge++ ;
                             wLinkPct = (int)( 100*(((float)wChainLink/(wChainLink + wChainBridge))) ) ;
                             isFullChainWhite = true ;
                             return ;
                     case 5: w5Chain++ ; break ;
                     case 4: w4Chain++ ; break ;
                     case 2: w2Chain++ ; break ;
                     case 1: if ( ((i==4)||(i==5))&&(j==3)&&(bd.isWhite(4,4)) ) 
                                w1Chain++ ;
                             else if ( (i==2)&&(j==2)&&((bd.isWhite(2,3))||(bd.isWhite(1,3))) ) 
                                w1Chain++ ;
                  }
               }
            }
         }
      }
      // Black
      for (int i=0; i<4; i++) {
         for (int j=0; j<Game.SIZE; j++) {
         
            if ((bd.isBlack(i,j))&&(!bd.isVisited(i,j))) {
               stackPtr = bChainLink = bChainBridge = 0 ;
               // first check for valid start
               if (isOpen(i,j,W)) {
                  bd.setVisited(i,j,true) ;
                  switch (searchChainBlack(i,j)) {
                     // full chain
                     case 8: if (i==0) bChainLink++ ;
                             else bChainBridge++ ;
                             bLinkPct = (int)( 100*(((float)bChainLink/(bChainLink + bChainBridge))) ) ;
                             isFullChainBlack = true ;
                             return ;
                     case 5: b5Chain++ ; break ;
                     case 4: b4Chain++ ; break ;
                     case 2: b2Chain++ ; break ;
                     case 1: if ( ((j==4)||(j==5))&&(i==3)&&(bd.isBlack(4,4)) ) 
                                b1Chain++ ;
                             else if ( (i==2)&&(j==2)&&((bd.isBlack(3,2))||(bd.isBlack(3,1))) ) 
                                b1Chain++ ;
                  }
               }
            }
         }
      }
   }
   // DFS for chains - returns "absolute" length of chain 
   //    (number of rows or columns it spans including edges)
   private int searchChainWhite(int x,int y) {
      int direction=0, currLength=0, maxLength=0, saveLength=0, localMaxLength=0 ;

      // initialize length counters
      if (y==0) currLength = maxLength = 1 ;
      else if (y==1) currLength = maxLength = 2 ;

      while (true) {
         // look for a link
         direction = bd.scanLinks(x,y,Game.WHITE) ;
         // nope, look for a bridge
         if (direction==0) direction = bd.scanBridges(x,y,Game.WHITE) ;
         if (direction!=0) {
            // found something - bump the counter
            if (direction>6) wChainBridge++ ;
            else wChainLink++ ;
            // make hex current
            stack[stackPtr++] = direction ;
            switch (direction) {
               case SW: y++ ; currLength++ ; break ;
               case SE: x++ ; y++ ; currLength++ ; break ;
               case E : x++ ; break ;
               case NE: y-- ; currLength-- ; break ;
               case NW: x-- ; y-- ; currLength-- ; break ;
               case W : x-- ; break ;
               case SW_B: x--  ; y++  ; currLength++ ; break ;
               case S_B : x++  ; y+=2 ; currLength+=2 ; break ;
               case SE_B: x+=2 ; y++  ; currLength++ ; break ;
               case NE_B: x++  ; y--  ; currLength-- ; break ;
               case N_B : x--  ; y-=2 ; currLength-=2 ; break ;
               case NW_B: x-=2 ; y--  ; currLength-- ; break ;
            }
            // check overall length
            if (currLength>maxLength) maxLength = currLength ;
            // check for local max if we're not moving forward
            else if (localMaxLength<maxLength)
               if ( (y>=3)&&(maxLength>0)&&(isOpen(x,y,SW)) ) localMaxLength = maxLength ;
            // check if we've reached the bottom
            if (y==(Game.SIZE-1)) { wChainLink++ ; return maxLength+1 ; }
            if (y==(Game.SIZE-2)) if (isOpen(x,y,SW)) { wChainBridge++ ; return maxLength+2 ; }
            // nope, look for next link/bridge
            bd.setVisited(x,y,true) ;
         }
         else {
            if (stackPtr==0)
               // all chains visited, return the longest we've found
               return (saveLength>localMaxLength)? saveLength : localMaxLength ;
            // at end of path, check chain and back up
            if (saveLength<currLength)
               if ( (y>=3)&&(currLength>0)&&(isOpen(x,y,SW)) ) saveLength = currLength ;
            direction = stack[--stackPtr] ;
            // decrement the counter
            if (direction>6) wChainBridge-- ;
            else wChainLink-- ;

            switch (direction) {
               case SW: y-- ; currLength-- ; maxLength-- ; break ;
               case SE: x-- ; y-- ; currLength-- ; maxLength-- ; break ;
               case E : x-- ; break ;
               case NE: y++ ; currLength++ ; break ;
               case NW: x++ ; y++ ; currLength++ ; break ;
               case W : x++ ; break ;
               case SW_B: x++  ; y--  ; currLength-- ; maxLength-- ; break ;
               case S_B : x--  ; y-=2 ; currLength-=2 ; maxLength-=2 ; break ;
               case SE_B: x-=2 ; y--  ; currLength-- ; maxLength-- ; break ;
               case NE_B: x--  ; y++  ; currLength++ ; break ;
               case N_B : x++  ; y+=2 ; currLength+=2 ; break ;
               case NW_B: x+=2 ; y++  ; currLength++ ; break ;
            }
         }
      }
   }
   private int searchChainBlack(int x,int y) {
      int direction=0, currLength=0, maxLength=0, saveLength=0, localMaxLength=0 ;

      // initialize length counters
      if (x==0) currLength = maxLength = 1 ;
      else if (x==1) currLength = maxLength = 2 ;

      while (true) {
         // look for a link
         direction = bd.scanLinks(x,y,Game.BLACK) ;
         // nope, look for a bridge
         if (direction==0) direction = bd.scanBridges(x,y,Game.BLACK) ;
         if (direction!=0) {
            // found something - bump the counter
            if (direction>6) bChainBridge++ ;
            else bChainLink++ ;
            // make hex current
            stack[stackPtr++] = direction ;
            switch (direction) {
               case SW: y++ ; break ;
               case SE: x++ ; y++ ; currLength++ ; break ;
               case E : x++ ; currLength++ ; break ;
               case NE: y-- ; break ;
               case NW: x-- ; y-- ; currLength-- ; break ;
               case W : x-- ; currLength-- ; break ;
               case SW_B: x--  ; y++  ; currLength-- ; break ;
               case S_B : x++  ; y+=2 ; currLength++ ; break ;
               case SE_B: x+=2 ; y++  ; currLength+=2 ; break ;
               case NE_B: x++  ; y--  ; currLength++ ; break ;
               case N_B : x--  ; y-=2 ; currLength-- ; break ;
               case NW_B: x-=2 ; y--  ; currLength-=2 ; break ;
            }
            // check overall length
            if (currLength>maxLength) maxLength = currLength ;
            // check for local max if we're not moving forward
            else if (localMaxLength<maxLength)
               if ( (x>=3)&&(maxLength>0)&&(isOpen(x,y,E)) ) localMaxLength = maxLength ;
            // check if we've reached the bottom
            if (x==(Game.SIZE-1)) { bChainLink++ ; return maxLength+1 ; }
            if (x==(Game.SIZE-2)) if (isOpen(x,y,E)) { bChainBridge++ ; return maxLength+2 ; }
            // nope, look for next link/bridge
            bd.setVisited(x,y,true) ;
         }
         else {
            if (stackPtr==0)
               // all chains visited, return the longest we've found
               return (saveLength>localMaxLength)? saveLength : localMaxLength ;
            // at end of path, check chain and back up
            if (saveLength<currLength)
               if ( (x>=3)&&(currLength>0)&&(isOpen(x,y,E)) ) saveLength = currLength ;
            direction = stack[--stackPtr] ;
            // decrement the counter
            if (direction>6) bChainBridge-- ;
            else bChainLink-- ;

            switch (direction) {
               case SW: y-- ; break ;
               case SE: x-- ; y-- ; currLength-- ; maxLength-- ; break ;
               case E : x-- ; currLength-- ; maxLength-- ; break ;
               case NE: y++ ; break ;
               case NW: x++ ; y++ ; currLength++ ; break ;
               case W : x++ ; currLength++ ; break ;

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久影院官网| 依依成人综合视频| 日韩视频在线观看一区二区| 日本道免费精品一区二区三区| 成人毛片视频在线观看| 丁香天五香天堂综合| 国产一区二区三区黄视频| 国产主播一区二区三区| 国产老妇另类xxxxx| 国产一区999| 成人国产精品视频| 97久久超碰精品国产| 99riav久久精品riav| 日本大香伊一区二区三区| 色婷婷av久久久久久久| 欧美日韩视频一区二区| 91精品国产综合久久蜜臀| 日韩视频永久免费| 久久蜜桃一区二区| 亚洲欧美综合在线精品| 亚洲在线视频网站| 美女网站在线免费欧美精品| 国产真实乱对白精彩久久| 成人自拍视频在线| 色一区在线观看| 欧美日韩国产bt| 久久综合狠狠综合久久激情| 欧美国产国产综合| 亚洲综合av网| 久久99在线观看| 成人18视频日本| 欧美在线免费观看亚洲| 欧美一级久久久久久久大片| 久久久九九九九| 一区二区三区在线视频免费观看| 亚洲成人av一区二区| 精品一区二区影视| 成人av免费在线观看| 欧美日韩一区二区在线观看视频| 日韩欧美国产一区在线观看| 国产日产精品1区| 亚洲图片欧美综合| 国产一区二区不卡| 色哟哟国产精品免费观看| 日韩三级电影网址| 国产精品高清亚洲| 日本伊人午夜精品| 成人性生交大合| 欧美精品自拍偷拍| 中文字幕第一页久久| 亚洲电影在线播放| 成人综合在线网站| 51精品久久久久久久蜜臀| 国产欧美综合色| 国产午夜精品在线观看| 欧美一区二区在线视频| 国产精品嫩草99a| 日韩成人伦理电影在线观看| 不卡一区在线观看| 日韩欧美国产综合一区| 亚洲精品国久久99热| 国产在线视视频有精品| 欧美无砖砖区免费| 国产欧美精品一区| 免费在线观看日韩欧美| 99r国产精品| 久久久久久久久一| 日韩电影在线一区二区三区| 99久久国产综合精品女不卡| 精品人伦一区二区色婷婷| 亚洲一区二区三区视频在线播放| 国产自产高清不卡| 这里只有精品99re| 1024成人网| 成人三级在线视频| 精品久久久久久久久久久久久久久久久| 一区二区三区欧美视频| 成人高清视频免费观看| 久久综合九色综合97婷婷女人 | 国产乱子伦视频一区二区三区| 91黄视频在线| 国产精品福利一区二区三区| 国产综合色视频| 欧美一级国产精品| 天天综合色天天| 色8久久精品久久久久久蜜| 国产精品麻豆99久久久久久| 国产一区二区三区最好精华液| 欧美一区二区福利在线| 亚洲不卡在线观看| 欧美色网一区二区| 亚洲另类中文字| 91无套直看片红桃| ㊣最新国产の精品bt伙计久久| 国产成人在线影院 | 婷婷国产v国产偷v亚洲高清| 色婷婷综合激情| 亚洲丝袜美腿综合| 色婷婷久久一区二区三区麻豆| 欧美激情在线一区二区三区| 国产精品夜夜爽| 久久亚洲春色中文字幕久久久| 看电视剧不卡顿的网站| 欧美一区二区三区视频在线| 免费在线欧美视频| 精品欧美一区二区久久 | 欧美一区二区三区婷婷月色| 午夜成人免费视频| 717成人午夜免费福利电影| 视频一区免费在线观看| 91精品午夜视频| 蜜桃视频一区二区| 久久亚洲欧美国产精品乐播| 国产精品18久久久久久久网站| 国产日韩精品久久久| 不卡视频免费播放| 亚洲免费看黄网站| 欧美视频在线一区二区三区 | 久久久91精品国产一区二区三区| 国产综合色在线视频区| 国产欧美日产一区| 91免费版在线| 亚洲高清久久久| 精品乱码亚洲一区二区不卡| 国产在线日韩欧美| 中文字幕亚洲成人| 欧美亚洲综合一区| 麻豆精品一区二区综合av| 久久色中文字幕| 成人网男人的天堂| 亚洲一区二区三区在线看| 欧美一区二区人人喊爽| 国产精品系列在线播放| 亚洲色图欧美激情| 51久久夜色精品国产麻豆| 色哟哟亚洲精品| 色哟哟日韩精品| 日韩不卡一二三区| 日本一区二区在线不卡| 色悠悠亚洲一区二区| 青青草原综合久久大伊人精品优势| 精品日韩一区二区三区免费视频| 国产成人免费在线视频| 亚洲精品国产精华液| 日韩欧美www| av亚洲精华国产精华精华| 亚洲3atv精品一区二区三区| 久久综合九色欧美综合狠狠| 色综合色狠狠天天综合色| 青娱乐精品视频| 中文字幕在线观看不卡视频| 欧美精品一二三| 成人听书哪个软件好| 肉肉av福利一精品导航| 国产日韩av一区二区| 欧美色精品在线视频| 国产精品资源在线| 亚洲国产一二三| 国产精品天美传媒| 欧美久久免费观看| 国产成人av电影在线| 亚洲成人在线网站| 国产精品女主播av| 欧美一级欧美一级在线播放| 99这里只有久久精品视频| 免费成人在线视频观看| 一区二区三区中文免费| 国产日产欧美一区二区视频| 51精品秘密在线观看| 99国产一区二区三精品乱码| 极品少妇一区二区三区精品视频| 一区二区三区 在线观看视频| 久久夜色精品一区| 91精品欧美久久久久久动漫| 色狠狠色噜噜噜综合网| 国产白丝网站精品污在线入口| 日韩制服丝袜先锋影音| 亚洲欧洲制服丝袜| 久久精品这里都是精品| 日韩一区二区三区免费看 | 琪琪一区二区三区| 亚洲伊人伊色伊影伊综合网 | 国产成人在线电影| 日本成人在线视频网站| 一区二区欧美国产| 中文字幕日韩av资源站| 一区二区激情视频| 大胆欧美人体老妇| 精一区二区三区| 全国精品久久少妇| 天堂av在线一区| 亚洲一区在线电影| 亚洲精品成人少妇| 亚洲欧洲日韩av| 国产精品九色蝌蚪自拍| 国产日韩欧美在线一区| 2020国产成人综合网| 日韩欧美高清dvd碟片| 制服丝袜av成人在线看| 欧美日韩dvd在线观看|