my solutions

The Partridge Family were neither partridges nor a family. Discuss.
randomGuy
Posts: 32
Joined: May 31st, 2018, 11:45 am

Re: my solutions

Post by randomGuy » June 19th, 2018, 4:13 am

Slidy, can you give me a hint? The solver is dope and I'm curios how it works.

Guys, yestarday airbags just randomly deployed in a car I was in and my right ear got fucked from the
blast.These things create a brief and intense pressure wave which can cause hearing loss, hopefully it's not permanent. Going to see doctor today.

Slidy
Posts: 80
Joined: September 9th, 2017, 1:19 pm

Re: my solutions

Post by Slidy » June 19th, 2018, 4:41 am

Sorry to hear that man, hope you're ok :(

Making the solver is actually simpler than it seems. You have the source code to Chili's Werd Game on GitHub, which makes things a lot easier. You know exactly how the score is calculated, and you know exactly what words are used in the list.

Knowing all of this, you can try to "replicate" that behaviour in a solver and eliminate what words it can't be based on what score the Werd Game bot gives you.

The hardest part was actually making the solver automated on discord by using the Discord.NET API to parse and respond to Chili's bot.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: my solutions

Post by chili » June 19th, 2018, 3:38 pm

tsk tsk Slidy
Self bots are not sanctioned by the Discord overmench.
Chili

Slidy
Posts: 80
Joined: September 9th, 2017, 1:19 pm

Re: my solutions

Post by Slidy » June 19th, 2018, 3:45 pm

They were allowed at the time when I made this as long as you didn't use it to spam/advertise, but seems they recently made them completely banned.

Looks like they don't enforce this all that well though, I used it about 10 times today, spamming around 10 messages each time and my account hasn't been banned yet, so jokes on you Discord overmench!

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: my solutions

Post by chili » June 19th, 2018, 3:52 pm

Nah, you'd have to be pretty dumb/obvious with it to get any sort of consequences. Enjoy your contraband botting you renegade.
Chili

randomGuy
Posts: 32
Joined: May 31st, 2018, 11:45 am

Re: my solutions

Post by randomGuy » June 21st, 2018, 6:37 pm

Code: Select all

std::string solve(std::vector<std::string>& filteredWordsCopy, std::string target) {
	std::mt19937 rng(std::random_device{}());
	std::uniform_int_distribution<int> dist(0, filteredWordsCopy.size() - 1);
	const std::string guessedWord = filteredWordsCopy[dist(rng)];
	int targetScore = score_match(guessedWord, target);

	std::vector<std::string> intersection;
	
	for (const auto& w : filteredWordsCopy)
	{
		if (score_match(w, guessedWord) >= targetScore && w != guessedWord)
		{
			intersection.push_back(w);
			
		}
	}
	filteredWordsCopy= intersection;
	return guessedWord;
}

int main()
{
..
while( true )
	{
	std::cout << "Guess a five letter word: ";
	std::string guess;
	guess = solve(filetered_word2, target);
..


Am I on the right track? This works but it sometimes takes 20 guesses which I think is a lot.

Slidy
Posts: 80
Joined: September 9th, 2017, 1:19 pm

Re: my solutions

Post by Slidy » June 22nd, 2018, 5:38 am

Yeah that seems pretty good, but you can eliminate more words based on the guess. You're only eliminating words that have a score less than the targetScore, but if you think about it you can eliminate any word that has a score not equal to the targetScore. After doing that, the number of attempts it takes should go down, my lowest was about 4.

randomGuy
Posts: 32
Joined: May 31st, 2018, 11:45 am

Re: my solutions

Post by randomGuy » June 26th, 2018, 3:07 pm

Thank you Slidy, works better now.

Homework on Tutorial 13 is to modify the Animation class so that it draws the sprite frames with a translucent "ghost" effect. Are we allowed to modify any other class?

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: my solutions

Post by albinopapa » June 26th, 2018, 7:30 pm

Shouldn't need to if I recall correctly. You are to create a SpriteEffect I believe, to pass in as a parameter, but it's been awhile since going over that section.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

randomGuy
Posts: 32
Joined: May 31st, 2018, 11:45 am

Re: my solutions

Post by randomGuy » June 27th, 2018, 3:53 pm

I couldn't do it from the animation class but got it working by modifying the graphics class.

Code: Select all

Color Graphics::getPixel(int x, int y)
{
	return pSysBuffer[Graphics::ScreenWidth * y + x];
}

void DrawSprite( int x,int y,RectI srcRect,const RectI& clip,const Surface& s,Color chroma = Colors::Magenta );
...
...
...
	for( int sy = srcRect.top; sy < srcRect.bottom; sy++ )
	{
		for( int sx = srcRect.left; sx < srcRect.right; sx++ )
		{
			Color srcPixel = s.GetPixel( sx,sy );

			if( srcPixel != chroma )
			{
				Color gfxColor = getPixel(x + sx - srcRect.left, y + sy - srcRect.top);
				Color newColor;
				
				newColor.SetB((srcPixel.GetB() + gfxColor.GetB())/ 2);
				newColor.SetR((srcPixel.GetR() + gfxColor.GetR()) / 2);
				newColor.SetG((srcPixel.GetG() + gfxColor.GetG()) / 2);

				PutPixel( x + sx - srcRect.left,y + sy - srcRect.top, newColor);
			}
		}
	}
In Game::ComposeFrame() Character link is drawn last.

This works but I wanted to make it so the foreground object is drawn with percentage transperancy which is passed in DrawSprite as a paramether. Could not figure out the formula though.

Post Reply