You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

71 lines
1.5 KiB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include "api.h"
  6. struct stockage {
  7. unsigned int nb_joueur;
  8. enum hole_t color;
  9. };
  10. struct stockage storage(unsigned int write, unsigned int nb_joueur, enum hole_t color) {
  11. static struct stockage stock= {0, none};
  12. if(write & 1)
  13. stock.color = color;
  14. if(write & 2)
  15. stock.nb_joueur = nb_joueur;
  16. return stock;
  17. }
  18. void InitLibrary(char name[50]) {
  19. struct stockage stock;
  20. stock = storage(3,0,0);
  21. printf("name for player (color %d)?", stock.color);
  22. scanf("%s", name);
  23. printf("stratégie init %s\n", name);
  24. }
  25. void StartGame() {
  26. puts("stratégie start game");
  27. }
  28. void StartMatch(const unsigned int nb_joueur, const enum hole_t color) {
  29. srand(time(NULL));
  30. struct stockage stock;
  31. stock = storage(3,nb_joueur, color);
  32. printf("stratégie start match (%d players, color%d)\n", stock.nb_joueur, stock.color);
  33. }
  34. void EndMatch() {
  35. puts("stratégie end match");
  36. }
  37. void EndGame() {
  38. puts("stratégie end game");
  39. }
  40. int NextMove(const SGameState * const gameState, int firstMove, SMove *move) {
  41. struct stockage stock;
  42. int i;
  43. int start, end, next;
  44. stock = storage(0, 0, 0);
  45. printf("joueur %d, pions : [ ", stock.color);
  46. for(i=0;i<121;i++) {
  47. if(gameState->board[i] == stock.color)
  48. printf("%d, ", i);
  49. }
  50. puts(" ]");
  51. if(firstMove)
  52. puts("== premier mouvement ==");
  53. printf("mouvement (start, end, next) ?");
  54. scanf("%d %d %d", &start, &end, &next);
  55. move->startPos = start;
  56. move->endPos = end;
  57. printf("mouvement %d %d %d\n", move->startPos, move->endPos, next);
  58. return next;
  59. }