2
已解决
李熙尧
新手光能
新手光能
1.0.0
#include<cstdio>
#define hello(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
///*
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-helloirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
//*/
#include<iomanip>
#include<stdio.h>
#include<cstdlib>
#include<ctime>
#include<map>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<iostream>
#include<windows.h>
using namespace std;
POINT p;
void pr(string s){
for(int i=0;i<s.size();i++){
cout<<s[i];
Sleep(40);
}
}
int gotoxy(int y, int x){
HANDLE handle;
COORD coord;
coord.X = x;
coord.Y = y;
handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(handle, coord);
} void cls(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 };
SetConsoleCursorPosition( hConsole, coordScreen );
}
void go1(){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);
CursorInfo.bVisible = false;
SetConsoleCursorInfo(handle, &CursorInfo);
}
int mp[35][35];
void pmp(int x,int y){
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(i==x&&j==y){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
}else{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
}
if(mp[i][j]==0){
printf("□");
}else if(mp[i][j]==2){
printf("×");
}else if(mp[i][j]==1){
printf("○");
}
if(i==x&&j==y){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
}
}cout<<endl;
}
}
bool check(int a,int b){
int cnt=0;
/*竖*/
cnt=0;
for(int i=max(0,a-4);i<=min(19,a+4);i++){
if(mp[i][b]==mp[a][b]&&mp[i][b]!=0){
cnt++;
if(cnt>=5) return true;
}else if(cnt!=0){
cnt=0;
}
}
/*横*/
cnt=0;
for(int i=max(0,b-4);i<=min(19,b+4);i++){
if(mp[a][i]==mp[a][b]&&mp[a][i]!=0){
cnt++;
if(cnt>=5) return true;
}else if(cnt!=0){
cnt=0;
}
}
/*主对角线*/
cnt=0;
for(int i=-4;i<=4;i++){
int dx=a+i,dy=b+i;
if(dx>=0&&dx<=19&&dy>=0&&dy<=19){
if(mp[dx][dy]==mp[a][b]){
cnt++;
if(cnt>=5){
return true;
}
}else if(cnt!=0){
cnt=0;
}
}
}
/*副对角线*/
cnt=0;
for(int i=-4;i<=4;i++){
int dx=a+i,dy=b-i;
if(dx>=0&&dx<=19&&dy>=0&&dy<=19){
if(mp[dx][dy]==mp[a][b]){
cnt++;
if(cnt>=5){
return true;
}
}else if(cnt!=0){
cnt=0;
}
}
}
return false;
}
signed main(){
/*-------------------------基本内容设置开始-----------------------*/
go1();
system("title 小李工作室—五分钟小游戏系列之二---------五子棋1.0.0,现仅支持双人对战!人机对战及其他功能正在研发,欢迎提出意见~~~");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);//设置红色和绿色相加
Sleep(1000);
/*-------------------------基本内容设置结束-----------------------*/
/*---------------------------主题程序开始-----------------------*/
int x=9,y=9,game=0,gx,gy;
int hf=1;
pmp(9,9);
printf("玩家%d",hf);
go1();
while(1){
game++;
int h=0;
bool f=0;
while(1){
if(f){
pmp(x,y);
printf("玩家%d",hf);
}
f=0;
if(hello(0x25)){
if(x>=0){
y--;
f=1;
}
}if(hello(0x27)){
if(x<=18){
y++;
f=1;
}
}if(hello(0x26)){
if(y>=0){
x--;
f=1;
}
}if(hello(0x28)){
if(y<=18){
x++;
f=1;
}
}if(hello(0x0D)){
break;
}
if(f==1){
cls();
}
}
if(game%2==1){
if(mp[x][y]==0){
mp[x][y]=1;
gx=x,gy=y;
cls();
Sleep(1);
pmp(x,y);
}else{
game--;
}
}else{
if(mp[x][y]==0){
mp[x][y]=2;
gx=x,gy=y;
cls();
Sleep(1);
pmp(x,y);
}else{
game--;
}
}
if(check(gx,gy)){
system("cls");
cout<<"玩家"<<hf<<"胜!!!\n";
pr("THAAAANK you 使用!敬请期待新版本");
break;
}
hf++;
if(hf==3) hf=1;
}
return false;
}
李熙尧在2022-07-31 08:37:54追加了内容
1.0.1来了
更新内容:
1.降低灵敏度
#include<cstdio>
#define hello(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
///*
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-helloirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
//*/
#include<iomanip>
#include<stdio.h>
#include<cstdlib>
#include<ctime>
#include<map>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<iostream>
#include<windows.h>
using namespace std;
POINT p;
void pr(string s){
for(int i=0;i<s.size();i++){
cout<<s[i];
Sleep(40);
}
}
int gotoxy(int y, int x){
HANDLE handle;
COORD coord;
coord.X = x;
coord.Y = y;
handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(handle, coord);
} void cls(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 };
SetConsoleCursorPosition( hConsole, coordScreen );
}
void go1(){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);
CursorInfo.bVisible = false;
SetConsoleCursorInfo(handle, &CursorInfo);
}
int mp[35][35];
void pmp(int x,int y){
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(i==x&&j==y){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
}else{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
}
if(mp[i][j]==0){
printf("□");
}else if(mp[i][j]==2){
printf("×");
}else if(mp[i][j]==1){
printf("○");
}
if(i==x&&j==y){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
}
}cout<<endl;
}
}
bool check(int a,int b){
int cnt=0;
/*竖*/
cnt=0;
for(int i=max(0,a-4);i<=min(19,a+4);i++){
if(mp[i][b]==mp[a][b]&&mp[i][b]!=0){
cnt++;
if(cnt>=5) return true;
}else if(cnt!=0){
cnt=0;
}
}
/*横*/
cnt=0;
for(int i=max(0,b-4);i<=min(19,b+4);i++){
if(mp[a][i]==mp[a][b]&&mp[a][i]!=0){
cnt++;
if(cnt>=5) return true;
}else if(cnt!=0){
cnt=0;
}
}
/*主对角线*/
cnt=0;
for(int i=-4;i<=4;i++){
int dx=a+i,dy=b+i;
if(dx>=0&&dx<=19&&dy>=0&&dy<=19){
if(mp[dx][dy]==mp[a][b]){
cnt++;
if(cnt>=5){
return true;
}
}else if(cnt!=0){
cnt=0;
}
}
}
/*副对角线*/
cnt=0;
for(int i=-4;i<=4;i++){
int dx=a+i,dy=b-i;
if(dx>=0&&dx<=19&&dy>=0&&dy<=19){
if(mp[dx][dy]==mp[a][b]){
cnt++;
if(cnt>=5){
return true;
}
}else if(cnt!=0){
cnt=0;
}
}
}
return false;
}
signed main(){
/*-------------------------基本内容设置开始-----------------------*/
go1();
system("title 小李工作室—五分钟小游戏系列之二---------五子棋1.0.1,现仅支持双人对战!人机对战及其他功能正在研发,欢迎提出意见~~~");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);//设置红色和绿色相加
Sleep(1000);
/*-------------------------基本内容设置结束-----------------------*/
/*---------------------------主题程序开始-----------------------*/
int x=9,y=9,game=0,gx,gy;
int hf=1;
pmp(9,9);
printf("玩家%d",hf);
go1();
while(1){
game++;
int h=0;
bool f=0;
while(1){
if(f){
pmp(x,y);
printf("玩家%d",hf);
}
f=0;
if(hello(0x25)){
if(x>=0){
y--;
f=1;
}
}if(hello(0x27)){
if(x<=18){
y++;
f=1;
}
}if(hello(0x26)){
if(y>=0){
x--;
f=1;
}
}if(hello(0x28)){
if(y<=18){
x++;
f=1;
}
}if(hello(0x0D)){
break;
}
if(f==1){
cls();
}
}Sleep(90);
if(game%2==1){
if(mp[x][y]==0){
mp[x][y]=1;
gx=x,gy=y;
cls();
Sleep(1);
pmp(x,y);
}else{
game--;
}
}else{
if(mp[x][y]==0){
mp[x][y]=2;
gx=x,gy=y;
cls();
Sleep(1);
pmp(x,y);
}else{
game--;
}
}
if(check(gx,gy)){
system("cls");
cout<<"玩家"<<hf<<"胜!!!\n";
pr("THAAAANK you 使用!敬请期待新版本");
break;
}
hf++;
if(hf==3) hf=1;
}
return false;
}