<commit_before>#include <stdio.h>
#include "chess.h"

/* DEF */
#define GETCURRENTPLAYER 0
#define SETCURRENTPLAYER 1 
#define GETBOARD 0
#define SETBOARD 1
#define WEISS '1' 
#define SCHWARZ '2'
#define WBAUER 1 
#define WLAEUFER 2
#define WSPRINGER 3
#define WTURM 4 
#define WDAME 5
#define WKOENIG 6
#define SBAUER 11
#define SLAEUFER 12
#define SSPRINGER 13
#define STURM 14 
#define SDAME 15 
#define SKOENIG 16

static int calcPos(position act) { 
	return ((act.y)*8 + act.x);

}

static char occupied(char currentplayer,position next,board game) { 
	/* 
		output: 0 Feld leer 
		output: 1 Feld besetzt, eigene Farbe 
		output: 2 Feld besetzt, gegnerische Farbe
	*/
	char res='3';
	int nextPos = calcPos(next);
	if(game.field[nextPos] == 0)
		res ='0';
	
	if ((currentplayer == '1') && ( res != '0')){ 
	 
		if (game.field[nextPos] < 10)
			res ='1'; 		
		else  
			res ='2'; 
		
	}
	if((currentplayer =='2') && ( res != '0')){ 
	
		if(game.field[nextPos] > 10) 
			res ='1'; 
	
		else  
			res ='2';  
	}
 return res;
}

static char moveBauer(char currentplayer, position act, position next,board game){ 
	/* input: 
		currentplayer, act pos, next pos, gameboard 
	   next pos ok? 
	   output: 
		0 besetzt, inkorrekte pos
		1 ok, geschlagen
	*/
	char res='9';
	char occ=occupied(currentplayer,next,game);
	
	if( occ =='1' ) 
		res = '0'; 
	else { 
		/* WEIß */ 
		if (currentplayer == '1') { 
			/* FELD drüber frei ? */ 
			if(next.x == act.x) {
				if((act.y == 1) && (next.y == 3) && (occ=='0'))
					res ='1';
				if((next.y == (act.y+1)) && res =='9'){
					if(occ == '0' && res =='9') 
						res = '1';
					else 
						res = '0';
				} 
				else 
					res = '0';
		}
			/* GESCHLAGEN */ 
		if( res == '9') { 
			if((next.x == act.x+1) && (next.y == act.y+1) && ( occ =='2')) 
				res='1';
			if((next.x == act.x-1) && (next.y == act.y+1) && ( occ == '2'))
				res='1';
			if ( res !='1')
				res='0'; 
		}
	}
		/* <NAME> */ 
		if ( currentplayer == '2') { 
		if ( next.x == act.x) {  
			if((act.y == 6) && ( next.y == 4) && (occ == '0'))
				res='1';
			
			if(next.y == (act.y-1) && (res=='9')){ 
					if ( occ == '0' && res =='9') 
						res = '1';
					else 
						res ='0';
				}
				else 
				res='0';
		}
			if(res == '9') {
			if((next.x == act.x+1) && (next.y == act.y-1) && ( occ =='2')) 
			res='1'; 
			if((next.x == act.x-1) && (next.y == act.y-1) && ( occ =='2'))
			res='1';
			if(res !='1')
			res='0';	          
			}
 		}
	}
	return res;
}

static char moveLaeufer(char currentplayer, position act, position next,board game){ 
	/* 
		Ziel korrekt ?  
	   	Prüfe Weg zum Ziel
		Weg blockiert? 
		Out : 
			0 : Eigene Figur, Ziel inkorrekt
			1 : Ziel erreicht, Platziere an neuer pos<commit_msg>Double field movement with the Pawn possible<commit_after>#include <stdio.h>
#include "chess.h"

/* DEF */
#define GETCURRENTPLAYER 0
#define SETCURRENTPLAYER 1 
#define GETBOARD 0
#define SETBOARD 1
#define WEISS '1' 
#define SCHWARZ '2'
#define WBAUER 1 
#define WLAEUFER 2
#define WSPRINGER 3
#define WTURM 4 
#define WDAME 5
#define WKOENIG 6
#define SBAUER 11
#define SLAEUFER 12
#define SSPRINGER 13
#define STURM 14 
#define SDAME 15 
#define SKOENIG 16

static int calcPos(position act) { 
	return ((act.y)*8 + act.x);

}

static char occupied(char currentplayer,position next,board game) { 
	/* 
		output: 0 Feld leer 
		output: 1 Feld besetzt, eigene Farbe 
		output: 2 Feld besetzt, gegnerische Farbe
	*/
	char res='3';
	int nextPos = calcPos(next);
	if(game.field[nextPos] == 0)
		res ='0';
	
	if ((currentplayer == '1') && ( res != '0')){ 
	 
		if (game.field[nextPos] < 10)
			res ='1'; 		
		else  
			res ='2'; 
		
	}
	if((currentplayer =='2') && ( res != '0')){ 
	
		if(game.field[nextPos] > 10) 
			res ='1'; 
	
		else  
			res ='2';  
	}
 return res;
}

static char moveBauer(char currentplayer, position act, position next,board game){ 
	/* input: 
		currentplayer, act pos, next pos, gameboard 
	   next pos ok? 
	   output: 
		0 besetzt, inkorrekte pos
		1 ok, geschlagen
	*/
	char res='9';
	char occ=occupied(currentplayer,next,game);
	
	if( occ =='1' ) 
		res = '0'; 
	else { 
		/* WEIß */ 
		if (currentplayer == '1') { 
			/* FELD drüber frei ? */ 
			if(next.x == act.x) {
				if((act.y == 1) && (next.y == 3) && (occ=='0'))
					res ='1';
				if((next.y == (act.y+1)) && res =='9'){
					if(occ == '0' && res =='9') 
						res = '1';
					else 
						res = '0';
				} 
				else {
					if(res =='9')
					res = '0';
		}
			}
			/* GESCHLAGEN */ 
		if( res == '9') { 
			if((next.x == act.x+1) && (next.y == act.y+1) && ( occ =='2')) 
				res='1';
			if((next.x == act.x-1) && (next.y == act.y+1) && ( occ == '2'))
				res='1';
			if ( res !='1')
				res='0'; 
		}
	}
		/* SCHWARZER BAUER */ 
		if ( currentplayer == '2') { 
		if ( next.x == act.x) {  
			if((act.y == 6) && ( next.y == 4) && (occ == '0'))
				res='1';
			
			if(next.y == (act.y-1) && (res=='9')){ 
					if ( occ == '0' && res =='9') 
						res = '1';
					else 
						res ='0';
				}
				else {
				if(res == '9')
				res='0';
				}
		}
			if(res == '9') {
			if((next.x == act.x+1) && (next.y == act.y-1) && ( occ =='2')) 
			res='1'; 
			if((next.x == act.x-1) && (next.y == act.y-1) && ( occ =='2'))
			res='1';
			if(res !='1')
			res='0';	          
			}
 		}
	}
	return res;
}

static char moveLaeufer(char currentplayer, position act, position next,board game){ 
	/* 
		Ziel korrekt ?  
	   	Prüfe Weg zum Ziel
		Weg blockiert? 
		Out : 
			0 : Eigene Figur, Ziel inkorrekt
			1 : Ziel erreicht, Platziere an neuer pos
{'fraction_non_alphanumeric': 0.20118983234180637, 'fraction_numerical': 0.03497385974400577, 'mean_word_length': 2.3932721712538227, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3965448', 'n_tokens_mistral': 2833, 'n_tokens_neox': 2360, 'n_words': 598}