-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauction.cpp
More file actions
62 lines (47 loc) · 1.29 KB
/
auction.cpp
File metadata and controls
62 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "auction.h"
Auction::Auction(std::vector<Agent>& agents, std::vector<int> agentsInAuction, Treasure& treasure) :
m_agents(agents), m_agentsInAuction(agentsInAuction), m_treasure(treasure)
//m_inAuction(std::vector<bool>(std::vector<bool>(agents.size(), true)))
{
}
void Auction::giveWinTo(int agent_index)
{
// give treasure to winner
m_agents[agent_index].m_treasureCount += m_treasure.value;
// change likeableness values for all agent involved in auction
for(int i: m_agentsInAuction)
{
if(i != agent_index)
{
m_agents[i].m_likableness[agent_index] -= m_askingPrice;
}
m_agents[i].leaveAuction();
}
}
void Auction::step()
{
m_askingPrice += 10;
int winner = rand() % m_agentsInAuction.size();
giveWinTo(m_agentsInAuction[winner]);
m_isOver = true;
return;
//TODO finish implementing auction step
m_askingPrice += 5;
std::vector<int> agentsStayingIn;
for(int i: m_agentsInAuction)
{
bool isIn = m_agents[i].bid(m_askingPrice, m_agentsInAuction);
if(isIn)
{
agentsStayingIn.push_back(i);
}
}
if(agentsStayingIn.size() == 1)
{
// winner
}
else if(agentsStayingIn.size() == 0)
{
// tie breaker
}
}