summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/standard.cpp141
1 files changed, 69 insertions, 72 deletions
diff --git a/server/standard.cpp b/server/standard.cpp
index d74ad17..a35a358 100644
--- a/server/standard.cpp
+++ b/server/standard.cpp
@@ -77,7 +77,7 @@ State& Standard::round_update() {
// Construct the discard action that the player can do.
Action discard;
discard.type = Action::Discard;
- discard.player = current_player;
+ //discard.player = current_player;
game_state.possible_actions.push_back(discard);
@@ -117,19 +117,19 @@ State& Standard::round_update() {
if(tile_match_ids[1]) {
Action temp_action;
- temp_action.player = array_counter;
- temp_action.target.push_back(tile_match_ids[0]);
- temp_action.target.push_back(tile_match_ids[1]);
+ //temp_action.player = array_counter;
+ //temp_action.target.push_back(tile_match_ids[0]);
+ //temp_action.target.push_back(tile_match_ids[1]);
temp_action.type = Action::Pon;
game_state.possible_actions.push_back(temp_action);
}
if(tile_match_ids[2]) {
Action temp_action;
- temp_action.player = array_counter;
- temp_action.target.push_back(tile_match_ids[0]);
- temp_action.target.push_back(tile_match_ids[1]);
- temp_action.target.push_back(tile_match_ids[2]);
+ //temp_action.player = array_counter;
+ //temp_action.target.push_back(tile_match_ids[0]);
+ //temp_action.target.push_back(tile_match_ids[1]);
+ //temp_action.target.push_back(tile_match_ids[2]);
temp_action.type = Action::Kan;
game_state.possible_actions.push_back(temp_action);
}
@@ -184,15 +184,15 @@ State& Standard::round_update() {
chi = true;
}
if(chi) {
- temp_action.player = temp_next_player;
- temp_action.target.push_back(tile_2u_id);
- temp_action.target.push_back(tile_1u_id);
+ //temp_action.player = temp_next_player;
+ //temp_action.target.push_back(tile_2u_id);
+ //temp_action.target.push_back(tile_1u_id);
temp_action.type = Action::Chi;
game_state.possible_actions.push_back(temp_action);
#ifdef DEBUG
- time_t current_time = std::time(0);
- std::cout << std::ctime(&current_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl;
+ //time_t current_time = std::time(0);
+ //std::cout << std::ctime(&current_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl;
#endif
}
@@ -210,16 +210,16 @@ State& Standard::round_update() {
chi = true;
}
if(chi) {
- temp_action.player = temp_next_player;
- temp_action.target.push_back(tile_1u_id);
- temp_action.target.push_back(tile_1o_id);
+ //temp_action.player = temp_next_player;
+ //temp_action.target.push_back(tile_1u_id);
+ //temp_action.target.push_back(tile_1o_id);
temp_action.type = Action::Chi;
game_state.possible_actions.push_back(temp_action);
#ifdef DEBUG
- time_t current_time = std::time(0);
- std::cout << std::ctime(&current_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl;
+ //time_t current_time = std::time(0);
+ //std::cout << std::ctime(&current_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl;
#endif
}
@@ -237,16 +237,16 @@ State& Standard::round_update() {
chi = true;
}
if(chi) {
- temp_action.player = temp_next_player;
- temp_action.target.push_back(tile_1o_id);
- temp_action.target.push_back(tile_2o_id);
+ //temp_action.player = temp_next_player;
+ //temp_action.target.push_back(tile_1o_id);
+ //temp_action.target.push_back(tile_2o_id);
temp_action.type = Action::Chi;
game_state.possible_actions.push_back(temp_action);
#ifdef DEBUG
- time_t current_time = std::time(0);
- std::cout << std::ctime(&current_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl;
+ //time_t current_time = std::time(0);
+ //std::cout << std::ctime(&current_time) << " Player: " << temp_action.player << " Can do action: " << temp_action.type << " On target: " << temp_action.target[0] << std::endl;
#endif
}
@@ -257,37 +257,37 @@ State& Standard::round_update() {
// Not implemented yet
for(Actions::iterator it = game_state.possible_actions.begin(); it != game_state.possible_actions.end(); ++it) {
- smart = smart | (0x0001 << it->player);
+ //smart = smart | (0x0001 << it->player);
}
if(smart & 1) {
Action pass;
pass.type = Action::Pass;
- pass.player = 0;
+ //pass.player = 0;
game_state.possible_actions.push_back(pass);
}
if(smart & 2) {
Action pass;
pass.type = Action::Pass;
- pass.player = 1;
+ //pass.player = 1;
game_state.possible_actions.push_back(pass);
}
if(smart & 4) {
Action pass;
pass.type = Action::Pass;
- pass.player = 2;
+ //pass.player = 2;
game_state.possible_actions.push_back(pass);
}
if(smart & 8) {
Action pass;
pass.type = Action::Pass;
- pass.player = 3;
+ //pass.player = 3;
game_state.possible_actions.push_back(pass);
}
}
for(Actions::iterator it = game_state.possible_actions.begin(); it != game_state.possible_actions.end(); ++it) {
- smart = smart | (1 << it->player);
+ //smart = smart | (1 << it->player);
}
if(smart & 1) {
@@ -313,8 +313,8 @@ State& Standard::round_update() {
bool Standard::round_action(Action action) {
#ifdef DEBUG
- time_t current_time = std::time(0);
- std::cout << std::ctime(&current_time) << " Player: " << action.player << " Did action: " << action.type << " On target: " << action.target[0] << std::endl;
+ //time_t current_time = std::time(0);
+ //std::cout << std::ctime(&current_time) << " Player: " << action.player << " Did action: " << action.type << " On target: " << action.target[0] << std::endl;
#endif
@@ -329,9 +329,9 @@ bool Standard::round_action(Action action) {
bool found_action = false;
for(Actions::iterator it = game_state.possible_actions.begin(); it != game_state.possible_actions.end(); ++it) {
- if(it->player == action.player && it->type == action.type) {
- found_action = true;
- }
+ //if(it->player == action.player && it->type == action.type) {
+ // found_action = true;
+ //}
}
if(!found_action) {
@@ -345,9 +345,9 @@ bool Standard::round_action(Action action) {
} break;
case Action::Discard: {
- Tile discarded_tile = game_state.players[action.player].hand[action.target[0]];
- game_state.players[action.player].pond.push_back(discarded_tile);
- game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + action.target[0]);
+ //Tile discarded_tile = game_state.players[action.player].hand[action.target[0]];
+ //game_state.players[action.player].pond.push_back(discarded_tile);
+ //game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + action.target[0]);
} break;
@@ -395,9 +395,9 @@ bool Standard::round_action(Action action) {
std::vector<int> positions;
int position = 0;
for(Actions::iterator it = game_state.possible_actions.begin(); it != game_state.possible_actions.end(); ++it) {
- if (it->player == action.player) {
- positions.push_back(position);
- }
+ //if (it->player == action.player) {
+ // positions.push_back(position);
+ //}
position++;
}
if (!positions.empty()) {
@@ -417,20 +417,19 @@ bool Standard::round_action(Action action) {
case Action::Chi: {
Tile left_tile = game_state.players[current_player].pond.back();
left_tile.rotated = true;
- game_state.players[action.player].open.push_back(left_tile);
+ //game_state.players[action.player].open.push_back(left_tile);
- int count = 0;
- for(std::vector<int>::iterator it = most_value_action.target.begin(); it != most_value_action.target.end(); ++it) {
- Tile target_tile = game_state.players[action.player].hand[(*it) - count];
- game_state.players[action.player].open.push_back(target_tile);
- game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + (*it) - count);
-
- count++;
- }
+ //int count = 0;
+ //for(std::vector<int>::iterator it = most_value_action.target.begin(); it != most_value_action.target.end(); ++it) {
+ // Tile target_tile = game_state.players[action.player].hand[(*it) - count];
+ // game_state.players[action.player].open.push_back(target_tile);
+ // game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + (*it) - count);
+ // count++;
+ //}
Action discard;
discard.type = Action::Discard;
- discard.player = action.player;
+ //discard.player = action.player;
game_state.possible_actions.push_back(discard);
draw_phase = false;
@@ -440,52 +439,50 @@ bool Standard::round_action(Action action) {
case Action::Pon: {
Tile left_tile = game_state.players[current_player].pond.back();
left_tile.rotated = true;
- game_state.players[action.player].open.push_back(left_tile);
+ //game_state.players[action.player].open.push_back(left_tile);
- int count = 0;
- for(std::vector<int>::iterator it = most_value_action.target.begin(); it != most_value_action.target.end(); ++it) {
- Tile target_tile = game_state.players[action.player].hand[(*it) - count];
- game_state.players[action.player].open.push_back(target_tile);
- game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + (*it) - count);
-
- count++;
- }
+ //int count = 0;
+ //for(std::vector<int>::iterator it = most_value_action.target.begin(); it != most_value_action.target.end(); ++it) {
+ // Tile target_tile = game_state.players[action.player].hand[(*it) - count];
+ // game_state.players[action.player].open.push_back(target_tile);
+ // game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + (*it) - count);
+ // count++;
+ //}
Action discard;
discard.type = Action::Discard;
- discard.player = action.player;
+ //discard.player = action.player;
game_state.possible_actions.push_back(discard);
draw_phase = false;//player must discard extra tile
//Play continues to the right
- current_player = action.player;
+ //current_player = action.player;
} break;
case Action::Kan: {
Tile left_tile = game_state.players[current_player].pond.back();
left_tile.rotated = true;
- game_state.players[action.player].open.push_back(left_tile);
+ //game_state.players[action.player].open.push_back(left_tile);
- int count = 0;
- for(std::vector<int>::iterator it = most_value_action.target.begin(); it != most_value_action.target.end(); ++it) {
- Tile target_tile = game_state.players[action.player].hand[(*it) - count];
- game_state.players[action.player].open.push_back(target_tile);
- game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + (*it) - count);
-
- count++;
- }
+ //int count = 0;
+ //for(std::vector<int>::iterator it = most_value_action.target.begin(); it != most_value_action.target.end(); ++it) {
+ // Tile target_tile = game_state.players[action.player].hand[(*it) - count];
+ // game_state.players[action.player].open.push_back(target_tile);
+ // game_state.players[action.player].hand.erase(game_state.players[action.player].hand.begin() + (*it) - count);
+ // count++;
+ //}
Action discard;
discard.type = Action::Discard;
- discard.player = action.player;
+ //discard.player = action.player;
game_state.possible_actions.push_back(discard);
draw_phase = false;//player must discard extra tile
//Play continues to the right
- current_player = action.player;
+ //current_player = action.player;
} break;