ValidAIs.lua - Page 7

ValidAIs.lua

Requests for features in the spring code.

Moderator: Moderators

raaar
Metal Factions Developer
Posts: 795
Joined: 20 Feb 2010, 12:17

Re: ValidAIs.lua

Post by raaar » 03 Jul 2018, 06:27

meanwhile, a new player tried MF and went into a battle against AI. Did he pick MFAI? of course he didn't. He picked some other AI which idled throughout...

The lack of standardized AI filter for games after all this time is incompetence or negligence, or both. Gross.

Then we complain about poor player retention.
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14564
Joined: 17 Nov 2005, 02:43

Re: ValidAIs.lua

Post by Forboding Angel » 03 Jul 2018, 08:04

raaar wrote: We NEED a standard way for games to define this for the lobbies, and maybe even for the engine itself.
Most of us have resorted to stripping it out of the engine that we distribute. If you aren't distributing your own build then I dunno what to tell you. I highly recommend putting metal factions on itch.io
0 x

gajop
Moderator
Posts: 3020
Joined: 05 Aug 2009, 20:42

Re: ValidAIs.lua

Post by gajop » 03 Jul 2018, 10:31

It's an open source project and you are completely responsible for everything your game uses: lobby client, server, engine, infra.
If you delegate any of this responsibility to other people you cannot complain if things aren't perfect
1 x

raaar
Metal Factions Developer
Posts: 795
Joined: 20 Feb 2010, 12:17

Re: ValidAIs.lua

Post by raaar » 03 Jul 2018, 16:30

That line of thought leads to incompatible packages for each game (lobby, engine, etc.) that break other games. It won't end well.

Shared environment won't work without standards.

There's no point in making a modified lobby if 90% of the potential players access the game through either the official springlobby or some of those other packages.

It's not like i'm asking for some exotic feature here...
2 x

raaar
Metal Factions Developer
Posts: 795
Joined: 20 Feb 2010, 12:17

Re: ValidAIs.lua

Post by raaar » 08 Jan 2019, 17:27

buuump
1 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14564
Joined: 17 Nov 2005, 02:43

Re: ValidAIs.lua

Post by Forboding Angel » 09 Jan 2019, 02:04

I genuinely don't understand why this doesn't already exist.
1 x

User avatar
ThinkSome
Posts: 260
Joined: 14 Jun 2015, 13:36

Re: ValidAIs.lua

Post by ThinkSome » 28 Apr 2019, 01:14

Everyone asks about ValidAIs.lua, but what about InvalidAIs.lua? :lol:

Code: Select all

diff --git a/src/gui/hosting/addbotdialog.cpp b/src/gui/hosting/addbotdialog.cpp
index 3580e24e7..010d0c75d 100644
--- a/src/gui/hosting/addbotdialog.cpp
+++ b/src/gui/hosting/addbotdialog.cpp
@@ -9,6 +9,7 @@
 #include <wx/dir.h>
 #include <wx/filename.h>
 #include <wx/listctrl.h>
+#include <wx/log.h>
 #include <wx/sizer.h>
 #include <wx/statline.h>
 #include <wx/stattext.h>
@@ -23,6 +24,11 @@
 #include "utils/conversion.h"
 #include "utils/lslconversion.h"
 
+static const char *banned_AIs[] = {
+	"AAI", "CircuitAI", "CppTestAI",
+	"E323AI", "KAIK", "NullAI", "RAI", "Shard"
+};
+
 BEGIN_EVENT_TABLE(AddBotDialog, wxDialog)
 EVT_BUTTON(ADDBOT_CANCEL, AddBotDialog::OnClose)
 EVT_BUTTON(ADDBOT_ADD, AddBotDialog::OnAddBot)
@@ -138,7 +144,7 @@ wxString AddBotDialog::GetNick()
 
 wxString AddBotDialog::Get(const std::string& section)
 {
-	const auto sel = m_ai->GetSelection();
+	const auto sel = GetAIType();
 	const auto infos = LSL::usync().GetAIInfos(sel);
 	const auto namepos = LSL::Util::IndexInSequence(infos, section);
 	if (namepos == LSL::lslNotFound)
@@ -158,7 +164,7 @@ wxString AddBotDialog::GetAIVersion()
 
 int AddBotDialog::GetAIType()
 {
-	return m_ai->GetSelection();
+	return m_valid_ai_index_map.at (m_ai->GetSelection());
 }
 
 wxString AddBotDialog::RefineAIName(const wxString& name)
@@ -179,19 +185,39 @@ wxString AddBotDialog::GetAiRawName()
 {
 	//    if ( m_ais.GetCount() < m_ai->GetSelection() )
 	//        return wxEmptyString;
-	return m_ais[m_ai->GetSelection()];
+	return m_ais [GetAIType()];
 }
 
 void AddBotDialog::ReloadAIList()
 {
+	LSL::StringVector ais;
 	try {
-		m_ais = lslTowxArrayString(LSL::usync().GetAIList(m_battle.GetHostGameName()));
-	} catch (...) {
+		ais = LSL::usync().GetAIList(m_battle.GetHostGameName());
+	} catch (std::exception& ex) {
+		wxLogWarning("Exception while loading AIs: " + wxString(ex.what()));
 	}
 
 	m_ai->Clear();
-	for (unsigned int i = 0; i < m_ais.GetCount(); i++)
-		m_ai->Append(RefineAIName(m_ais[i]));
+	m_ais.clear();
+	m_valid_ai_index_map.clear();
+	for (unsigned int i = 0; i < ais.size(); ++i) {
+		std::string &AINameVersion = ais.at(i);
+		bool matched = false; // either this or goto...
+
+		for (unsigned int j = 0; j < sizeof (banned_AIs) / sizeof(char *); ++j) {
+			const char *ai_str = banned_AIs[j];
+			if (std::string::npos != AINameVersion.find(ai_str)) {
+				matched = true;
+				break;
+			}
+		}
+		if (!matched) {
+			wxString wxAINV (AINameVersion);
+			m_ais.Add(wxAINV);
+			m_ai->Append(RefineAIName(wxAINV));
+			m_valid_ai_index_map.push_back(i);
+		}
+	}
 	if (m_ais.GetCount() > 0) {
 		m_ai->SetStringSelection(sett().GetLastAI());
 		if (m_ai->GetStringSelection() == wxEmptyString)
diff --git a/src/gui/hosting/addbotdialog.h b/src/gui/hosting/addbotdialog.h
index 334c99747..da7c34ccf 100644
--- a/src/gui/hosting/addbotdialog.h
+++ b/src/gui/hosting/addbotdialog.h
@@ -5,7 +5,10 @@
 
 #include <wx/dialog.h>
 #include <map>
+#include <vector>
+
 #include "gui/windowattributespickle.h"
+
 class wxTextCtrl;
 class wxStaticText;
 class wxChoice;
@@ -72,6 +75,7 @@ private:
 
 	bool m_sp;
 
+	std::vector<int> m_valid_ai_index_map;
 	wxString RefineAIName(const wxString& name);
 
 	enum {
This is a gift to raaar for playing s44 with me. Enjoy.
2 x

raaar
Metal Factions Developer
Posts: 795
Joined: 20 Feb 2010, 12:17

Re: ValidAIs.lua

Post by raaar » 28 Apr 2019, 02:02

Having defaults is fine as a short-term fix but in either case it should be a config property.

That way whoever wants to test AIs could remove them from the banned list.
0 x

Post Reply

Return to “Feature Requests”