This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IndividualFile.cs
141 lines (128 loc) · 3.47 KB
/
IndividualFile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace LevelGenerator
{
/// This class defines how the generated individuals must be written.
[Serializable]
public class IndividualFile
{
[JsonInclude]
public Dimensions dimensions;
[JsonInclude]
public List<Room> rooms;
[JsonInclude]
public int generation;
[JsonInclude]
public float fitness;
[JsonInclude]
public int numberOfRooms;
[JsonInclude]
public int numberOfKeys;
[JsonInclude]
public int numberOfLocks;
[JsonInclude]
public float linearCoefficient;
[JsonInclude]
public int neededLocks;
[JsonInclude]
public float neededRooms;
[JsonInclude]
public float exploration;
[JsonInclude]
public float leniency;
[JsonInclude]
public float fGoal;
[JsonInclude]
public float fRooms;
[JsonInclude]
public float fKeys;
[JsonInclude]
public float fLocks;
[JsonInclude]
public float fLinearCoefficient;
[JsonInclude]
public float fSTD;
[JsonInclude]
public float fEnemySparsity;
[JsonInclude]
public float fNeededRooms;
[JsonInclude]
public float fNeededLocks;
public IndividualFile()
{
rooms = new List<Room>();
}
/// This class holds the features that a room may have.
[Serializable]
public class Room
{
[JsonInclude]
public Coordinates coordinates;
[JsonInclude]
public string type;
[JsonInclude]
public List<int> keys;
[JsonInclude]
public List<int> locks;
public int enemies = -1;
[DefaultValue(-1), JsonInclude]
public int Enemies { get => enemies; set => enemies = value; }
}
}
/// This class holds the level dimensions.
[Serializable]
public class Dimensions
{
private int width;
private int height;
public Dimensions(
int _width,
int _height
) {
Width = _width;
Height = _height;
}
[JsonInclude]
public int Width { get => width; set => width = value; }
[JsonInclude]
public int Height { get => height; set => height = value; }
}
/// This class holds the coordinates of a level room.
[Serializable]
public class Coordinates
{
private int x;
private int y;
public Coordinates(
int _x,
int _y
) {
X = _x;
Y = _y;
}
[DefaultValue(-1)]
public int X { get => x; set => x = value; }
[DefaultValue(-1)]
public int Y { get => y; set => y = value; }
public override bool Equals(
object _obj
) {
if (_obj is null || !GetType().Equals(_obj.GetType()))
{
return false;
}
Coordinates coordinates = (Coordinates) _obj;
return coordinates.x == x && coordinates.y == y;
}
public override string ToString()
{
return $"Coordinates X = {X}, Y = {Y}";
}
public override int GetHashCode()
{
return x ^ y;
}
}
}