我的狼人杀程序
最近感覺CSDN上自編的狼人殺太爛了,于是自己寫了一個(gè),下載地址見下
鏈接:?https://pan.baidu.com/s/1-rnUS5COZdQbZCdFHubFOQ?pwd=ychi?
 提取碼:ychi?
(進(jìn)網(wǎng)站的時(shí)候記得把前面的“xn--https-kt3b//”刪掉,我也不知道那是什么東西)
?自認(rèn)為還不錯(cuò)
?
本程序用C++編寫,工具是VS,有bug請(qǐng)與作者練習(xí),謝謝!
貼上源代碼:
player.h
#ifndef PLAYER_H_
#define PLAYER_H_#include <time.h>
#include <cstdlib>
#include <iostream>
#include <conio.h>
#include "output.h"
using namespace std;
template<typename T1, typename T2>
constexpr auto random(T1 x, T2 y) { return rand() % (y - x + 1) + x; }//1為狼人,2為平民,3為預(yù)言家,4為女巫,5為獵人
struct Pl {bool dead, is_AI;//是否死亡及是否是AIint occ;//職業(yè)int last_out;//上一個(gè)對(duì)自己進(jìn)行投票的人int pots;//毒藥數(shù)量int know[40];//已知的別人身份bool fknow[40];//知道誰的身份int i_of_know;int num;void csh() {//初始化dead = false;is_AI = true;occ = 0;pots = 3;last_out = 0;num = 0;for (int i = 1; i <= 35; i++)know[i] = 0;for (int i = 1; i <= 35; i++)fknow[i] = false;i_of_know = 1;}
};
__declspec(selectany) Pl player[40];
extern string occs[10];//職業(yè)名稱,比判斷好使多了bool check(Pl a,int i);extern int out(Pl a, int peop);extern int kill_for_wolf(Pl a, int peop, int which);extern int things_of_witch(Pl a, int peop, int which,int day);extern bool prop(Pl a, int peop, int which);extern int pull_us(Pl a, int peop);extern int over(Pl a, int peop, bool watchhh);#endif
player.cpp
#include "player.h"
#include "output.cpp"string occs[10] = { "","狼人","平民","預(yù)言家","女巫","獵人" };//職業(yè)名稱,比判斷好使多了bool check(Pl a,int i) {//預(yù)言家的判斷函數(shù)int i1 = 1;while (a.know[i1] != 0) {if (a.know[i1] != 1 && a.know[i1] == i) return false;i1++;}return true;
}int out(Pl a, int peop) {//投票if (a.dead) return 0;//死了else if (a.is_AI && a.occ == 2 && a.last_out != 0 && !player[a.last_out].dead) {//如果是平民且有人投過他,這人還沒死Sleep(300);outp_n(a.num);outp("->");outp_n(a.last_out);outp("\n");player[a.last_out].last_out = a.num;return a.last_out;}else if (a.is_AI && a.occ == 3 && a.know[1] != 0) {//如果是預(yù)言家,且可能知道是誰int i = 1;while (a.know[i] != 0) {if (player[i].occ == 1 && !player[i].dead) {Sleep(300);outp_n(a.num);outp("->");outp_n(a.last_out);outp("\n");return i;}}int tou = random(1, peop);while (tou == a.num || player[tou].dead || !check(a,tou)) tou = random(1, peop);//如果是自己或已死亡或已知不是狼人,就重來Sleep(300);outp_n(a.num);outp("->");outp_n(tou);outp("\n");player[tou].last_out = a.num;return tou;}else if (a.is_AI) {//其他AI或預(yù)言家未預(yù)言所有人int tou = random(1, peop);while (tou == a.num || player[tou].dead || (a.occ == 1 && player[tou].occ == 1)) tou = random(1, peop);//如果是自己或已死亡或雙方都是狼人,就重來Sleep(300);outp_n(a.num);outp("->");outp_n(tou);outp("\n");player[tou].last_out = a.num;return tou;}else {//是玩家outp("你要投誰?(如果投死人,那么游戲可能會(huì)崩掉,你愿意嗎)\n");for (int i = 1; i <= peop; i++)if (!player[i].dead) cout << i << " ";int tou;cin >> tou;player[a.last_out].last_out = a.num;return tou;}
}int kill_for_wolf(Pl a, int peop, int which) {//狼人殺人if (a.occ != 1) return 0;//不是狼人else if (a.dead) return 0;//死了if (a.is_AI) {//是AIint tou = random(1, peop);while (tou == a.num || player[tou].dead || player[tou].occ == 1) tou = random(1, peop);outp("狼人");outp_n(which);outp("號(hào)請(qǐng)睜眼!\n");outp("今晚要?dú)⒄l?\n");Sleep(500 - op1 * 2);outp("好的。\n");return tou;}else {//是玩家outp("狼人");outp_n(which);outp("號(hào)請(qǐng)睜眼!\n");outp("今晚要?dú)⒄l?(如果殺死人,那么游戲可能會(huì)崩掉,你愿意嗎)\n");for (int i = 1; i <= peop; i++)if (!player[i].dead) cout << i << " ";int tou;cin >> tou;return tou;}
}int things_of_witch(Pl a, int peop, int which,int day) {//女巫殺人或救人if (a.occ != 4) return 0;//不是女巫else if (a.dead) return 0;//死了else if (a.is_AI) {//是AIint dead = 0;for (int i = 1; i <= peop; i++)if (player[i].dead) dead++;outp("女巫");outp_n(which);outp("號(hào)請(qǐng)睜眼!\n");outp("今晚要?dú)⑷诉€是救人?\n");Sleep(500 - op1 * 2);outp("好的。\n");int kill_save = random(1, 2);if ((a.pots > 0 && kill_save == 1) || (dead == 0 && a.pots > 0)) {//有毒藥且沒人死/隨機(jī)抽到,殺人int tou = random(1, peop);while (tou == a.num || player[tou].dead) tou = random(1, peop);a.pots--;//cout << "殺\n";player[tou].dead = true;return tou;}else if (dead > 0) {//沒毒藥,救人int tou = random(1, peop);while (tou == a.num || !player[tou].dead) tou = random(1, peop);//cout << "救\n";player[tou].dead = false;return tou;}else return 2147483647;//無法殺,也無法救}else {//是玩家char k_s;outp("女巫");outp_n(which);outp("號(hào)請(qǐng)睜眼!\n");while (true) {outp("你要?dú)⑷诉€是要救人? 殺人:1    救人:2   啥也不做:3\n");k_s = _getch();if (k_s == '1') {//殺人if (a.pots < 1)//毒藥不夠cout << "毒藥不足!\n";else {//毒藥夠outp("今晚要?dú)⒄l?(如果殺死人,那么游戲可能會(huì)崩掉,你愿意嗎)\n");for (int i = 1; i <= peop; i++)if (!player[i].dead) cout << i << " ";int tou;cin >> tou;player[tou].dead = true;return tou;}}else if (k_s == '2') {//救人outp("今晚要救誰?(如果救活人,那么游戲可能會(huì)崩掉,你愿意嗎)\n");for (int i = 1; i <= peop; i++)if (player[i].dead) cout << i << "號(hào),職業(yè):" << occs[player[i].occ] << endl;int tou;cin >> tou;player[tou].dead = false;return tou;}else return 2147483647;}}
}bool prop(Pl a, int peop,int which) {//占卜某人身份if (a.occ != 3) return false;//如果不是預(yù)言家,就退出else if (a.dead) return false;//死了else if (a.is_AI) {//如果是AIoutp("預(yù)言家");outp_n(which);outp("號(hào)請(qǐng)睜眼!\n");outp("你要占卜誰的身份?\n");Sleep(500 - op1 * 2);outp("好的。\n");int get_who = random(1, peop);while (a.fknow[get_who]) get_who = random(1, peop);a.know[a.i_of_know] = get_who;a.fknow[get_who] = true;a.i_of_know++;return true;}else {//如果不是AIoutp("預(yù)言家");outp_n(which);outp("號(hào)請(qǐng)睜眼!\n");while (true) {outp("你要占卜誰的身份(輸入編號(hào))?(占卜百分百正確,如果占卜同一個(gè)人后果自負(fù))\n");int get_who;cin >> get_who;if (get_who > peop || get_who < 1) continue;//當(dāng)編號(hào)不正確else {//cout << get_who << "號(hào)的身份是:" << occs[player[get_who].occ] << "。\n";outp_n(get_who);outp("號(hào)的身份是:");outp(occs[player[get_who].occ]);outp("。\n");break;}}return true;}
}int pull_us(Pl a, int peop) {//獵人的神級(jí)技能:拉一個(gè)人陪葬if (a.occ != 5) return 0;//不是獵人else if (a.dead) return 0;//死了else if (a.is_AI) {//是AIif (a.last_out != 0 && !player[a.last_out].dead) {Sleep(300);outp_n(a.num);outp("號(hào)決定拉出");outp_n(a.last_out);outp("號(hào)陪葬。\n");outp_n(a.last_out);outp("號(hào)的身份是:");outp(occs[player[a.last_out].occ]);outp("。\n");return a.last_out;}else {int tou = random(1, peop);while (tou == a.num || player[tou].dead) tou = random(1, peop);Sleep(300);outp_n(a.num);outp("號(hào)決定拉出");outp_n(tou);outp("號(hào)陪葬。\n");outp_n(tou);outp("號(hào)的身份是:");outp(occs[player[a.last_out].occ]);outp("。\n");return tou;}}else {//不是AIoutp("很遺憾,你被投出了。正義雖遲但到,你可以陪葬一人,選擇誰?(如果帶走死人,那么游戲可能會(huì)崩掉,你愿意嗎)\n");for (int i = 1; i <= peop; i++)if (!player[i].dead) cout << i << " ";int tou;cin >> tou;outp_n(tou);outp("號(hào)的身份是:");outp(occs[player[a.last_out].occ]);outp("。\n");return tou;}
}int over(Pl a, int peop,bool watchhh) {//游戲是否結(jié)束int wolfs = 0, else_p = 0;;if (a.dead && watchhh == false) {outp("你已經(jīng)>>死<<了。\n");system("pause");system("cls");return 3;}for (int i = 1; i <= peop; i++) {if (!player[i].dead && player[i].occ == 1) wolfs++;}if (wolfs == 0) {outp("狼人已全部死亡,好人勝利!\n");system("pause");system("cls");if (a.occ == 1) return 1;return 2;}for (int i = 1; i <= peop; i++) {if (!player[i].dead && player[i].occ != 1) else_p++;}if (else_p == 0) {outp("好人已全部死亡,狼人勝利!\n");system("pause");system("cls");if (a.occ == 1) return 2;else return 1;}return 0;
}//0為游戲未結(jié)束,1為游戲失敗,2為游戲成功,3為人物死亡
chong.h
#ifndef CHONG_H_
#define CHONG_H_#include "occ_card.h"
#include "player.h"
#include <cstring>void play(int peoplesss);#endif
chong.cpp
#include "chong.h"
#include "output.h"//20人場(chǎng):2狼人,8平民,3預(yù)言家,2女巫,5獵人
//30人場(chǎng):3狼人,12平民,4預(yù)言家,4女巫,7獵人void play(int peoplesss) {//開始游戲system("cls");//初始化for (int i = 1; i <= peoplesss; i++)player[i].csh();int twenty[10] = { 0,2,8,2,3,5 };int thirty[10] = { 0,3,12,4,4,7 };int hundred[10] = {0,16,40,24,7,13};//分配身份for (int i = 1; i <= peoplesss; i++) {int iden = random(1, 5);if (peoplesss == 20)while (twenty[iden] == 0) iden = random(1, 5);else if (peoplesss == 30)while (thirty[iden] == 0) iden = random(1, 5);elsewhile (hundred[iden] == 0) iden = random(1, 5);player[i].occ = iden;if (peoplesss == 20)twenty[iden]--;else if (peoplesss == 30)thirty[iden]--;elsehundred[iden]--;player[i].num = i;}//分配號(hào)碼int p1 = random(1, peoplesss);player[p1].is_AI = false;//顯示outp("你是");outp_n(p1);outp("號(hào)。\n");outp("正在分配身份……\n");Sleep(3000 - op1 * 2);outp_occ(player[p1].occ);/*system("cls");for (int i = 1; i <= peoplesss; i++)cout << player[i].occ << " ";cout << endl;system("pause");//system("cls");// 以上這段是測(cè)試*///開始游戲outp("按任意鍵開始游戲……");char yijiansanlian_jiayou = _getch();int day = 1;//第幾天bool watchh = false;while (true) {system("cls");//晚上outp("第");outp_n(day);outp("晚開始\n");outp("你是");outp_n(p1);outp("號(hào)\n");outp("天黑請(qǐng)閉眼!\n");int kill_by_wolf[10];//被狼人殺int things_by_witch[10];//被女巫殺/救memset(kill_by_wolf, 0, sizeof(kill_by_wolf));memset(things_by_witch, 0, sizeof(things_by_witch));//狼人殺人int i = 1;//第幾個(gè)for (int i1 = 1; i1 <= peoplesss; i1++) {if (player[i1].dead) continue;int kill = kill_for_wolf(player[i1], peoplesss, i);if (kill != 0) {player[kill].dead = true;kill_by_wolf[i++] = kill;}}//女巫救人/殺人i = 1;int i2 = 1;for (int i1 = 1; i1 <= peoplesss; i1++) {if (player[i1].dead) continue;int kill = things_of_witch(player[i1], peoplesss, i2,day);if (kill != 0) {if (kill == 2147483647) {i2++;continue;}things_by_witch[i] = kill;i++,i2++;}}//預(yù)言家占卜i = 1;for (int i1 = 1; i1 <= peoplesss; i1++) {if (player[i1].dead) continue;bool is_or_not = prop(player[i1], peoplesss, i);if (is_or_not)i++;}//輸出信息i = 1;bool save_p1 = false;//救玩家while (kill_by_wolf[i] > 0) {outp("狼人殺掉了");outp_n(kill_by_wolf[i]);outp("號(hào),身份:");outp(occs[player[kill_by_wolf[i]].occ]);outp("。\n");i++;}/*int i1 = 1;while (kill_by_witch[i1] > 0) {outp("女巫殺掉了");outp_n(kill_by_witch[i1]);outp("號(hào),身份:");outp(occs[player[kill_by_witch[i1]].occ]);outp("。\n");i1++;}int i2 = 1;while (save_by_witch[i2] > 0) {outp("女巫救活了");outp_n(save_by_witch[i2]);outp("號(hào),身份:");outp(occs[player[save_by_witch[i2]].occ]);outp("。\n");if (save_by_witch[i2] == p1) save_p1 = true;i2++;if (save_by_witch[i2] == p1) save_p1 = true;}*///之前的代碼i = 1;while (things_by_witch[i] > 0) {if (player[things_by_witch[i]].dead) {outp("女巫殺掉了");outp_n(things_by_witch[i]);outp("號(hào),身份:");outp(occs[player[things_by_witch[i]].occ]);outp("。\n");i++;}else if (!player[things_by_witch[i]].dead) {outp("女巫救活了");outp_n(things_by_witch[i]);outp("號(hào),身份:");outp(occs[player[things_by_witch[i]].occ]);outp("。\n");if (things_by_witch[i] == p1) save_p1 = true;i++;if (things_by_witch[i] == p1) save_p1 = true;}}//判斷游戲是否結(jié)束(0為未結(jié)束,1為失敗,2為成功)int over2 = over(player[p1], peoplesss, watchh);if (over2 == 1) {outp("對(duì)不起,你失敗了。\n");system("pause");return;}else if (over2 == 2) {outp("恭喜你,你成功取得了勝利!!!\n");system("pause");return;}else if (over2 == 3){outp("對(duì)不起,你死了。\n");outp("是否觀戰(zhàn)?1:是   其他:否\n");char watchhh = _getch();if (watchhh == '1') {outp("好的。\n兩秒后繼續(xù)游戲……\n");Sleep(2000 - op1);watchh = true;}else return;}if (save_p1) {outp("你被救活了。\n");watchh = false;}//投票outp("投票開始\n");int how_much[40];memset(how_much, 0, sizeof(how_much));for (int i = 1; i <= peoplesss; i++) {int outi = out(player[i], peoplesss);if (player[i].occ == 2 && day % 3 == 0) how_much[outi] += 2;else how_much[outi]++;}int maxn = -1, maxnn = 0;;for (int i = 1; i <= peoplesss; i++)if (how_much[i] > maxn) maxn = how_much[i], maxnn = i;outp_n(maxnn);outp("號(hào)被大家以");outp_n(maxn);outp("票的高票數(shù)投出了。\n");outp_n(maxnn);outp("號(hào)的身份是:");outp(occs[player[maxnn].occ]);outp("。\n");int who_out_with_hau = pull_us(player[maxnn], peoplesss);player[maxnn].dead = true;if (who_out_with_hau > 0) player[who_out_with_hau].dead = true;//判斷游戲是否結(jié)束over2 = over(player[p1], peoplesss,watchh);if (over2 == 1) {outp("對(duì)不起,你失敗了。\n");system("pause");return;}else if (over2 == 2) {outp("恭喜你,你成功取得了勝利!!!\n");system("pause");return;}else if (over2 == 3){outp("對(duì)不起,你死了。\n");outp("是否觀戰(zhàn)?1:是   其他:否\n");char watchhh = _getch();if (watchhh == '1') {outp("好的。\n兩秒后繼續(xù)游戲……\n");Sleep(2000 - op1);watchh = true;}else return;}//天數(shù)++day++;system("pause");/*for (int i = 1; i <= peoplesss; i++)cout << player[i].dead << " ";cout << endl;system("pause");//以上是測(cè)試*/}
}
output.h
#ifndef OUTPUT_H_
#define OUTPUT_H_#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
inline extern void outp(string s);
inline extern void outp_n_l(int a);
inline extern void outp_n(int a);
inline extern void outp_fast(string s);
inline extern void outp_line(string s);
__declspec(selectany) extern const int op1 = 66;
__declspec(selectany) extern const int op2 = 40;
__declspec(selectany) extern const int op3 = 500;#endif
output.cpp
#include "output.h"
using namespace std;inline void outp(string s) {for (int i = 0; i < s.size(); i++) {cout << s[i];Sleep(op1);}
}
inline void outp_n_l(int a) {string s = to_string(a);for (int i = 0; i < s.size(); i++) {cout << s[i];Sleep(op1 * 2);}cout << endl;Sleep(op1 * 2);
}
inline void outp_n(int a) {string s = to_string(a);for (int i = 0; i < s.size(); i++) {cout << s[i];Sleep(op1 * 2);}
}
inline void outp_fast(string s) {for (int i = 0; i < s.size(); i++) {cout << s[i];Sleep(op2);}
}
inline void outp_line(string s) {cout << s;Sleep(op3);
}
game.h
#ifndef GAME_H_
#define GAME_H_#include "chong.h"
#include <fstream>extern void begin();//開始游戲#endif
game.cpp
#include "game.h"
using namespace std;void begin() {//開始游戲system("cls");while (true) {cout << "你要玩多少人場(chǎng)的游戲?20人:1   30人:2\n";char how_many_p = _getch();if (how_many_p == '1') {play(20);break;}else if (how_many_p == '2') {play(30);break;}/*else if (how_many_p == 'h') {play(100);break;}*/elsesystem("cls");}system("cls");cout << "是否再來一局?是:1    否:其它\n";char again = _getch();if (again == '1') {cout << "好的。\n";cout << "按任意鍵開始新一局游戲...";char yijiansanlian = _getch();system("cls");begin();return;}else {cout << "好的。\n";return;}return;
}
occ_card.h
#ifndef OCC_CARD_H_
#define OCC_CARD_H_
#include <string>
#include <windows.h>
#include <iostream>
#include <conio.h>
using namespace std;extern string occ[10][40];//職業(yè)extern void outp_occ(int x);//顯示職業(yè),1為狼人,2為平民,3為女巫,4為預(yù)言家,5為獵人#endif
occ_card.cpp
#include "occ_card.h"string occ[10][40] = {
{"╔════════════════════════════════════════════════════════╗\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║          狼               人               殺          ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","╚════════════════════════════════════════════════════════╝\n"
},//空
{                      "╔════════════════════════════════════════════════════════╗\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                     你           是                    ║\n","║                                                        ║\n","║                  狼                 人                 ║\n","║                                                        ║\n","║                          !!!                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                  技能:每晚可以殺一個(gè)人                ║\n","║                                                        ║\n","║                       去追隨野性吧!                   ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","╚════════════════════════════════════════════════════════╝\n"},//狼人{(lán)     "╔════════════════════════════════════════════════════════╗\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                     你           是                    ║\n","║                                                        ║\n","║                  平                 民                 ║\n","║                                                        ║\n","║                          !!!                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║               技能:第3的倍數(shù)天投一票等于2票           ║\n","║                                                        ║\n","║                簡(jiǎn)單的單位組成了世間的一切。            ║\n","║                                                        ║\n","║                                    ——艾薩克·牛頓       ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","╚════════════════════════════════════════════════════════╝\n"
},//平民{   "╔════════════════════════════════════════════════════════╗\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                     你           是                    ║\n","║                                                        ║\n","║                 預(yù)         言         家               ║\n","║                                                        ║\n","║                          !!!                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║               技能:每晚可以占卜一個(gè)人的身份           ║\n","║                                                        ║\n","║          當(dāng)世界暴露在徹底的光明之下,人類就毀滅了。    ║\n","║                                                        ║\n","║                                            ——白冰      ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","╚════════════════════════════════════════════════════════╝\n"
},//女巫{    "╔════════════════════════════════════════════════════════╗\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                     你           是                    ║\n","║                                                        ║\n","║                  女                 巫                 ║\n","║                                                        ║\n","║                          !!!                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                 技能:每晚可以殺人或救人               ║\n","║                                                        ║\n","║                 生存還是死亡,這是個(gè)問題。             ║\n","║                                                        ║\n","║                                      ——哈姆雷特        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","╚════════════════════════════════════════════════════════╝\n"
},//預(yù)言家{   "╔════════════════════════════════════════════════════════╗\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                     你           是                    ║\n","║                                                        ║\n","║                  獵                 人                 ║\n","║                                                        ║\n","║                          !!!                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║            技能:被投出后,可以拉一人作為陪葬          ║\n","║                                                        ║\n","║                   任何邪惡終將繩之以法!               ║\n","║                                                        ║\n","║                                      ——吳京            ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","║                                                        ║\n","╚════════════════════════════════════════════════════════╝\n"
} };//獵人
//以上是為了對(duì)齊所做的努力(可能在Windows10又壞了)extern void outp_occ(int x) {//顯示職業(yè),1為狼人,2為平民,3為女巫,4為預(yù)言家,5為獵人system("cls");for (int i = 0; i < 29; i++) cout << occ[0][i];cout << "按任意鍵查看你的身份:";char dianzano = _getch();system("cls");for (int i = 0; i < 29; i++) {cout << occ[x][i];Sleep(300);}
}
狼人殺.cpp
// 狼人殺.cpp : 此文件包含 "main" 函數(shù)。程序執(zhí)行將在此處開始并結(jié)束。
//#include "game.h"
using namespace std;int main()
{srand(time(0));outp_line("歡迎來到狼人殺游戲!\n");outp_line("你要干什么?\n1:開始游戲\n2:查看游戲規(guī)則\n3:退出\n4:游戲信息\n");while (true) {char choose = _getch();if (choose == '2') {cout << "---------------------------------------------------------\n";outp_line("狼人殺游戲規(guī)則如下:\n");outp_line("首先介紹職業(yè):\n");outp_line("1.狼人:在每個(gè)晚上可以殺一個(gè)人,20人場(chǎng)中有2個(gè)狼人,30人場(chǎng)中有3個(gè)狼人;\n");outp_line("2.平民:每晚投票時(shí)可以獲得一次機(jī)會(huì),三的倍數(shù)晚時(shí)投一票等于2票,20人場(chǎng)中有8個(gè)平民,30人場(chǎng)中有12個(gè)平民;\n");outp_line("3.預(yù)言家:每晚可以看見一個(gè)人的身份,如果發(fā)現(xiàn)了狼人,就是走大運(yùn)了,20人場(chǎng)中有2個(gè)預(yù)言家,30人場(chǎng)中有4個(gè)預(yù)言家;\n");outp_line("4.女巫:每晚可以毒死一個(gè)人或者救一個(gè)人,但是毒藥只有3瓶,救藥無限,20人場(chǎng)中有3個(gè)女巫,30人場(chǎng)中有4個(gè)女巫;\n");outp_line("5.獵人:當(dāng)投票被投出時(shí),可以拉一個(gè)人陪葬,20人場(chǎng)中有5個(gè)獵人,30人場(chǎng)中有7個(gè)獵人\n\n");outp_line("接下來說一下其他規(guī)則:\n");outp_line("本游戲中的其他人都是作者手寫很久的人工愚蠢,有這幾條規(guī)則,利用好規(guī)則贏得游戲:\n");outp_line("1.平民每次都會(huì)投上次投他的最后一個(gè)人;\n");outp_line("2.獵人帶走的是最后一個(gè)投他的人;\n");outp_line("3.預(yù)言家如果預(yù)言到狼人,就會(huì)一直投他;如果不是,則不會(huì)投他;\n");outp_line("4.女巫是好人,但是有時(shí)會(huì)腦抽,復(fù)活狼人(親測(cè)這種情況很多);\n");outp_line("5.狼人不會(huì)互殺,投票時(shí)也不會(huì);\n");outp_line("6.如果有人票數(shù)相同,則選編號(hào)靠前的人\n");outp_line("7.會(huì)顯示死的人,但不會(huì)顯示被救的人;\n");outp_line("8.為什么人機(jī)叫人工愚蠢?非常簡(jiǎn)單,因?yàn)樗麄?#xff08;除了預(yù)言家)記不住自己知道的身份\n\n\n");outp_line("好了,游戲的規(guī)則就是這樣了,開始你的狼人殺旅程吧!\n");system("pause");}else if (choose == '1') {begin();break;}else if (choose == '3') {cout << "好的。\n";break;}else if (choose == '4') {cout << "\n游戲版本:1.0版\n";cout << "作者:一尺\(yùn)n";cout << "copyright (c) yichi studios. 保留所有權(quán)利\n";system("pause");}system("cls");cout << "你要干什么!\n1:開始游戲\n2:查看游戲規(guī)則\n3:退出\n4:游戲信息";}system("pause");return 0;
}// 運(yùn)行程序: Ctrl + F5 或調(diào)試 >“開始執(zhí)行(不調(diào)試)”菜單
// 調(diào)試程序: F5 或調(diào)試 >“開始調(diào)試”菜單// 入門使用技巧: 
//   1. 使用解決方案資源管理器窗口添加/管理文件
//   2. 使用團(tuán)隊(duì)資源管理器窗口連接到源代碼管理
//   3. 使用輸出窗口查看生成輸出和其他消息
//   4. 使用錯(cuò)誤列表窗口查看錯(cuò)誤
//   5. 轉(zhuǎn)到“項(xiàng)目”>“添加新項(xiàng)”以創(chuàng)建新的代碼文件,或轉(zhuǎn)到“項(xiàng)目”>“添加現(xiàn)有項(xiàng)”以將現(xiàn)有代碼文件添加到項(xiàng)目
//   6. 將來,若要再次打開此項(xiàng)目,請(qǐng)轉(zhuǎn)到“文件”>“打開”>“項(xiàng)目”并選擇 .sln 文件
                            總結(jié)
                            
                        - 上一篇: 电脑CPU的参数怎么看如何查看电脑的参数
 - 下一篇: 通俗理解神经网络BP反向传播算法