/[projet1]/public/oric/games/Awele/MinigameAwale.h
Defence Force logotype

Contents of /public/oric/games/Awele/MinigameAwale.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 491 - (show annotations)
Sun May 22 11:33:41 2011 UTC (8 years, 10 months ago) by dbug
File MIME type: text/plain
File size: 2406 byte(s)
Added an Oric version of the game Awele made by a coworker eons ago :)
1 #define WIDTH (6)
2 #define LENGTH (2)
3
4
5 #define RAND_MAX (0x7fff)
6 //int rand();
7
8 /**
9 @brief definition d'un coup
10 */
11 /*
12 typedef struct _shot_awale
13 {
14 int m_column; // which column ?
15 }ShotAwale;
16 */
17 typedef int ShotAwale;
18
19 /**
20 @brief definition d'un joueur
21 */
22 /*
23 typedef struct _player_awale
24 {
25 unsigned long m_id;
26 }PlayerAwale;
27 */
28 typedef int PlayerAwale;
29
30 /**
31 */
32 typedef struct _state_awale
33 {
34 // Datas
35 int m_player; // current line to play (0 or 1)
36 int m_garbage[LENGTH];
37 //unsigned short m_map[LENGTH][WIDTH];
38 int m_map[LENGTH][WIDTH];
39 } StateAwale;
40
41 void StateAwale_Reset(StateAwale* state);
42 int StateAwale_PlacesToPlay(const StateAwale* state, ShotAwale* shotArray);
43 int StateAwale_HasPlaceToPlay(const StateAwale* state);
44 int StateAwale_CanPlay(const StateAwale* state, ShotAwale play);
45 void StateAwale_PlayShot(StateAwale* state, ShotAwale play);
46
47 //int StateAwale_GetPlayer(const StateAwale* state) { return state->m_player; }
48 //void StateAwale_SetPlayer(StateAwale* state, int p) { state->m_player = p; }
49 #define StateAwale_GetPlayer(state) ((state)->m_player)
50 #define StateAwale_SetPlayer(state, p) ((state)->m_player = p)
51
52
53 // display
54 //int StateAwale_Eval(const StateAwale* state, int player) { return state->m_garbage[player] - state->m_garbage[1-player]; }
55 #define StateAwale_Eval(state, player) ( (state)->m_garbage[player] - (state)->m_garbage[1-player] )
56
57 // IA
58
59 /**
60 @return index of the best shot in the array
61 */
62 int StateAwale_BestShot_AlphaBeta(const StateAwale* state, const ShotAwale* shotArray, int shotArraySize, int depth);
63
64 /**
65 @return an evaluation of the branch
66 */
67 int StateAwale_AlphaBeta(const StateAwale* state, int player, int alpha, int beta, int depth);
68
69
70
71
72 /**
73 */
74 struct _game_awale;
75 typedef ShotAwale (*SHOT_FUNC)(struct _game_awale*);
76
77 typedef struct _game_awale
78 {
79 SHOT_FUNC m_shotFunc[LENGTH];
80 PlayerAwale m_player[LENGTH];
81 StateAwale m_currentState;
82 } GameAwale;
83
84
85 void GameAwale_GameInit(GameAwale* game);
86 void GameAwale_GameLoop(GameAwale* game);
87 int GameAwale_GameTerm(GameAwale* game);
88
89 ShotAwale GameAwale_GetShot_Human(GameAwale* game );
90 ShotAwale GameAwale_GetShot_Cpu0(GameAwale* game ); // random
91 ShotAwale GameAwale_GetShot_Cpu1(GameAwale* game ); // alpha-beta
92 ShotAwale GameAwale_GetShot_Cpu2(GameAwale* game ); // alpha-beta bis
93
94
95

  ViewVC Help
Powered by ViewVC 1.1.26