« first day (220 days earlier)      last day (3641 days later) » 

00:01
I knew that was going to be a problem! I just fixed it today so that the text in the left hand corner did not cover the help menu. I went ahead and made it that way for all menus, but I realized that you would have to open and close the trade menu to see your resources.. should have fixed it :)
thanks for the feedback!
No problem, good work!
How do you tell when you own a region?
00:17
your name will pop up underneath it at the top
How would the game know my name? o.O
Oh, I guess my name is singlePlayer :D
3
00:35
@bazola You'll have to remind me about your question another time.
2
^^ that's how they remind people in the VBA room.
 
2 hours later…
02:25
@bazola There is something I notice gameplay wise (perhaps I'm missing something about the game) it feels tedious... I don't know if you ever played a game like Farmville but that's kind of what it feels like to me... Put crops/buildings down, wait a while, go harvest/take from it, rinse & repeat
 
11 hours later…
13:46
Hey everyone!
hey @Marc-Andre
half-sick hey
14:03
@skiwi Are you resting ? I do hope so!
Incoming SFPEQ! (Simon Forsberg Project Euler Question)
@skiwi How are we feeling today?
@SimonAndréForsberg I'm feeling somewhat better... though not sitting behind my desktop PC yet
@SimonAndréForsberg For a second I've read SPQR !! I was like what has the roman empire do with here :P
well I got the XML working using the libGDX classes @SimonAndréForsberg:
    public void saveGameToXML() throws IOException {
        StringWriter writer = new StringWriter();
        XmlWriter xml = new XmlWriter(writer);
        try {

            xml.element("regions");
            for (Region region : this.world.closebyRegionsForPosition(this.player.position())) {
                xml.element("region")
                    .attribute("wP", region.worldPosition().toString())
                    .attribute("tp", region.biomeType.ordinal())
                    .attribute("n", region.getName())
what is interesting about saving to XML (and I guess any text or string based format) is that shorter variable names will equal less space on the disk
i cut off about 4 megabytes of the save file just by shortening the variable names to one or two letters
@bazola if you are aiming for low disk usage, XML is not really the best format to pick :)
3
14:19
@SimonAndréForsberg well everything I read recommended against Java serialization. But it was much faster and generated much smaller files :)
@bazola There are other alternatives as well though. DataOutputStream is really the best IMO if you are aiming for low disk usage.
You should ask yourself if Disk usage is really a problem though.
as long as I use the shortened variable names I think it is acceptable. But it bothers me because XML is supposed to be human readable, and the output I am generating definitely isn't
Also ask yourself if the format should be humanly readable or not :) On Android, if you use the external storage, the files is readable by other apps, and there are plenty of editors you can use to edit such files.
@bazola what is the output?
<regions>
	<region wP="3,2" tp="5" n="Wetecron" oN="null">
		<t p="2,1" tp="7" b="0"/>
		<t p="6,5" tp="6" b="0"/>
		<t p="2,2" tp="2" b="0"/>
		<t p="6,6" tp="2" b="0"/>
		<t p="2,3" tp="7" b="0"/>
		<t p="6,7" tp="7" b="0"/>
		<t p="2,4" tp="6" b="0"/>
		<t p="6,8" tp="4" b="0"/>
		<t p="2,5" tp="1" b="0"/>
		<t p="6,9" tp="1" b="0"/>
		<t p="2,6" tp="7" b="0"/>
		<t p="6,10" tp="7" b="0"/>
		<t p="2,7" tp="7" b="0"/>
		<t p="2,8" tp="2" b="0"/>
		<t p="2,9" tp="6" b="0"/>
		<t p="2,10" tp="1" b="0"/>
I'd say that's quite readable.
Although there are plenty of ways to reduce the size of that data.
14:25
by just using binary instead of strings?
@bazola You can remove the pretty output. Space and newlines take space
@bazola essentially, all the <t p="1,10" data is useless. Instead if you transform the data into pure binary form, each tile is two bytes (assuming you only need values from 0-255). If it's 6*10 tiles per region, that's 120 bytes per region.
However, ask yourself how common it is for tiles to have buildings, it might save more space if you store building information separately, as a "List of buildings" thing - but then you will also need to store the position for each building.
@SimonAndréForsberg yeah that is a good point
i'm also now converting variables to static to limit the amount of things I need to write to disk when saving
@bazola whoa, wait... what?
converting variables to static?
how will that reduce the number of things needed to write to disk?
right now I have a couple of instance variables that I don't really need to store on disk, I can just make them static and public
instead of passing them as arguments
14:41
are they constants?
yeah
phew
make them final as well in that case
lol
	public static final int numTilesPerRow = 7;
	public static final int numRows = 11;
	public static final Random random = new Random();
of course I have to make them CAPITALIZED also
There is a keyword too or an annotation to skip things when seriliazing (to xml or using serializable) (transient and the annotation depends on your library)
@Marc-Andre at the moment I am still manually building the XML with the libGDX library
14:52
@bazola Ok there are framework that could do it for you if you serialize more things, you could use json too. Less verbose and can be as readable as xml.
using JSON would be a step forward, I think. LibGDX does support that.
@Marc-Andre some frameworks are not possible to use when GWT compatibility is desired.
@SimonAndréForsberg I'm sure there are some cool library you can use for that even if you needed to be GWT compatible.
@Marc-Andre I suspect that there's only a few such libraries, actually. And what's worse, I don't know which. You'd be surprised at how many things are not compatible with GWT.
I'm surprised about with how many things GWT is incompatible ;)
@skiwi The good news though is that in a few months, GWT will be compatible with Java 8
15:05
@SimonAndréForsberg Now I understand a bit more about GWT. You're coding in Java, but everything (client code) is transformed in JavaScript or run server-side. Then well it's normal that most library won't work. If it's using JavaScript, I strongly suggest JSON then.
@Marc-Andre Exactly. Now explain this to @skiwi that it's no wonder a lot of things is incompatible with GWT.
In fact, I'd say that it's a miracle GWT exists and works at all.
@SimonAndréForsberg #Google
so JSON is better because it will be less characters because of the syntax? or some other reason?
15:24
Syntax and some other reason. On most case, json will take less space than xml. But the thing to know is that json can be interpreted directly in JavaScript. I'm sure that can be used to your advantage!
JSON (JavaScript Object Notation)
ah, that is a good point
In fact, I would suggest you try both option and decide which one you like most !
@bazola But I'm not sure GWT can benefit from the JavaScript object translation thing, since you write your code in Java.
i could see using it if I wanted to display information in the browser window outside of the libGDX game window, or something like that
that's an option!
@bazola You've got answer
0
A: Strategy Game Menus and OOP

Simon André ForsbergChecking if something is on stage In your parent class you have: public boolean isOpen() { return this.isOpen; } This can be replaced by menuTable.hasParent() setPage method? HelpMenu.this.pageNumber = ...; HelpMenu.this.build(HelpMenu.this.pageNumber); This is some duplciated code. I...

I focused on aspects
but I entirely agree with @Marc-Andre that the parent class should be abstract
15:34
@SimonAndréForsberg thanks, taking a look now
@SimonAndréForsberg lots of good stuff in there
15:58
JSON certainly does the job with less code..
		Json json = new Json();
		System.out.println(json.prettyPrint(this.world.closebyRegionsForPosition(player.position())));
[
{
	class: com.walkaboutMMO.GameModel.Region,
	regionMap: {
		2,1: {
			position: {
				regionWidth: 0,
				x: 2,
				y: 1,
				regionHeight: 0
			},
			building: {
				type: NONE,
				occupiedStorage: 0
			},
			type: DESERT,
			ownerName: null
		},
		6,5: {
			position: {
				regionWidth: 0,
				x: 6,
				y: 5,
				regionHeight: 0
			},
			building: {
				type: NONE,
				occupiedStorage: 0
			},
			type: MOUNTAIN,
			ownerName: null
		},
		2,2: {
			position: {
				regionWidth: 0,
				x: 2,
				y: 2,
14 seconds to save the world file and it is 41.8MB
@bazola what about performance difference?
@SimonAndréForsberg its pretty sucky so far
16:13
interesting
I wonder what the speed with it would be if Jackson would be used.
even if Jackson can't be used in GWT
16:31
@bazola If you do not use prettyPrint ? and write directly to a file instead of sysout ? (is it the real sysout or the dev console ? )
@Marc-Andre i did some more tweaking to my model and got it down to about 24MB, taking 10 seconds to save. and then without prettyPrint it was 13MB, 4 seconds
Monking! Man I've been slammed today :\
@bazola Wow I knew prettyPrint would speed up, but wow that's an improvement!
Hey @Phrancis!
@Marc-Andre its very not pretty though!
{worldMap:{0,0:{regionMap:{2,1:{position:{x:2,y:1},building:{type:NONE},type:MOU‌​NTAIN},6,5:{position:{x:6,y:5},building:{type:NONE},type:FOREST},2,2:{position:{x‌​:2,y:2},building:
@bazola Yeha but there is tools to pretty the json after ;)
Json Viewer in google chrome works nicely
16:44
@Marc-Andre i will take a look at that
I've got it deserializing the JSON into an object, and it does create part of it.. unfortunately it said it needed no argument constructors for all of the objects it was serializing, and those arguments are not correctly creating all of the data from the saved JSON
@bazola is it meant to be pretty?
@bazola No argument constructors is normal, how would he know automatically how to wired the arguments, unless there is a way to specify certain things.
@Marc-Andre but what if I already have a no argument constructor that I am using for normal stuff?
Indeed. No-arg constructors in serialization is very normal. All Cardshifter-stuff are no-arg compatible. If it doesn't work for you, look into a more low-level IO solution.
@bazola For all the sub objects too ?
16:58
@Marc-Andre for some of them I already have a no arg constructor that initializes the fields of the class
You need to have it for all the object you serialize in your object hierarchy.
I do, but won't it call the constructor and initialize it to fresh values rather than loading values from the Json?
@bazola No, normally it will use reflection and use setter/getter. But this should be mentionned in the documentation of the parser
@bazola It will call the no-arg constructor first, then it will load values from the Json and inject them
17:55
0
Q: Implement a Shape abstract class

PhrancisTo learn more about OOP, @nhgrif challenged me to implement a Shape abstract class (more details in code remarks below. Here is how I did it. Any and all advice appreciated! Shape.java /* nhgrif says: * Phrancis ready for inheritance/polymorphism? * Given the following abstract class: * * ...

Took a few minutes out of my lunch break to post this - back to work now :D
@Phrancis Well done. I have really nothing to say at all.
I guess I could go into some nitpicks about it but I don't see any reason to do so.
More importantly: Do you feel that you understand the inheritance concept?
I think there are many ways you can take it to the next level though.
18:13
To the extent that a simple example like this can help me understand inheritance, I feel that I do somewhat
I kept seeing things about interfaces, throughout abstract class tutorials, that I don't really get the difference
I'm stuck doing stupid data entry right now, but I'll be sure to read anything you post here and on the question!
@Phrancis An interface defines a number of specific methods that has to exist, it does not care about the implementation of them. An abstract class can specify the implementations for methods, and can also contain variables. An interface can not specify any variables.
@SimonAndréForsberg @Marc-Andre should this be an interface since there aren't any default methods for the abstract class?
public abstract class Shape {
    public abstract double area();
    public abstract double perimeter();
}
@bazola as monkey said in his answer, yes.
hehe, i see it now
(Now @skiwi will say "Java 8 interfaces can contain implementations!", but to simplify things for @Phrancis, let's not talk about that...)
18:39
@bazola Yeah you can always declare a :
public abstract class AbstractShape implements Shape {
    public double area() {
          /* basic implementation */
    }
    public abstract double perimeter();
}
> This seems to happen about every two-three days.
in The 2nd Monitor, 12 mins ago, by nhgrif
@Phrancis rolfl is almost certainly right about abstract versus interface. I'm not used to abstract classes. But this was good practice because the next challenge is a 3d interface
18:58
i have verified that after loading the JSON that all of the regions are present in the HashMap of the World, and also that all of the Tiles are in the HashMap of the Regions.. and yet targetRegion is null:
	public Tile getPlayerPositionTile(MapPoint playerWorldPosition, MapPoint playerPosition) {
		Region targetRegion = this.worldMap.get(playerWorldPosition);
		return targetRegion.getTileForPosition(playerPosition);
	}
Man I hate data entry, such a mindless activity :(
@bazola does MapPoint implement hashcode and equals?
^^ that I was about to ask if worldMap is a HashMap or something similar
are the actual keys in the hashmap of the correct type? Loop over the keyset and print out key.getClass()
@SimonAndréForsberg yeah
19:03
@bazola is the implementation of them correct?
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + x;
        result = prime * result + y;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        MapPoint other = (MapPoint) obj;
        if (x != other.x)
            return false;
@bazola good, that's approved.
now check the map key types.
when this method gets called, it prints out all the strings as expected:
public void loadWorld() {
    FileHandle loadedFile = Gdx.files.local("jsontest.txt");
    Json newJson = new Json();
    World loadedWorld = newJson.fromJson(World.class, loadedFile);
    for (Region region : loadedWorld.getAllRegions()) {
        System.out.println(region.toString());
        System.out.println(region.worldPosition().toString());
        for (Tile tile : region.allTiles()) {
            System.out.println(tile.toString());
            System.out.println(tile.position().toString());
com.walkaboutMMO.GameModel.Region@f20ded0
22,22
com.walkaboutMMO.GameModel.Tile@32218db7
3,9
com.walkaboutMMO.GameModel.Tile@7683f888
5,7
com.walkaboutMMO.GameModel.Tile@fea7ac1
5,8
com.walkaboutMMO.GameModel.Tile@635e3b2
5,9
Sorry @bazola I don't have enough context/code to help you out.
@bazola Are you sure this.worldMap is not empty ?
19:14
figured out something at least
			for (MapPoint point : region.allKeys()) {
				System.out.println(point);
			}
the keys should be MapPoints but when I call that method I get
Exception in thread "LWJGL Application" java.lang.ClassCastException: java.lang.String cannot be cast to com.walkaboutMMO.GameModel.MapPoint
	at com.walkaboutMMO.GameModel.MainGame.loadWorld(MainGame.java:247)
	at com.walkaboutMMO.GameModel.MainGame.<init>(MainGame.java:28)
	at com.walkaboutMMO.GameScene.GameScreen.<init>(GameScreen.java:50)
	at com.walkaboutMMO.GameScene.LibGDXGame.create(LibGDXGame.java:92)
	at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
@bazola that's what I thought.
strange that Json figured out the types for all the other things..
either you need to make sure that JSON actually loads them as MapPoint
or you need to fix so that when you have loaded a level, you loop over the keys as Object, cast to String and create a new MapPoint from that.
@bazola HashMaps and reflection can be tricky business. While it is possible to read the keys correctly, many things don't. Even Jackson needs some special handling of HashMap keys.
Again though, this problem would solve itself if you serialized differently.
by using a custom-written binary serialization and not JSON.
that would also reduce the map size, significantly.
but can cause compatibility problems in the future if you want to add new things to save.
well, the eventual idea is to have basically a separate file for every Region hosted on the MMO server. I was thinking that XML or JSON would be better in case those Regions ever need to be repaired, or if changes to the server are made. I don't want to be unable to read the binary files in the future.. but on the other hand, even though I have read that this can be a problem, I don't really see how
@bazola If the serialization only needs to be done on the server then you could use Jackson to do it, which will fix the key problem. But then you need a way to pass data from server to client also...
19:29
@SimonAndréForsberg quick and dirty workaround.. just change the HashMaps to use a String as the key
its at least loading properly now
but unfortunately I would have to do that to all of the HashMaps for this to work, not that there are That many
@bazola true that. indeed a solution. not a very good one, but a solution it is.
@bazola You know if there's a way to make a table cell always have the same width and height?
How do you set the size of your game tiles for example?
@SimonAndréForsberg table cell? not sure. For the tiles in the game I am doing this:
this.tileSize = (int)LibGDXGame.STAGE_WIDTH/MainGame.NUM_TILES_PER_ROW;
//deal with iPad OR horizontal
if (this.tileSize * MainGame.NUM_ROWS > LibGDXGame.STAGE_HEIGHT || LibGDXGame.STAGE_WIDTH > LibGDXGame.STAGE_HEIGHT) {
    this.tileSize = (int)LibGDXGame.STAGE_HEIGHT/MainGame.NUM_ROWS;
}
@SimonAndréForsberg is it not? seems like when the JSON is saving these properties (such as the enum values) it is saving them as their toString() values anyway
so i change about 20 lines of code to have all my HashMaps use strings, and bam everything works without even outputting a new JSON file
19:48
@bazola But you lost the readability of the enum, which is not critic but not desirable
@Marc-Andre the JSON file seems to look the same either way, you just mean it is no longer clear that the HashMap uses the enum values as keys?
Yeah that is what I meant
one good thing is that at the class level I still use the enum types as arguments like this:
public void resourcePurchasedFromPlayer(ResourceType type) {
    int currentPrice = this.sellPrices.get(type.toString());
    int decreaseAmount = this.incrementAmounts.get(type.toString());
    this.buyPrices.put(type.toString(), currentPrice); //buy price always equals previous sell price
    this.sellPrices.put(type.toString(), Math.max(currentPrice - decreaseAmount, 0));
}
so all the toString stuff pretty much happens at the implementation level
TTQW !
20:25
@Marc-Andre @SimonAndréForsberg i wonder if it would be possible to use cookies to save JSON data?
20:38
@bazola I have to say, it is not an optimal solution.
@bazola make the JSON a string and I'm sure you can.
holy 121 messages
@skiwi nope. 121 messages. None of them are holy.
@SimonAndréForsberg but, but, okay
feeling somewhat better
hope tomorrow I'm worth something again
I did have the luck that despite feeling sick, I could eat normally most of the time, so I don't need to recover from that part
@SimonAndréForsberg then it would be possible to save the game even in the GWT version, i think
@bazola yes, correct
21:45
it looks like at some point, cardshifter (i think the GDX version) generated this file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="username">Ybaz</entry>
</properties>
22:13
@bazola Sure you can, but I don't map information should be store in it.
@Marc-Andre probably not should, no.. but if it works.. ;)
what would you store in it ?
the JSON game save
Why don't you save it on the server. Cookie are limited by size and can die and people can delete cookie for no reason. Do you really trust your users with that kind of information ?
You can save the json to a DB, or in file on the server , but cookie are really not the good option here I feel.
22:29
well what I am thinking about here is the single player version of the game. If I have to save it to my server then there will be a storage cost and such. If its a cookie, although it is volatile, at least it is stored locally on the users machine
@bazola Look for the local storage, browser now permit some file to the local storage.
@Marc-Andre not sure LibGDX / GWT supports that
@SimonAndréForsberg back in march 2014 someone on their forums was saying that they might eventually implement it
would be nice
home finally, what a dreadful day it was
22:44
well I guess it was fun messing around with XML and JSON, but i am getting crashes on iOS trying to save. works in the simulator but not on a device
22:57
it would be nice to use serializable and call it a day, but if you have implements Serializable in your class declaration then the GWT version will not compile. At least with the JSON and XML the GWT still compiles
Would it be accurate to say that Shape would be better as interface (without modifications to it) because it doesn't need to care how its method(s) are implemented, just that they are implemented in one fashion or another?
23:22
Then why would I use GWT :P
Maybe an example would help me... Say I had a very general Vehicle interface, with base characteristics that would apply to any vehicle, and then I had a Car abstract class with more specific attributes specific to cars... Then if I made a class Volvo implements Vehicle extends Car would that be a decent beginner way to think about the concepts?
Prediction:
2
@Phrancis You don't need to implements Vehicle if you extends Car
@Phrancis what Marc-Andre said ^^. And also, in some cases you should not use too much inheritance.
So Car would implement Vehicle, and Volvo would extend Car?
Should Volvo be a subclass of Car or should "Volvo" be passed as String carModel for the Car?
@Phrancis yes
23:27
Ah, interesting details
Volvo can also implement Vehicle, but there's no reason to do so, that is implicit from inheriting Car.
OK, good info.
See, if you're patient with me, I pick up on things eventually :D
I might try to write some Vehicle interface and see how it works
(easier with something simple/concrete I guess)
I saw you mentioned something about abstract classes being able to define(?) implementation details and variables?
I could certainly say a Car has specific things, like wheels, a motor, etc. that may behave similarly in different cars but have different attributes/values... Would that be a good case for an abstract class?
23:50
Ok, I'll give that a try!
RELOAD!
[retailcoder/Rubberduck] 3 commits. 1 opened issue. 1 closed issue. 22 issue comments.
[Zomis/GithubHookSEChatService] 1 issue comment.

« first day (220 days earlier)      last day (3641 days later) »