#include "code\Deployment\Deployment.txt"

//----------------------------------------------------------------------------------------------
void main(){
	S={1,1,1,1};
	SYS={
		starter:S,
		filename:getThisFileName(),
		toString:"toStringStan",
		priznakfinish:"gotovo",
		control:"oksystem",
		methods:{"perepravil"},
		parameters:{"chengperepravil"}
		};
	poisk(&SYS);
	//printerSYS(&SYS);

	FindWAYS(&SYS);
	DefineRandomWAY(&SYS);
	printWAY(&SYS);

	getstring();
}


var chengperepravil(S){
	v={};
	for(i=0;i<S->size();++i)if((*S)[0]==(*S)[i])v.push({i});
	return v;
}


void perepravil(S,n){
	p=(*S)[0];
	p=1-p;
	(*S)[0]=p;
	if(!n)return;
	(*S)[n]=p;
}


bool oksystem(S){
	if( (*S)[1]==(*S)[2] )if((*S)[0]!=(*S)[1])return 0;
	if( (*S)[3]==(*S)[2] )if((*S)[0]!=(*S)[2])return 0;
	return 1;
}


bool gotovo(S){
	for(i=0;i<S->size();++i)if((*S)[i])return 0;
	return 1;
}


string toStringStan(S){
	//return S->export();
	m={"Я","Капуста","Коза","Волк"};
	a={};
	b={};
	for(i=0;i<m.size();++i)((*S)[i]?a:b).push(m[i]);
	return a.implode(", ").rovno(23)+" | "+b.implode(", ");
}
