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.

88 lines
1.7 KiB

  1. #define _CRT_SECURE_NO_WARNINGS // to write faster
  2. #define re return
  3. #define N 20 // size of Play Field
  4. #include<stdio.h>
  5. #include<string.h>
  6. #include<stdlib.h>
  7. #include<time.h>
  8. #include<stdbool.h>
  9. int speed = 0;
  10. int win(int realU[N][N]){
  11. int groesste = 0;
  12. for(int i = 0; i < N; i++){
  13. for(int j = 0; j < N; j++){
  14. if(realU[i][j] > groesste && realU[i][j] != (N * N ) + 1){
  15. groesste = realU[i][j];
  16. }
  17. }
  18. }
  19. if(groesste == (N * N) - 1){
  20. return 1;
  21. }
  22. else{
  23. return 0;
  24. }
  25. }
  26. //Die Funktion überprüft, ob das Feld bereits vom Schlangenkoerper besetzt ist.
  27. int feldFrei(int realU[N][N], int ii, int jj){
  28. if (realU[ii][jj] == 0)
  29. {
  30. return 1;
  31. }
  32. return 0;
  33. }
  34. int lose(int realU[N][N], char richtung){
  35. int groesste = 0; //Suche den Kopf der Schlange
  36. int ii, jj;
  37. for(int i = 0; i < N ; i++){
  38. for(int j = 0; j < N; j++){
  39. if (realU[i][j] > groesste && realU[i][j] != (N * N) + 1){
  40. groesste = realU[i][j];
  41. ii = i;
  42. jj = j;
  43. }
  44. }
  45. }
  46. if (richtung == 'u') {
  47. if (realU[ii - 1][jj] != (N*N) + 1&& realU[ii - 1][jj] != 0) {
  48. return 1;
  49. }
  50. }
  51. else if (richtung == 'd') {
  52. if (realU[ii + 1][jj] != (N*N) + 1 && realU[ii + 1][jj] != 0 || ii == 20) {
  53. return 1;
  54. }
  55. }
  56. else if (richtung == 'l') {
  57. if (realU[ii][jj-1] != (N*N) + 1 && realU[ii][jj-1] != 0 || jj == 0) {
  58. return 1;
  59. }
  60. }
  61. else {
  62. if (realU[ii][jj + 1] != (N*N) + 1 && realU[ii][jj + 1] != 0) {
  63. return 1;
  64. }
  65. }
  66. return 0;
  67. }
  68. int update(int realU[N][N],char richtung) {
  69. int groesste = 0;
  70. int ii, jj;
  71. for(int i = 0; i < N; i++) {
  72. for(int j = 0; j < N; j++) {
  73. }
  74. }
  75. }
  76. int probe(int input){
  77. return input;
  78. }