This site requires JavaScript, please enable it in your browser!
Greenfoot back

Comments for UserInfo Greeps

Return to UserInfo Greeps

bournebourne

2013/5/9

I've noticed UserInfo sometimes seems to disconnect after long durations of the scenario being paused. (In that it will fail to connect again), and in some instances I have had it fail to store after the first time (Don't believe I had it happen yet on here). Otherwise I don't know why there would be a problem saving the code and scores. I will consider implementing a return statement.
Seems that there is a bug when storing/parsing the setMemory operation argument. I save it as the + argument, but when it executes/loads it treats it as a - argument.
bournebourne

2013/5/9

That explains your error before. Looking into it..
A new version of this scenario was uploaded on Thu May 09 22:11:28 UTC 2013 Fixed bug with setMemory op argument.
A new version of this scenario was uploaded on Thu May 09 22:38:49 UTC 2013 Can change the execution speed when testing with keys 1-3. Where 3 is the fastest. Also made it print your code to the terminal automatically when start testing.
Am I supposed to be able to paste text from the clipboard into the text box? It seems I can copy to clipboard properly, but if I copy from a separate editor such as notepad it does not let me paste that text ingame.
bournebourne

2013/5/10

It's because of applet security. Which case (like here on gallery), it creates a local clipboard within the applet since it cannot access the system clipboard. You can try pasting into the JOptionPane (pressing F6) for inputing code (But may not work either). Printing the code out was just a safeguard for you the user to have your code.
Ah I see, that makes sense. Out of curiosity, I can't find anything in the rules that states you cannot use methods such as getX(), getY(), or getRotation() in the normal Greeps contest, do you know if these methods are allowed?
bournebourne

2013/5/10

I believe they are allowed. But I didn't implement them, since I didn't have implemented ability to store and use values. Wouldn't be too difficult to implement something like checkX(<comp>,<value>), and something similar for the rotation. Would that be useful?
I think it would be exceedingly useful. That way you can know objectively your position and rotation instead of forcing everything to be local. Especially because even with my current program which is pretty complicated I am not even using half the space available.
A new version of this scenario was uploaded on Fri May 10 05:15:38 UTC 2013 Added 4 new methods: checkRotation(<comp>, <degree>) checkX(<comp>, <loc>) checkY(<comp>, <loc>) return()
JetLennitJetLennit

2013/5/13

atWorldEdge() isnt working for me, i have if(atWorldEdge()) { } and it gives a sytax error
danpostdanpost

2013/5/13

@JetLennit, it appears that you must have at least one statement between each set of squiggly brackets.
m_p_v_13m_p_v_13

2013/5/29

Please give more detail on how to use JOptionPane or any other way (besides manually) to copy code into this scenario. I guess some sort of driver that emulates a keyboard at a low level should work.
bournebourne

2013/5/30

@m_p_v_13, Because of applet security restrictions, it cannot access the System clipboard. Some sort of keyboard emulator sounds like something you would have on your computer - not something I can implement within the scenario. Your code gets saved (after running all 10 maps). (And outputted to terminal just as a safeguard). The idea was that you edit your code within the scenario.
m_p_v_13m_p_v_13

2013/6/1

@bourne, Thanks for the response. I did find a keyboard emulator (WinKeySim) but I am wary of installing these kind of apps as others must be also. The online score keeping greeps is a great idea. Can you think of any way to have users submit java files? It would not have to be interactive, since users can do that locally. For example, have an email address to which one can send a java file from ones registered email address and get a reply with the results as well placement in high scores and userinfo.
bournebourne

2013/6/1

I can think of no way systematically without simply giving out an email which can be used to submit the java files, which then can be ran/tested, and it wouldn't be difficult to update the scenario or add admin functionality for the scenario (may not work because UserInfo.store() I believe only works for the active UserInfo) for posting results/high-scores From the API: UserInfo.store() "You can only store data for the current user (that is, data retrieved using getMyData). If you try to store data for any user other than the current user, it is guaranteed to fail." So you would have to go the updating the scenario with results approach. (i.e. high scores / results stored within a text file included with the scenario with associations to particular User names)
danpostdanpost

2013/6/1

The only other option is to share your UserName and Password (whether by email or some other method) so someone else could run the scenario using your info.
m_p_v_13m_p_v_13

2013/6/4

danpost, How about the following? Create a 2nd load option into which you enter the url (e.g. on a google drive with public access) of the greep java code. That code is then retrieved and put into the scenario screen as if it were typed.
danpostdanpost

2013/6/4

@m_p_v_13, I do not believe that would be possible on the site due to security issues.
m_p_v_13m_p_v_13

2013/6/5

danpost, I tried it out using the Java URL Class. It fails if run on this site and works OK run from my machine. See my scenario called "test". At what level/layer is just getting a file disallowed (e.g. Greenfoot, server, firewall,...) Aren't you a superuser of sorts?
danpostdanpost

2013/6/5

When the scenario runs in Greenfoot, it can read and save files all day long. When it runs in the Gallery, it cannot access (read or write) any files at all. This is a Java security measure for applets (programs running in web browsers). If this was not the case, just browsing the Gallery would be very dangerous: Any scenario could read your email and forward (or publish) it anywhere it likes. Or it could overwrite your files. As it is, you're safe. But you cannot (easily) save files.
m_p_v_13m_p_v_13

2013/6/5

