2009-10-31 15:13:53 +00:00
|
|
|
#ifndef BAST_H_
|
|
|
|
#define BAST_H_
|
|
|
|
|
2009-11-05 19:14:50 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include "playfield.h"
|
|
|
|
#include "piece.h"
|
|
|
|
|
|
|
|
/*********
|
|
|
|
* types *
|
|
|
|
*********/
|
|
|
|
|
2009-12-27 02:11:58 +00:00
|
|
|
typedef struct tetris_bastet_scorepair_t
|
|
|
|
{
|
|
|
|
tetris_piece_shape_t shape;
|
|
|
|
int16_t nScore;
|
|
|
|
}
|
|
|
|
tetris_bastet_scorepair_t;
|
|
|
|
|
|
|
|
|
2009-11-05 19:14:50 +00:00
|
|
|
typedef struct tetris_bastet_t
|
|
|
|
{
|
2009-12-27 02:11:58 +00:00
|
|
|
tetris_playfield_t *pPlayfield; // the playfield to be examined
|
|
|
|
int8_t *pColHeights; // array of calculated heights
|
|
|
|
tetris_bastet_scorepair_t nPieceScores[7]; // score for every piece
|
2009-11-05 19:14:50 +00:00
|
|
|
}
|
|
|
|
tetris_bastet_t;
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
|
|
|
* construction/destruction *
|
|
|
|
****************************/
|
|
|
|
|
|
|
|
/* Function: tetris_bastet_construct
|
|
|
|
* Description: constructs a bastet instance for a given playfield
|
|
|
|
* Argument pPlayfield: the playfield to be observed
|
|
|
|
* Return value: pointer to a newly created bastet instance
|
|
|
|
*/
|
|
|
|
tetris_bastet_t* tetris_bastet_construct(tetris_playfield_t *pPl);
|
|
|
|
|
|
|
|
|
|
|
|
/* Function: tetris_bastet_destruct
|
|
|
|
* Description: destructs the given bastet instance
|
|
|
|
* Argument pBastet: the bastet instance to be destroyed
|
|
|
|
* Return value: void
|
|
|
|
*/
|
|
|
|
void tetris_bastet_destruct(tetris_bastet_t *pBastet);
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
|
|
|
* bastet related functions *
|
|
|
|
****************************/
|
|
|
|
|
|
|
|
/* Function: tetris_bastet_construct
|
|
|
|
* Description: calculates a score for a piece at a given column
|
|
|
|
* Argument pBastet: the bastet instance of interest
|
|
|
|
* Argument pPiece: the piece to be tested
|
|
|
|
* Argument pnColum: the column where the piece should be dropped
|
|
|
|
* Return value: score for the given move
|
|
|
|
*/
|
|
|
|
int16_t tetris_bastet_evalPos(tetris_bastet_t *pBastet,
|
|
|
|
tetris_piece_t *pPiece,
|
|
|
|
int8_t nColumn);
|
2009-10-31 15:13:53 +00:00
|
|
|
|
2009-12-27 02:11:58 +00:00
|
|
|
|
|
|
|
/* Function: tetris_bastet_minimax
|
|
|
|
* Description: calculates the best possible score for every piece
|
|
|
|
* Argument pBastet: the bastet instance of interest
|
|
|
|
* Return value: void
|
|
|
|
*/
|
|
|
|
void tetris_bastet_minimax();
|
|
|
|
|
|
|
|
|
|
|
|
tetris_piece_t* tetris_bastet_choosePiece(tetris_bastet_t *pBastet);
|
|
|
|
|
|
|
|
tetris_piece_t* tetris_bastet_choosePreviewPiece(tetris_bastet_t *pBastet);
|
|
|
|
|
2009-10-31 15:13:53 +00:00
|
|
|
#endif /* BAST_H_ */
|