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.
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.
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?
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()
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.
@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.
@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.
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)
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.
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.
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?
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.
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.
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.
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.
@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).
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.
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.
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 :)
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/
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
@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).
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.
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?
@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.
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.
@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?
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")
2013/5/9
2013/5/9
2013/5/9
2013/5/10
2013/5/10
2013/5/10
2013/5/10
2013/5/10
2013/5/13
2013/5/13
2013/5/29
2013/5/30
2013/6/1
2013/6/1
2013/6/1
2013/6/4
2013/6/4
2013/6/5
2013/6/5
2013/6/5
2013/6/5
2013/6/5
2013/6/5
2013/6/5
2013/6/5
2013/6/5
2013/6/5
2013/6/6
2013/6/6
2013/6/7
2013/6/7
2013/6/7
2013/6/7
2013/6/7
2013/6/8
2013/6/8
2013/6/8
2014/3/24
2014/3/24
2014/3/25
2014/3/25
2014/3/25
2014/12/9
2014/12/9
2014/12/9
2016/11/27