Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider ab1f13ab rédigé par Timon DESCHAMPS's avatar Timon DESCHAMPS
Parcourir les fichiers

70% rule

parent 20520545
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#include "CStats.h"
\ No newline at end of file
#pragma once
#include <map>
#include <array>
class CStats {
public:
std::map<unsigned int, std::map<unsigned int, unsigned int>> possibilites = { {1, {{1, 1},{2, 1},{3, 1},{4, 1},{5, 1},{6, 1}}},{2, {{1, 0},{2, 1},{3, 2},{4, 3},{5, 4},{6, 5},{7, 6},{8, 5},{9, 4},{10, 3},{11, 2},{12, 1}}},{3, {{1, 0},{2, 0},{3, 1},{4, 3},{5, 6},{6, 10},{7, 15},{8, 21},{9, 25},{10, 27},{11, 27},{12, 25},{13, 21},{14, 15},{15, 10},{16, 6},{17, 3},{18, 1}}},{4, {{1, 0},{2, 0},{3, 0},{4, 1},{5, 4},{6, 10},{7, 20},{8, 35},{9, 56},{10, 80},{11, 104},{12, 125},{13, 140},{14, 146},{15, 140},{16, 125},{17, 104},{18, 80},{19, 56},{20, 35},{21, 20},{22, 10},{23, 4},{24, 1}}},{5, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 1},{6, 5},{7, 15},{8, 35},{9, 70},{10, 126},{11, 205},{12, 305},{13, 420},{14, 540},{15, 651},{16, 735},{17, 780},{18, 780},{19, 735},{20, 651},{21, 540},{22, 420},{23, 305},{24, 205},{25, 126},{26, 70},{27, 35},{28, 15},{29, 5},{30, 1}}},{6, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 0},{6, 1},{7, 6},{8, 21},{9, 56},{10, 126},{11, 252},{12, 456},{13, 756},{14, 1161},{15, 1666},{16, 2247},{17, 2856},{18, 3431},{19, 3906},{20, 4221},{21, 4332},{22, 4221},{23, 3906},{24, 3431},{25, 2856},{26, 2247},{27, 1666},{28, 1161},{29, 756},{30, 456},{31, 252},{32, 126},{33, 56},{34, 21},{35, 6},{36, 1}}},{7, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 0},{6, 0},{7, 1},{8, 7},{9, 28},{10, 84},{11, 210},{12, 462},{13, 917},{14, 1667},{15, 2807},{16, 4417},{17, 6538},{18, 9142},{19, 12117},{20, 15267},{21, 18327},{22, 20993},{23, 22967},{24, 24017},{25, 24017},{26, 22967},{27, 20993},{28, 18327},{29, 15267},{30, 12117},{31, 9142},{32, 6538},{33, 4417},{34, 2807},{35, 1667},{36, 917},{37, 462},{38, 210},{39, 84},{40, 28},{41, 7},{42, 1}}},{8, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 0},{6, 0},{7, 0},{8, 1},{9, 8},{10, 36},{11, 120},{12, 330},{13, 792},{14, 1708},{15, 3368},{16, 6147},{17, 10480},{18, 16808},{19, 25488},{20, 36688},{21, 50288},{22, 65808},{23, 82384},{24, 98813},{25, 113688},{26, 125588},{27, 133288},{28, 135954},{29, 133288},{30, 125588},{31, 113688},{32, 98813},{33, 82384},{34, 65808},{35, 50288},{36, 36688},{37, 25488},{38, 16808},{39, 10480},{40, 6147},{41, 3368},{42, 1708},{43, 792},{44, 330},{45, 120},{46, 36},{47, 8},{48, 1}}} };
std::array<std::array<double, 9>, 9> probabilites = { {0, 1, 2, 3, 4, 5, 6, 7, 8}, {1, 0.416667, 0.0925926, 0.0115741, 0.000771605, 2.14335e-05, 0, 0, 0}, {2, 0.837963, 0.443673, 0.152006, 0.0358796, 0.00610497, 0.000766247, 7.09488e-05, 4.72992e-06}, {3, 0.972994, 0.778549, 0.453575, 0.191701, 0.0607127, 0.0148786, 0.00288998, 0.000451922}, {4, 0.997299, 0.939236, 0.742831, 0.459528, 0.220442, 0.0834228, 0.0254497, 0.00637948}, {5, 0.99985, 0.98794, 0.909347, 0.718078, 0.463654, 0.242449, 0.103626, 0.0367419}, {6, 0.999996, 0.998217, 0.9753, 0.883953, 0.699616, 0.466731, 0.259984, 0.121507}, {7, 1, 0.999801, 0.994663, 0.961536, 0.862377, 0.685165, 0.469139, 0.274376}, {8, 1, 0.999983, 0.999069, 0.989534, 0.947731, 0.843874, 0.673456, 0.471091} };
};
\ No newline at end of file
......@@ -6,7 +6,9 @@
StrategyBase::StrategyBase(unsigned int id, unsigned int nbPlayer, const SMap* map) :
Id(id),
NbPlayer(nbPlayer),
Map(CMap(map))
Map(CMap(map)),
possibilites({ {1, {{1, 1},{2, 1},{3, 1},{4, 1},{5, 1},{6, 1}}},{2, {{1, 0},{2, 1},{3, 2},{4, 3},{5, 4},{6, 5},{7, 6},{8, 5},{9, 4},{10, 3},{11, 2},{12, 1}}},{3, {{1, 0},{2, 0},{3, 1},{4, 3},{5, 6},{6, 10},{7, 15},{8, 21},{9, 25},{10, 27},{11, 27},{12, 25},{13, 21},{14, 15},{15, 10},{16, 6},{17, 3},{18, 1}}},{4, {{1, 0},{2, 0},{3, 0},{4, 1},{5, 4},{6, 10},{7, 20},{8, 35},{9, 56},{10, 80},{11, 104},{12, 125},{13, 140},{14, 146},{15, 140},{16, 125},{17, 104},{18, 80},{19, 56},{20, 35},{21, 20},{22, 10},{23, 4},{24, 1}}},{5, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 1},{6, 5},{7, 15},{8, 35},{9, 70},{10, 126},{11, 205},{12, 305},{13, 420},{14, 540},{15, 651},{16, 735},{17, 780},{18, 780},{19, 735},{20, 651},{21, 540},{22, 420},{23, 305},{24, 205},{25, 126},{26, 70},{27, 35},{28, 15},{29, 5},{30, 1}}},{6, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 0},{6, 1},{7, 6},{8, 21},{9, 56},{10, 126},{11, 252},{12, 456},{13, 756},{14, 1161},{15, 1666},{16, 2247},{17, 2856},{18, 3431},{19, 3906},{20, 4221},{21, 4332},{22, 4221},{23, 3906},{24, 3431},{25, 2856},{26, 2247},{27, 1666},{28, 1161},{29, 756},{30, 456},{31, 252},{32, 126},{33, 56},{34, 21},{35, 6},{36, 1}}},{7, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 0},{6, 0},{7, 1},{8, 7},{9, 28},{10, 84},{11, 210},{12, 462},{13, 917},{14, 1667},{15, 2807},{16, 4417},{17, 6538},{18, 9142},{19, 12117},{20, 15267},{21, 18327},{22, 20993},{23, 22967},{24, 24017},{25, 24017},{26, 22967},{27, 20993},{28, 18327},{29, 15267},{30, 12117},{31, 9142},{32, 6538},{33, 4417},{34, 2807},{35, 1667},{36, 917},{37, 462},{38, 210},{39, 84},{40, 28},{41, 7},{42, 1}}},{8, {{1, 0},{2, 0},{3, 0},{4, 0},{5, 0},{6, 0},{7, 0},{8, 1},{9, 8},{10, 36},{11, 120},{12, 330},{13, 792},{14, 1708},{15, 3368},{16, 6147},{17, 10480},{18, 16808},{19, 25488},{20, 36688},{21, 50288},{22, 65808},{23, 82384},{24, 98813},{25, 113688},{26, 125588},{27, 133288},{28, 135954},{29, 133288},{30, 125588},{31, 113688},{32, 98813},{33, 82384},{34, 65808},{35, 50288},{36, 36688},{37, 25488},{38, 16808},{39, 10480},{40, 6147},{41, 3368},{42, 1708},{43, 792},{44, 330},{45, 120},{46, 36},{47, 8},{48, 1}}} }),
probabilites({ { {0, 1, 2, 3, 4, 5, 6, 7, 8}, {1, 0.416667, 0.0925926, 0.0115741, 0.000771605, 2.14335e-05, 0, 0, 0}, {2, 0.837963, 0.443673, 0.152006, 0.0358796, 0.00610497, 0.000766247, 7.09488e-05, 4.72992e-06}, {3, 0.972994, 0.778549, 0.453575, 0.191701, 0.0607127, 0.0148786, 0.00288998, 0.000451922}, {4, 0.997299, 0.939236, 0.742831, 0.459528, 0.220442, 0.0834228, 0.0254497, 0.00637948}, {5, 0.99985, 0.98794, 0.909347, 0.718078, 0.463654, 0.242449, 0.103626, 0.0367419}, {6, 0.999996, 0.998217, 0.9753, 0.883953, 0.699616, 0.466731, 0.259984, 0.121507}, {7, 1, 0.999801, 0.994663, 0.961536, 0.862377, 0.685165, 0.469139, 0.274376}, {8, 1, 0.999983, 0.999069, 0.989534, 0.947731, 0.843874, 0.673456, 0.471091} } })
{
}
......@@ -83,7 +85,7 @@ bool StrategyBase::PlayTurn(unsigned int gameTurn, const SGameState* state, STur
for (unsigned int numCell = 0; numCell < Map.nbCells; numCell++) {
if (Map.cells[numCell]->owner == Id) {
for (unsigned int numNeighbor = 0; numNeighbor < Map.cells[numCell]->nbNeighbors; numNeighbor++) {
if (Map.cells[numCell]->nbDices > Map.cells[numCell]->neighbors[numNeighbor]->nbDices and Map.cells[numCell]->neighbors[numNeighbor]->owner != Id) {
if (probabilites[Map.cells[numCell]->nbDices][Map.cells[numCell]->neighbors[numNeighbor]->nbDices] > 0.7 and Map.cells[numCell]->neighbors[numNeighbor]->owner != Id) {
//std::cout << "StratBase" << std::endl;
turn->cellFrom = numCell;
turn->cellTo = Map.cells[numCell]->neighbors[numNeighbor]->id;
......
......@@ -2,6 +2,8 @@
#include "../../Commun/IStrategyLib.h"
#include <vector>
#include <array>
#include <map>
#include "CMap.h"
class StrategyBase
......@@ -18,6 +20,9 @@ public:
void updateOwnedCells();
std::map<unsigned int, std::map<unsigned int, unsigned int>> possibilites;
std::array<std::array<double, 9>, 9> probabilites;
protected:
const unsigned int Id;
const unsigned int NbPlayer;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter