void TestIterativeValue(int depth) { // setup book and cache CCache acache(2); cache = &acache; const int nEmpty = 22; CBook* oldBook = book; book = NULL; InitializeCache(); SetBookHeights(nEmpty); mpcs = CMPCStats::GetMPCStats('J','A',5); // testing const COsGame osGame = LoadTestGames().at(0); const CQPosition testPosition = PositionFromEmpties(osGame, nEmpty); std::vector<CMoveValue> mvs = createMoves(testPosition); Pos2 pos2; pos2.Initialize(testPosition.BitBoard(), testPosition.BlackMove()); u4 nValued=0; std::vector<CMoveValue> mvsEvaluated; ValueMulti(pos2, depth, -kInfinity, kInfinity, 4, 1, mvs, false, false, mvsEvaluated, nValued); // cout << " nValued = " << nValued << "\n"; // cout << " mvsEvaluated = \n"; // for (int i=0; i<mvsEvaluated.size(); i++) { // CMoveValue mv = mvsEvaluated.at(i); // cout << "new CMoveValue(" << mv.move << "," << mv.value << "),\n"; // } // cout << "\n"; // tear down book and cache book = oldBook; cache = NULL; }
/** \brief callback notified when netif_vdev_t has an event to report * * - TODO this function is ugly - clean it up */ bool router_peer_t::neoip_netif_vdev_cb(void *cb_userptr, netif_vdev_t &cb_netif_vdev , uint16_t ethertype, pkt_t &pkt) throw() { // log to debug KLOG_ERR("recevied ethertype=0x" << std::hex << ethertype << std::dec << " pkt=" << pkt ); // if the ethertype is NOT ip4, discard the packet if( ethertype != netif_vdev_t::TYPE_IP4 ) return true; // try to find the destination ip address in the address cache const router_acache_item_t * acache_item; acache_item = acache().find_by_remote_iaddr( ippkt_util_t::get_dst_addr(pkt) ); // if the destination ip address is found in acache, launch a router_itor_t on this remote_peerid if( acache_item ){ const router_name_t & remote_dnsname = acache_item->remote_dnsname(); router_peerid_t remote_peerid = dnsname2peerid(remote_dnsname); router_itor_t * router_itor; router_err_t router_err; // sanity check - remote_peerid MUST have been found // - in fact i dunno what to do here, if this case is possible // - so i do DBG_ASSERT() DBG_ASSERT( !remote_peerid.is_null() ); // if a router_itor_t is already running on this remote_peerid, queue the packet router_itor = itor_by_remote_peerid(remote_peerid); if( router_itor ){ // queue the tiggering packet router_itor->queue_inner_pkt(ethertype, pkt); // return tokeep return true; } // if the remote_peerid is in the itor_negcache, discard the packet without replying icmp // - TODO this is for the mobility part // - dont report a itor faillure immdiatly // - leave it some time to let the new connection to be established // - the algo is 'take the last time an established connection with this destination // existed. if it is more than Xsec. then reply icmp" // - i think it is possible by storing the last_seen_date in the router_acache if( itor_negcache.contain(remote_peerid) ){ // build the icmp packet to reply pkt_t icmp_pkt= ippkt_util_t::build_icmp4_pkt(ippkt_util_t::get_dst_addr(pkt) , ippkt_util_t::get_src_addr(pkt) , ICMP_DEST_UNREACH, ICMP_NET_UNREACH, 0, pkt.to_datum()); // send the icmp packet catchall_netif->send_pkt(netif_vdev_t::TYPE_IP4, icmp_pkt); return true; } // launch a new router_itor_t based on this remote_peerid router_itor = nipmem_new router_itor_t(this); router_err = router_itor->start(remote_peerid, remote_dnsname); // if the router_itor_t start() succeed, return tokeep now if( router_err.succeed() ){ // queue the tiggering packet router_itor->queue_inner_pkt(ethertype, pkt); // return tokeep return true; } // if the router_itor_t start() failed, delete it and fall thru to reply an icmp nipmem_zdelete router_itor; } // build the icmp packet to reply pkt_t icmp_pkt= ippkt_util_t::build_icmp4_pkt(ippkt_util_t::get_dst_addr(pkt) , ippkt_util_t::get_src_addr(pkt) , ICMP_DEST_UNREACH, ICMP_NET_UNREACH, 0, pkt.to_datum()); // send the icmp packet catchall_netif->send_pkt(netif_vdev_t::TYPE_IP4, icmp_pkt); // return 'tokeep' return true; }