Working on more AI kinks.

This commit is contained in:
2021-09-27 21:53:56 -07:00
parent 4ef0766506
commit 25e683b512
11 changed files with 54 additions and 44 deletions

View File

@ -31,7 +31,7 @@ void _pokerGameActionBetOnUpdate(
// Are they human?
player = game->poker.players + game->poker.bet.better;
isHuman = game->poker.bet.better == POKER_PLAYER_HUMAN_INDEX && false;
isHuman = game->poker.bet.better == POKER_PLAYER_HUMAN_INDEX;
// Handle as an AI
if(isHuman) {

View File

@ -12,7 +12,6 @@ void _pokerGameActionLookOnStart(
) {
pokergame_t *game = (pokergame_t *)action->data;
pokergameactiondata_t *data = game->actionData + i;
printf("Looking at %u\n", data->lookAtPlayer);
pokerWorldLookAtPlayer(&game->scene, data->lookAtPlayer);
queueNext(queue);
}

View File

@ -59,7 +59,7 @@ void pokerUiUpdate(
// Set up the camera perspective
cameraPerspective(&camera, 45,
(float)POKER_UI_PLAYER_IMAGE_SIZE / (float)POKER_UI_PLAYER_IMAGE_SIZE,
0.03f, 10.0f
0.03f, 100.0f
);
// Render the face of each player.

View File

@ -33,7 +33,7 @@
#define POKER_UI_PLAYER_HEIGHT POKER_UI_PLAYER_IMAGE_SIZE
#define POKER_UI_PLAYER_IMAGE_RESOLUTION POKER_UI_PLAYER_IMAGE_SIZE * 2
#define POKER_UI_PLAYER_IMAGE_DIST 0.8f
#define POKER_UI_PLAYER_IMAGE_DIST 0.7f
#define POKER_UI_PLAYER_IMAGE_Y 0.1f
#define POKER_UI_PLAYER_PADDING 8
#define POKER_UI_PLAYER_CHIPS_ANIMATION_SPEED 0.5f

View File

@ -40,16 +40,15 @@ void pokerWorldInit(
void pokerWorldLookAtPlayer(
vnscene_t *scene, uint8_t playerIndex
) {
vnSceneLookAtCharacter(scene, playerIndex, -1);
// uint8_t seat = pokerGameSeatFromIndex(playerIndex);
// vnSceneLookAtCharacter(scene,
// scene->cameraLook.x,
// scene->cameraLook.y,
// scene->cameraLook.z,
// POKER_WORLD_SEAT_POSITION_X(seat),
// scene->cameraLook.lookY,
// POKER_WORLD_SEAT_POSITION_Z(seat)
// );
vncharacter_t *character = scene->characters + playerIndex;
vnSceneLookAt(scene,
scene->cameraLook.x,
scene->cameraLook.y,
scene->cameraLook.z,
character->x,
scene->cameraLook.lookY,
character->z
);
}
void pokerWorldRender(pokerworld_t *world, pokergameassets_t *assets) {

View File

@ -23,6 +23,7 @@ void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){
pokerDealerInit(&poker->dealer);
// Reset the players
printf("Resetting the players\n");
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
pokerPlayerReset(poker->players + i);
}

View File

@ -33,12 +33,21 @@ void pokerBetResetBetter(
) {
uint8_t i;
pokerplayer_t *player;
// Reset the round betting state.
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
player = players + i;
player->state = flagOff(player->state, POKER_PLAYER_STATE_ROUND_MOVE);
}
// Now reset to the first player that needs to bet.
// We do this step first to reset the better
bet->better = pokerBetGetRoundPlayerDefault(roundSmallBlind);
// Then we check who's remaining. We do this because the default better may
// have folded already.
bet->better = pokerBetGetRemainingPlayer(bet, players, roundSmallBlind);
}
bool pokerBetPlayerCanBet(pokerbet_t *bet, pokerplayer_t *player) {

View File

@ -31,7 +31,6 @@ pokerturn_t pokerTurnGet(poker_t *poker, uint8_t playerIndex) {
// they are expected to win from those games, but I'm just going to use the
// odds of the winning hand.
// Is this preflop?
if(poker->dealer.cardsFacing == 0 && player->cardCount >= 2) {
// Get the hand weight
@ -123,7 +122,7 @@ pokerturn_t pokerTurnGet(poker_t *poker, uint8_t playerIndex) {
amount = maxBet;
}
} else if (confidence < 0.95 || poker->dealer.cardsFacing < 0x04) {
if(random < 30) {
if(random < 20) {
amount = callBet;
} else {
amount = maxBet;
@ -132,19 +131,21 @@ pokerturn_t pokerTurnGet(poker_t *poker, uint8_t playerIndex) {
amount = (player->chips - callBet) * 9 / 10;
}
if(isBluff) printf("Mum I'm bluffing\n");
printf("Raised %i times\n", player->timesRaised);
// Let's not get caught in a raising loop with AI.
if(player->timesRaised >= POKER_TURN_MAX_RAISES) {
printf("Calling instead.\n");
amount = callBet;
// If this is the first round... make it a lot less likely I'll bet
if(poker->dealer.cardsFacing == 0x00 && amount > callBet) {
if(random > 5) amount = callBet;
}
// Did we actually bet?
if(amount > 0) {
amount = mathMin(amount, callBet);
printf("I plan on betting %i chips\n", amount);
// Let's not get caught in a raising loop with AI.
if(player->timesRaised >= POKER_TURN_MAX_RAISES) {
amount = callBet;
}
amount = mathMax(amount, callBet);
turn = pokerTurnRaise(poker, playerIndex, amount);
turn.confidence = confidence;
} else if(pokerTurnCanPlayerCheck(poker, playerIndex)) {
@ -170,10 +171,12 @@ void pokerTurnAction(poker_t *poker, pokerplayer_t *player, pokerturn_t *turn) {
case POKER_TURN_TYPE_CHECK:
pokerBetPlayer(&poker->bet, player, 0);
player->timesRaised = 0;
break;
case POKER_TURN_TYPE_FOLD:
player->state |= POKER_PLAYER_STATE_FOLDED;
player->timesRaised = 0;
break;
}
@ -193,9 +196,7 @@ pokerturn_t pokerTurnFold(poker_t *poker, uint8_t player) {
}
pokerturn_t pokerTurnCheck(poker_t *poker, uint8_t player) {
pokerturn_t turn;
turn.type = POKER_TURN_TYPE_CHECK;
return turn;
return pokerTurnRaise(poker, player, 0);
}
pokerturn_t pokerTurnCall(poker_t *poker, uint8_t playerIndex) {
@ -213,9 +214,10 @@ pokerturn_t pokerTurnRaise(poker_t *poker, uint8_t playerIndex, int32_t chips) {
pokerplayer_t *player;
player = poker->players + playerIndex;
if(chips < poker->bet.currentBet) chips = poker->bet.currentBet;
if(player->chips <= chips) {
if(chips == 0) {
turn.type = POKER_TURN_TYPE_CHECK;
turn.chips = 0;
} else if(player->chips <= chips) {
turn.chips = player->chips;
turn.type = POKER_TURN_TYPE_ALL_IN;
} else {

View File

@ -32,15 +32,15 @@
#define POKER_WINNNIG_TYPE_HIGH_CARD 0x0A
#define POKER_WINNNIG_CONFIDENCE_ROYAL_FLUSH 1.0f
#define POKER_WINNNIG_CONFIDENCE_STRAIGHT_FLUSH 0.9f
#define POKER_WINNNIG_CONFIDENCE_FOUR_OF_A_KIND 0.85f
#define POKER_WINNNIG_CONFIDENCE_FULL_HOUSE 0.83f
#define POKER_WINNNIG_CONFIDENCE_STRAIGHT_FLUSH 0.99f
#define POKER_WINNNIG_CONFIDENCE_FOUR_OF_A_KIND 0.9f
#define POKER_WINNNIG_CONFIDENCE_FULL_HOUSE 0.85f
#define POKER_WINNNIG_CONFIDENCE_FLUSH 0.8f
#define POKER_WINNNIG_CONFIDENCE_STRAIGHT 0.75f
#define POKER_WINNNIG_CONFIDENCE_THREE_OF_A_KIND 0.75f
#define POKER_WINNNIG_CONFIDENCE_TWO_PAIR 0.7f
#define POKER_WINNNIG_CONFIDENCE_PAIR 0.6f
#define POKER_WINNNIG_CONFIDENCE_HIGH_CARD 0.5f
#define POKER_WINNNIG_CONFIDENCE_STRAIGHT 0.7f
#define POKER_WINNNIG_CONFIDENCE_THREE_OF_A_KIND 0.5f
#define POKER_WINNNIG_CONFIDENCE_TWO_PAIR 0.4f
#define POKER_WINNNIG_CONFIDENCE_PAIR 0.2f
#define POKER_WINNNIG_CONFIDENCE_HIGH_CARD 0.1f
/** Holds information about a player's winning state */
typedef struct {

View File

@ -51,7 +51,7 @@ void vnSceneRenderWorld(vnscene_t *scene, engine_t *engine, shader_t *shader) {
cameraLookAtStruct(&scene->camera, scene->cameraLook);
// Set Camera Perspective
cameraPerspective(&scene->camera, 35,
cameraPerspective(&scene->camera, 45,
engine->render.width/engine->render.height,
0.01f, 1000.0f
);
@ -103,10 +103,10 @@ void vnSceneLookAt(vnscene_t *scene,
timeline_t *t;
easefunction_t *f;
d = 1.0f;
d = 0.7f;
s = scene->timeline.current;
t = &scene->timeline;
f = &easeOutQuart;
f = &easeOutQuad;
// Clear the timeline
timelineClear(t);

View File

@ -18,7 +18,7 @@
/** Maximum number of Visual Novel Characters the scene can support */
#define VN_SCENE_CHARACTERS_MAX 6
#define VN_SCENE_DISTANCE_DEFAULT -5.0f
#define VN_SCENE_DISTANCE_DEFAULT -8.0f
typedef struct {
timeline_t timeline;