minimax

minimax - score = zero; else { if (!c.est_profondeur_max())...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include "minimax.h" //------------------------------------------------------------- // Entree : deux entiers a et b // Sortie : le plus grand entier entre a et b //------------------------------------------------------------- int max(int a,int b) { if (a > b) return a; else return b; } //------------------------------------------------------------- // Entree : deux entiers a et b // Sortie : le plus petit entier entre a et b //------------------------------------------------------------- int min(int a,int b) { if (a < b) return a; else return b; } //------------------------------------------------------------- // Entree : une configuration c // Sortie : un score mesurant l'interet d'un coup //------------------------------------------------------------- int minimax(config c) { int score, t; list<config> fils; list<config>::iterator it; fils = c.coups_possibles(); score = c.eval_partielle(); if ((c.gagne()) && (!c.est_max())) score = plus_infini; else { if (c.perd()) score = moins_infini; else { if (c.match_nul())
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: score = zero; else { if (!c.est_profondeur_max()) { it = fils.begin(); score = minimax(*it); if (c.est_max()) { for(it=fils.begin(); it!=fils.end(); it++) { t = minimax(*it); score = max(score, t); } } else { for(it=fils.begin(); it!=fils.end(); it++) { t = minimax(*it); score = min(score, t); } } } } } } return score; } //-------------------------------------------------------------// Entree : une configuration c // Sortie : renvoie la configuration du meilleur coup grace // à minimax. //-------------------------------------------------------------config meilleur_coup(config c) { int m, t; config c1; list<config> fils; list<config>::iterator it; fils = c.coups_possibles(); it = fils.begin(); m = minimax(*it); c1 = *it; for(it=fils.begin(); it!=fils.end(); it++) { if ((*it).gagne() && !((*it).est_max())) { c1 = *it; m = plus_infini + 1; } t = minimax(*it); if (m < t) { m = t; c1 = *it; } } return c1; }...
View Full Document

This note was uploaded on 11/01/2009 for the course AV 244 taught by Professor Dub during the Spring '09 term at ECE.

Page1 / 2

minimax - score = zero; else { if (!c.est_profondeur_max())...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online