示例#1
0
 private bool IsStillBestTile(SearchTile bestTile, float highestBid, SearchTile tile, float gj)
 {
     if (bestTile == null)
     {
         return(false);
     }
     if (gj >= highestBid)
     {
         if (tile.GetState() == SearchTile.TileState.OPEN)
         {
             return(false);
         }
         else
         {
             if ((new SearchTileBid(this.myId, gj)).IsBetterThan(tile.GetHighestBid()))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
示例#2
0
    public void Update()
    {
        ArrayList toRm = new ArrayList();

        foreach (SearchTile tile in tilesInAuction)
        {
            tile.Update();
            if (tile.GetState() == SearchTile.TileState.CLAIMED)
            {
                toRm.Add(tile);
            }
        }

        foreach (SearchTile tile in toRm)
        {
            this.MoveTile(tile, this.tilesInAuction, this.claimedTiles);
        }

        toRm.Clear();

        foreach (SearchTile tile in claimedTiles)
        {
            tile.Update();
            if (tile.GetState() == SearchTile.TileState.OPEN)
            {
                toRm.Add(tile);
            }
        }

        foreach (SearchTile tile in toRm)
        {
//			Debug.Log ("A tile has timed out");
            this.MoveTile(tile, this.claimedTiles, this.openTiles);
            if (tile.GetWinnerAgentId() == this.kb.agent.ID)
            {
                WorldStateManager.MarkTileAsOpen(tile);
                this.ResetCandidateAndGoalTile();
//				Debug.Log ("I'm giving up my bid");
            }

            tile.acceptedBid = null;
        }


        /* BIDDING LOGIC HERE */
        if (this.kb.GoalTile == null)
        {
            // If there is no tile bidded on yet
            if (this.canidateTile == null)
            {
                this.SendBidForNextBestTile();
            }
            else
            {
                // If the auction has ended for the tile I bid on
                if (canidateTile.GetState() == SearchTile.TileState.CLAIMED)
                {
                    //Debug.Log("AUCTION END");
                    // Check if I was the winner
                    if (canidateTile.GetWinnerAgentId() == this.kb.agent.ID)
                    {
                        this.sender.SendClaimed(canidateTile.id, canidateTile.acceptedBid.agentId, canidateTile.acceptedBid.value);
//						Debug.Log("Agent " + this.kb.agent.ID + " WON tileid = " + canidateTile.id + " bid=" + this.kb.TempGoal.acceptedBid.value);
                        this.kb.SetGoalTile(this.kb.TempGoal);
                        this.ResetCandidateTile();
                        WorldStateManager.MarkTileAsClaimed(this.kb.GoalTile);
                    }
                    else                         // Otherwise, bid on a new tile
                    {
                        this.SendBidForNextBestTile();
                    }
                }
                else if (canidateTile.GetState() == SearchTile.TileState.SEARCHED)
                {
                    this.SendBidForNextBestTile();
                }
            }
        }
        else
        {
            //Debug.Log("I have a goal!");
        }
    }