Long time no see

This commit is contained in:
2026-02-21 10:47:00 +07:00
parent 0d54fe176e
commit b7df98a55c
198 changed files with 3249 additions and 1 deletions
+86
View File
@@ -0,0 +1,86 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 8
Cpp11BracedListStyle: true
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
...
Binary file not shown.
Binary file not shown.
Binary file not shown.
+93
View File
@@ -0,0 +1,93 @@
# lab-rodionov-iv522s18
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
* [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://git.csc.sibsutis.ru/trpo2026/lab-rodionov-iv522s18.git
git branch -M master
git push -uf origin master
```
## Integrate with your tools
* [Set up project integrations](https://git.csc.sibsutis.ru/trpo2026/lab-rodionov-iv522s18/-/settings/integrations)
## Collaborate with your team
* [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
* [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
* [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
* [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
## Test and Deploy
Use the built-in continuous integration in GitLab.
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
+32
View File
@@ -0,0 +1,32 @@
#ifndef HEAD
#define HEAD
// LIBC
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
// DEFINE
#define CHARS_IN_INPUT_MAX 40
// TYPEDEF
typedef struct{
unsigned char currCol;
unsigned char currRow;
unsigned char nextCol;
unsigned char nextRow;
unsigned char whosTurn;
}__TURN;
// FUNC
// === === io.c === ===
char input_(char *_input, char *charsInInput);
void print_board(char* _board);
// === === logic.c === ===
char match_turn(char currFigure,char whosTurn);
char match_move(char _board[8][8],__TURN* __turn,char currFigure);
void move(char _board[8][8],__TURN *__turn);
int abs(int n);
#endif
+50
View File
@@ -0,0 +1,50 @@
#include "head.h"
char input_(char *_input, char *charsInInput){
// INPUT
do{
*charsInInput = 0;
char ch;
while((ch=getchar())>' '&&*charsInInput<CHARS_IN_INPUT_MAX){
*(_input+*charsInInput)=ch;
(*charsInInput)++;
}
if(ch<= 4)return -1;
if(*_input>= '0' && *_input<='9'){
for(int i = 0;i<*charsInInput;i++)
putchar(_input[i]);
putchar(' ');
continue;}
if((*_input>= 'A' && *_input<='A'+7) ||
(*_input>= 'a' && *_input<='a'+7)||
(*_input=='N'||*_input=='Q'||*_input=='R'||*_input=='K'||*_input=='P')){
for(int i = 0;i<*charsInInput;i++)
putchar(_input[i]);
putchar('\n');
break;}
}while(*_input>4);
return 0;
}
void print_board(char* _board){
for (int i = 0;i<8;i++){
putchar('8'-i);
putchar(' ');
for(int j = 0;j<8;j++){
putchar(_board[i*8+j]);
putchar(' ');
}
putchar('\n');
}
putchar(' ');putchar(' ');
for(int i = 0; i<8;i++){
putchar('a'+i);
putchar(' ');
}
putchar('\n');
putchar('\n');
return;
}
+225
View File
@@ -0,0 +1,225 @@
#include "head.h"
char match_turn(char currFigure,char whosTurn){
if((currFigure>='a' && currFigure<='z' && whosTurn-1)
// a-z white && turn !white
||(currFigure>='A' && currFigure<='Z' && whosTurn)){
// A-Z black && turn white
printf("Err, turn missmatch");
return 1;
}
return 0;
}
char match_move(char board[8][8], __TURN* turn, char currFigure)
{
int rowD = turn->nextRow - turn->currRow;
int colD = turn->nextCol - turn->currCol;
if (turn->nextRow < 0 || turn->nextRow > 7 ||
turn->nextCol < 0 || turn->nextCol > 7)
{
printf("Err, move out of board\n");
return 1;
}
switch (currFigure)
{
case 'P':
case 'p':
{
int dir = (currFigure == 'P') ? -1 : 1;
if (colD == 0)
{
if (board[turn->nextRow][turn->nextCol] != ' ')
return 1;
if (rowD == dir)
return 0;
if ((currFigure == 'P' && turn->currRow == 6 && rowD == 2*dir &&
board[turn->currRow + dir][turn->currCol] == ' ') ||
(currFigure == 'p' && turn->currRow == 1 && rowD == 2*dir &&
board[turn->currRow + dir][turn->currCol] == ' '))
return 0;
}
if (abs(colD) == 1 && rowD == dir)
{
if (board[turn->nextRow][turn->nextCol] != ' ')
return 0;
}
printf("Err, pawn move mismatch\n");
return 1;
}
case 'R':
case 'r':
{
if (rowD != 0 && colD != 0)
{
printf("Err, rook move mismatch\n");
return 1;
}
if (rowD == 0)
{
int step = (colD > 0) ? 1 : -1;
for (int c = turn->currCol + step;
c != turn->nextCol;
c += step)
{
if (board[turn->currRow][c] != ' ')
{
printf("Err, rook blocked\n");
return 1;
}
}
}
else
{
int step = (rowD > 0) ? 1 : -1;
for (int r = turn->currRow + step;
r != turn->nextRow;
r += step)
{
if (board[r][turn->currCol] != ' ')
{
printf("Err, rook blocked\n");
return 1;
}
}
}
return 0;
}
case 'N':
case 'n':
{
if ((abs(rowD) == 2 && abs(colD) == 1) ||
(abs(rowD) == 1 && abs(colD) == 2))
return 0;
printf("Err, knight move mismatch\n");
return 1;
}
case 'B':
case 'b':
{
if (abs(rowD) != abs(colD))
{
printf("Err, bishop move mismatch\n");
return 1;
}
int stepR = (rowD > 0) ? 1 : -1;
int stepC = (colD > 0) ? 1 : -1;
int r = turn->currRow + stepR;
int c = turn->currCol + stepC;
while (r != turn->nextRow && c != turn->nextCol)
{
if (board[r][c] != ' ')
{
printf("Err, bishop blocked\n");
return 1;
}
r += stepR;
c += stepC;
}
return 0;
}
case 'Q':
case 'q':
{
if (abs(rowD) == abs(colD))
{
int stepR = (rowD > 0) ? 1 : -1;
int stepC = (colD > 0) ? 1 : -1;
int r = turn->currRow + stepR;
int c = turn->currCol + stepC;
while (r != turn->nextRow && c != turn->nextCol)
{
if (board[r][c] != ' ')
{
printf("Err, queen blocked\n");
return 1;
}
r += stepR;
c += stepC;
}
return 0;
}
if (rowD == 0 || colD == 0)
{
if (rowD == 0)
{
int step = (colD > 0) ? 1 : -1;
for (int c = turn->currCol + step;
c != turn->nextCol;
c += step)
{
if (board[turn->currRow][c] != ' ')
{
printf("Err, queen blocked\n");
return 1;
}
}
}
else
{
int step = (rowD > 0) ? 1 : -1;
for (int r = turn->currRow + step;
r != turn->nextRow;
r += step)
{
if (board[r][turn->currCol] != ' ')
{
printf("Err, queen blocked\n");
return 1;
}
}
}
return 0;
}
printf("Err, queen move mismatch\n");
return 1;
}
case 'K':
case 'k':
{
if (abs(rowD) <= 1 && abs(colD) <= 1)
return 0;
printf("Err, king move mismatch\n");
return 1;
}
}
return 1;
}
void move(char board[8][8], __TURN *turn)
{
board[turn->nextRow][turn->nextCol] =
board[turn->currRow][turn->currCol];
board[turn->currRow][turn->currCol] = ' ';
turn->whosTurn = turn->whosTurn == 0 ? 1 : 0;
}
int abs(int n){
n = n<0 ? n*-1:n;
return n;
}
+69
View File
@@ -0,0 +1,69 @@
#include "head.h"
int main()
{
char _board[8][8];
{ //Set Def desk
char _cleanDesk[] = {"rnbqkbnrpppppppp"};
for(int i = 0;i<8;i++)
for(int j = 0;j<8;j++)
_board[i][j] = ' ';
for (int i = 0; i < 2;i++)
for(int j = 0; j <8;j++)
_board[i][j] = _cleanDesk[i*8+j];
for (int i = 6; i < 8;i++)
for(int j = 0; j < 8;j++)
_board[i][j] = i==6? (_cleanDesk[8+j])-32 : (_cleanDesk[j])-32;
print_board(*_board);
}
char charsInInput=1;
char _input[CHARS_IN_INPUT_MAX];
__TURN __turn;
__turn.whosTurn = 0; // 0 - white 1 - black
while(charsInInput>0){
if (input_(_input,&charsInInput)) return 0;
unsigned char ptr;
{//Turn info
ptr = (*_input>='A'&&*_input<='Z')?3:2; // Qe2-e4
__turn.currCol = _input[ptr-2]-'a';
__turn.currRow = 8-(_input[ptr-1]-'0');
__turn.nextCol = _input[ptr+1]-'a';
__turn.nextRow = 8-(_input[ptr+2]-'0');
}
{//Rules
char currFigure = _board[__turn.currRow][__turn.currCol];
{ // 'Q'e2-e5 Missmatch
if(ptr==3)
if(*_input!=currFigure&&*_input!=currFigure-32){
printf("Err, figure missmatch");
return 1;
}
}
if(match_turn(currFigure,__turn.whosTurn))return 1;
{ // TAKE MISMATCH
if
((_board[__turn.nextRow][__turn.nextCol]!=' ' && _input[ptr]!='x'
)||(
_board[__turn.nextRow][__turn.nextCol]==' ' && _input[ptr]=='x'))
{
printf("Err, take missmatch");
return 1;
}
}
if(match_move(_board,&__turn,currFigure))return 1;
}
move(_board,&__turn);
print_board(*_board);
if(_input[charsInInput-1]=='#')break;
}
return 0;
}
BIN
View File
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
1. e2-e4 e7-e5
2. Bf1-c4 Nb8-c6
3. Qd1-h5 Ng8-f6
4. Qh5xf7#
Binary file not shown.
Submodule 1Y-2H/trpo/lab-rodionov-iv522s18 added at 5553e1330f