Skip to content

Commit

Permalink
Added backtrack algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykorir committed May 24, 2024
1 parent e37bbad commit bc94488
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ jobs:
# run: |
# sudo chmod +x script.sh && ./script.sh

- name: set priviledge
run: |
sudo su && ls -al
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down
Binary file modified bin/Debug/minesweeper
Binary file not shown.
15 changes: 11 additions & 4 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ wxButton * Field::GetButton()
void Field::OnButtonClick(wxCommandEvent& event)
{
button->SetFont(wxFont(13, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false));
button->SetLabel(wxString::Format(wxT("%d"),type));
button->Enable(false);
button->SetForegroundColour(wxColor(0,255,0));

MainFrame * parent = dynamic_cast<MainFrame*>(GetParent());
parent->UnCover(x,y);
if(type == FIELD_MINE)
{
button->SetForegroundColour(wxColor(255,0,0));
button->SetLabel("M");
}
else
{
button->SetForegroundColour(wxColor(0,255,0));
MainFrame * parent = dynamic_cast<MainFrame*>(GetParent());
parent->UnCover(x,y);
}
}

wxBEGIN_EVENT_TABLE(Field, wxPanel)
Expand Down
7 changes: 7 additions & 0 deletions minesweeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ void MainFrame::UnCover(int x, int y)

matrix[x][y]->GetButton()->SetLabel(wxString::Format("%d",countMines));
visited[matrix[x][y]->GetID()] = true;

if(st.empty()) return;
Field * top = st.top();
st.pop();

UnCover(top->GetX(), top->GetY());

}

wxDECLARE_APP(Minesweeper);
Expand Down
6 changes: 3 additions & 3 deletions minesweeper.depend
Original file line number Diff line number Diff line change
Expand Up @@ -1631,21 +1631,21 @@
1714995324 source:/home/freedom/Desktop/work/minesweeper/minesweeper/minesweeper.cpp
"wx/wx.h"

1716060291 source:/home/freedom/Desktop/work/minesweeper/minesweeper.cpp
1716585350 source:/home/freedom/Desktop/work/minesweeper/minesweeper.cpp
"wx/wx.h"
<stdlib.h>
"minesweeper.h"
"field.h"

1716060291 source:/home/freedom/Desktop/work/minesweeper/field.cpp
1716585559 source:/home/freedom/Desktop/work/minesweeper/field.cpp
"wx/wx.h"
"field.h"
"minesweeper.h"

1716060291 /home/freedom/Desktop/work/minesweeper/field.h
"wx/wx.h"

1716060291 /home/freedom/Desktop/work/minesweeper/minesweeper.h
1716583035 /home/freedom/Desktop/work/minesweeper/minesweeper.h
"wx/wx.h"
"wx/stack.h"
"field.h"
Expand Down
Binary file modified obj/Debug/field.o
Binary file not shown.
Binary file modified obj/Debug/minesweeper.o
Binary file not shown.

0 comments on commit bc94488

Please sign in to comment.