Assaf-Alon / pvz_ai_project

MCTS implementation that plays Plants vs. Zombies in C++
2 stars 0 forks source link

Difficulty Running the Project and Compilation Errors #27

Open bjutedu24 opened 6 days ago

bjutedu24 commented 6 days ago

Dear Professor, Greetings from Hong Kong Polytechnic University (PolyU) ! My name is Christopher Young, and I'm currently a second-year undergraduate student studying Sofware Engineering. I recently came across your fascinating project on PVZ AI using MCTS.

However, I have encountered some issues while attempting to run the project .Despite carefully following the instructions in the README and , I am unsure if I correctly configured the environment or installed all dependencies.

-My environment: VSCODE、WSL with Ubuntu-24.04

Compilation Errors: During the "Make" process, I encountered the following errors:

  1. A type mismatch when calling the method ( vs ).rolloutLossHeuristic*int
  2. Undefined references to in the class.plant_dataLevel
  3. Several mismatches in method parameters (e.g., being called with three arguments instead of the expected two).timed_rollout

Error Screenshots as follows: 1 2

These errors suggest either missing configurations or misinterpretation of the intended logic in certain sections. I would be grateful for any clarification or advice you could provide!

bjutedu24 commented 6 days ago

After fixing my Python3-dev environment and putting some code files into cpp_env folder(eg. level.hpp plant.cpp zombie.cpp), I executed make clean && make -j8 ,but with following errors: image

I don't understand how this works, plz help.

dgershko commented 6 days ago

Hi! We're not professors, just undergrad students like you! I've made a few fixes to the codebase (we changed the name of the folder containing the actual game implementation from cpp_env to game_engine, and probably forgot to push the changes to imports in some files!) Try pulling again and see if it works now. Also, in case you encounter issues with missing Python.h, make sure you change the python version in the Makefile to the one you are currently using (3.10, 3.11, etc.)

Out of curiosity, what is your interest in this work? I'd be really interested to know how this project could be of use to others, as we worked on it for almost a year.

bjutedu24 commented 6 days ago

Hi! We're not professors, just undergrad students like you! I've made a few fixes to the codebase (we changed the name of the folder containing the actual game implementation from cpp_env to game_engine, and probably forgot to push the changes to imports in some files!) Try pulling again and see if it works now. Also, in case you encounter issues with missing Python.h, make sure you change the python version in the Makefile to the one you are currently using (3.10, 3.11, etc.)

Out of curiosity, what is your interest in this work? I'd be really interested to know how this project could be of use to others, as we worked on it for almost a year.

Hi there! Thanks for your reply! 😊

The issues with missing Python.h have been fixed, I installed the Python 3.12.3-Dev which includes Python.h file.

We’re currently taking an elective course on machine learning, and our professor introduced some fascinating examples of using machine learning algorithms to play games. I find this incredibly interesting! By the way, I love playing PVZ , and I had this idea of training an AI to play PVZ. While exploring this topic, I stumbled upon your project, pretty cool!

However, I’ve run into some issues while trying to use your project. For example, even after carefully following the instructions in the readme.md file, I encountered the following error when running the command make clean && make -j8:

rm game_engine/level_wrap.cxx
rm: cannot remove 'game_engine/level_wrap.cxx': No such file or directory
make: *** [Makefile:109: clean] Error 1

If possible, could you please provide or update a workable version of the project files and upload it to GitHub? That would help me. Additionally, I’d love to connect and exchange contact information(like WhatsApp or facebook), as I’m very interested in researching similar algorithms and applying them to AI game-playing studies. I’m looking forward to chatting and learning more from you. Thank you so much in advance! 🌟

dgershko commented 5 days ago

Try compiling with 'make' instead of 'make clean && make -j8' (make clean is meant to delete the intermediate files used by the compilation process, and fails as you dont have them before ever running make)

bjutedu24 commented 5 days ago

Try compiling with 'make' instead of 'make clean && make -j8' (make clean is meant to delete the intermediate files used by the compilation process, and fails as you dont have them before ever running make)

Got it, Appreciate! I’ve successfully built and run main.py. However, I’m facing some issues with displaying the results generated by Matplotlib.

I’ve tried using VcXsrv and GNOME to show the images generated by Matplotlib, but unfortunately, it hasn’t worked. After running main.py, I couldn’t see any results or the game scene. With following results: image image

How can I get real game screen just like pictures in demo folder? Could you kindly advise if there’s a method to visualize how the game plays through MCTS?

Thank you so much for your time and patience!

Best regards,

Assaf-Alon commented 1 day ago

Hello friend! Sorry for the confusion, the demo directory is historical from our initial fork of the GitHub project by marblexu, which we should've deleted when refactored the repo. Sadly, using a proper game GUI was removed from the project scope because it required significantly more effort than we initially estimated.

We implemented a simple GUI to understand what the agent is doing, and you should see it when running the main.py file image

We'll update the demo directory to avoid further confusion 🙏