danpost, bourne, We don't need to save a file, just read it, like the browser does. I think applet permissions can be configured for specific benign reading, but I understand wanting to be super safe. Can I write a scenario to store a string (the Java greep code) in UserInfo that can be accessed (only) by the "UserInfo Greeps" scenario? If, so, any user so inclined can write a scenario that includes their greep code in a string variable and when run in the Gallery copies that string to UserInfo. (The scenario should of course not include source). The "UserInfo Greeps" scenario would then load code from this string (possibly via a seperate "load" option). If that could work, a utility class could be developed, which users include in their local Greep development environment which has methods to save the Greep code in a variable in a java file for and load it from that "file" into the UserInfo variable.
danpostdanpost

2013/6/5

If I am not mistaken, you are saying something like having two scenarios: one with your Greeps code and the other being the Greeps scenario itself and have one access a file within the other's folder. Again, on the site, you cannot do this due to security restrictions. On the site, you can only access files within that scenarios folder.
davmacdavmac

2013/6/5

m_p_v_13: I think you're suggesting that one scenario store something in the UserInfo database so that another scenario can read it. This won't work unfortunately, as all scenarios effectively have their own database - one can't read from the database of another.
m_p_v_13m_p_v_13

2013/6/5

So it's not so much UserInfo as UserScenarioInfo or ScenarioInfo ;l )
bournebourne

2013/6/5

Correct. UserInfo per scenario.
Super_HippoSuper_Hippo

2013/6/5

Could it be that it only saves the last score and not the best? I had 8 or so before and now i have 0 again.
danpostdanpost

2013/6/5

@Super_Hippo, what is saved is determined by how the scenario was programmed. Just with any instruction: good instruction, good results; poor instruction, poor results (not saying that not saving the best score is always what one wants to do).
Super_HippoSuper_Hippo

2013/6/5

Yes, I know, I only wanted to know whether I am doing something wrong or if it is like that for everyone. And if bourne could maybe solve it. I do not know if he knew that issue.
You are correct that is saves the most recent score, and not the best. I'm pretty sure this is intentional by bourne, but you will have to wait for a response.
bournebourne

2013/6/6

It was my intention for recording most recent score. So that it reflects your current code, and so that it perhaps removes temptation to run the same code over and over in hopes of getting most optimal results - without consequence (losing a decent score). Furthermore, I think it reflects the feeling of the real Greeps competition - you run your Greeps through the maps and that's your new score.
DonaldDuckDonaldDuck

2013/6/7

Hit a best of 61 but then started goofing ;) Either way, I love it but it's so structured. Possibilities to introduce variables and custom RGB colors could strongly benefit my score :)
bournebourne

2013/6/7

This scenario is based off of the official Greenfoot Greeps competition. So custom RGB colors for the paint wouldn't be following the rules. Also you can't extend the Greep's "memory" (local variables would be allowed - which I realize there are these limitations with my given implementation). More info found here: http://www.greenfoot.org/competition/greeps/
bournebourne

2013/6/7

Also I think I found a way to allow copy and paste from the system clipboard. Let me know if it works for you. By following this tutorial: http://www.shodor.org/interactivate/resources/InstructionsCopyPaste/#policytool
danpostdanpost

2013/6/7

@DonaldDuck, I know that you are not allowed to add instance or class fields to the Greep class, unless they are final fields. However, they do not explicitly disallow local fields (those whose scope ends when the method they are in has completed its execution).
danpostdanpost

2013/6/7

@bourne, might be good to include the rules within the scenario.
m_p_v_13m_p_v_13

2013/6/8

@bourne, That link for setting Java policy worked for me. Many thanks!
bournebourne

2013/6/8

Included a link to the rules for the official competition. So if you are not familiar with them. Though my scenario hides any avenues of cheating I believe.
Very impressive! I think what donald duck meant was that you had made a mini IDE with Greenfoot.
A new version of this scenario was uploaded on Thu Nov 21 19:54:51 UTC 2013 Preparation for a project coming soon.
JohnShererJohnSherer

2014/3/24

Hey, no copy and paste? I had been working on this for a long time (my average is around 100 tomatoes on the first three maps) but now I can't show you guys my code?
bournebourne

2014/3/24

@JohnSherer, first via the rules and nature of the competition, code should not be shared. Note your code should be saved on the scenario, and I believe it is printed out to the console. Lastly, there is a way to get copy and paste to share the clipboard with your system clipboard, mentioned in the scenario description above.
JohnShererJohnSherer

2014/3/25

Sorry, what I meant when I said "show you my code" is "show you how my Greeks move with the code I wrote." I was studying Greenfoot and the greeps competition before I saw this page. I do see a link for how to copy and paste, but it looks like too much effort. Anyway, your score is higher than mine, so it's not like I was going to crack any records.
bournebourne

2014/3/25

@JohnSherer, the ability to show others how your Greeps move is not implemented here since I don't think it would be desired. Watching how Greeps move can shed a lot of light on what the code is doing such as how the code uses the different elements such as the paint the Greeps spit. I don't see a score for you, were you not running your code in this scenario here onsite?
Super_HippoSuper_Hippo

2014/3/25

I think his point is that he has a code, but not here in your scenario and he wants to import this code, so others can see his score.
m_p_v_13m_p_v_13

2014/12/9

Did something break? I get an error on the initialization (after run and before I ever see anything). Caused by: java.security.AccessControlException: access denied ("java.net.SocketPermission" "129.12.3.237:8888" "connect,resolve")
JetLennitJetLennit

2014/12/9

Are you in java 8?
NikZNikZ

2014/12/9

Yeah, 8 tightened security.
RidicolasRidicolas

2016/11/27

doesn't work