Skip to content

Commit

Permalink
完善简单界面
Browse files Browse the repository at this point in the history
  • Loading branch information
golitter committed May 12, 2024
1 parent 7c92433 commit dbea8ff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/input_processor.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once
#include "A_star.h"
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
namespace EightPuzzleInput {

// 开始
Expand Down
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ int main(int, char**){
// test_Cantor();
// test_Ev();
// EightPuzzleInput::start();
test_Eight();
// test_Eight();
// test_TEST();
EightPuzzleInput::start();
}
4 changes: 3 additions & 1 deletion src/A_star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void IDDFS(int zero_pos, std::vector<int> init_stat) {
arr = init_stat;
int mhd = EvaluationFunctions::mhd(arr);
if(mhd == 0) { // 对0特判
std::cout<<0<<std::endl;
std::cout<<"输入初始状态即为目标状态"<<std::endl;
return ;
}
// std::cout<<mhd<<std::endl;
Expand All @@ -122,6 +122,8 @@ void IDDFS(int zero_pos, std::vector<int> init_stat) {
// std::cout<<max_depth<<std::endl;
std::cout<<"最大深度(max_depth): "<< std::left<<std::setw(5)<<max_depth<<std::endl;
std::cout<<"结束"<<std::endl;

std::cout<<"\n"<<std::endl;
}

// void dispose()
Expand Down
11 changes: 10 additions & 1 deletion src/input_processor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../include/input_processor.h"
#include <cstdio>


namespace EightPuzzleInput {

Expand Down Expand Up @@ -72,6 +72,15 @@ void input_init_stat() {
std::cout<<"初始状态为:"<<std::endl;
printBoard(init_stat);
std::cout<<std::endl;
std::cout<<"正在处理......"<<std::endl;
int pos = 0;
for(int i = 0; i < 9; ++i) {
if(init_stat[i] == 0) {
pos = i;
break;
}
}
IDDFS(pos, init_stat);
}

// void input_target_stat() {
Expand Down

0 comments on commit dbea8ff

Please sign in to comment.