Giter Club home page Giter Club logo

Comments (11)

kolt-mcb avatar kolt-mcb commented on August 11, 2024

dont use the reset when an agent is stuck, use env.change_level(new_level=LVint). feel free to ask more questions

from gym-super-mario.

shinshiner avatar shinshiner commented on August 11, 2024

But I should reach enough score to change level, or it would say env has no attribution:change_level. How to solve it ?

from gym-super-mario.

kolt-mcb avatar kolt-mcb commented on August 11, 2024

I had these same issues, I am using this for a genetic algorithm and specifically need to train on each level, getting to a base score as this env does now is of no use to me. I have a branch on my repo that has as few changes as I could to achieve the functionality I needed. The only reset indicator I use is if the distance increase in a number of steps.


			maxDistance = 0
			oldDistance = 0
			bonus = 0
			bonusOffset = 0
			staleness = 0
			done = False
			env.change_level(new_level=LVint)
			while not done:
				ob = env.tiles.flatten()
				o = genome.evaluateNetwork(ob.tolist(),discrete=True)
				ob, reward, done, _ = env.step(o)
				if 'ignore' in _:
					done = False
					env = gym.make('meta-SuperMarioBros-Tiles-v0')
					env.lock.acquire()
					env.reset()
					env.locked_levels = [False] * 32
					env.change_level(new_level=LVint)
					env.lock.release()
				distance = env._get_info()["distance"]
				if oldDistance - distance < -100 :
					bonus = maxDistance
					bonusOffset = distance
				if maxDistance - distance > 50 and distance != 0:
					maxDistance = distance                    
				if distance > maxDistance:
					maxDistance = distance
					staleness = 0
				if maxDistance >= distance:
					staleness += 1
				if staleness > 80 or done:
					scores.append(maxDistance-bonusOffset+bonus)
					if not done:
						done = True
				oldDistance = distance

I use this is a chunk of code from my current project (you can find this code in my jobtrainer function) to reset and change levels through all 32 levels as well as save scores through pipes, it is rather complicated because the only way to tell if mario has warped through a pipe is checking if his distance jumps more that 50 units, there might be a better unit but this works in practice. again this is using the env branched on my repo, it is hacky and gross but it works. In the future I would like to rewrite this to not have a base score needed to move to the next level and have windows support... big dreams here.

from gym-super-mario.

shinshiner avatar shinshiner commented on August 11, 2024

@koltafrickenfer I have tried your branch and solve this problem perfectly, but there are some little issues:

  1. It seems like your branch also use 'Tiles' version, but the running speed is much slower than original version, is there any way to improve it?
  2. Can I remove the mainmenu and just give mario one life to speed up my game?
  3. Could you please share the main points you modified from original version?

from gym-super-mario.

kolt-mcb avatar kolt-mcb commented on August 11, 2024

I believe only my instructions in my readMe specify to use the tiles version, just remove "-tiles-" from the env string.

If it is running slower than the original I have not noticed??? I run this in a 12 core opteron server with a gtx 1080 and if there is some issue with my branch causing a drop in performance I would love to resolve that.

In ppaquette_gym_super_mario/nes_env.py look for line 51, self.cmd_args = ['--xscale 1.5', '--yscale 1.45', '-f 0','--opengl 1.5','--sound 0','--nogui'] , you can set the cmd line arguments for fceux here. maybe enable your gui / change openGL settings.

from gym-super-mario.

shinshiner avatar shinshiner commented on August 11, 2024

I merge the original NesEnv class and your MetaNesEnv class and solve the speed issue. And is there no way to change the source code of the game, such as set mario in a specified position? Or I can implement this via lua script?

from gym-super-mario.

kolt-mcb avatar kolt-mcb commented on August 11, 2024

you could implement that in the lua script.

from gym-super-mario.

shinshiner avatar shinshiner commented on August 11, 2024

Are you familiar with this lua script? I tried to modified its curr_page and curr_x_position, but I can only move mario in current screen, namely from 0 to 256.

from gym-super-mario.

kolt-mcb avatar kolt-mcb commented on August 11, 2024

I am familiar with the script but I have almost zero knowledge of the inner workings of the emulator/nes hardware.

from gym-super-mario.

shinshiner avatar shinshiner commented on August 11, 2024

Oh, I have solved this problem by reading fceux help files. Thank you very much!

from gym-super-mario.

aryani1 avatar aryani1 commented on August 11, 2024

How did you solve it? @shinshiner

A code snippet would be very appreciated!

from gym-super-mario.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.