Skip to content

Commit

Permalink
Add readme and license
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarez5341 committed Feb 28, 2019
1 parent c319a3c commit d37b4bc
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 6 deletions.
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Joseph Suarez and Clare Zhu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 30 additions & 2 deletions README.md
@@ -1,2 +1,30 @@
# Godsword-Client
Welcome to Projekt Godsword.
[ags]: resources/ags.png?raw=true
[fire]: resources/fire_thumbnail.png
[env]: resources/env.jpg

# ![][fire] Neural-MMO-Client
This repository contains the THREE.js based 3D browser client for the main [Neural MMO Project](https://docs.google.com/document/d/1_76rYTPtPysSh2_cFFz3Mfso-9VL3_tF5ziaIZ8qmS8/edit?usp=sharing). It's in Javascript, but it reads like Python. This is both because I am a Python-using researcher and because it allows researchers with under 30 minutes of Javascript experience to begin contributing immediately.

![][env]

## ![][ags] Setup

You don't need to clone this repo manually. Follow the install instructions in the [OpenAI Repo](https://docs.google.com/document/d/1_76rYTPtPysSh2_cFFz3Mfso-9VL3_tF5ziaIZ8qmS8/edit?usp=sharing). This will download THREE.js. You can do this manually if you do not want to download the whole source repo.

## ![][ags] Details

I personally plan on continuing development on both the main environment and the client. Environment updates will most likely be released in larger chunks, potentially coupled to future publications. On the other hand, the client is under active and rapid development. You can expect most features, at least in so far as they are applicable to the current environment build, to be released as soon as they are stable. Feel free to contact me with ideas and feature requests.

Please note: this is my personal agenda, and I do not speak for OpenAI.

## ![][ags] Known Limitations

The client has been tested with Firefox on Ubuntu. Don't use Chrome. It should work on other Linux distros and on Macs -- if you run into issues, let me know.

Use Nvidia drivers if your hardware setup allows. The only real requirement is support for more that 16 textures per shader. This is only required for the Counts visualizer -- you'll know your setup is wrong if the terrain map vanishes when switching overlays.

This is because the research overlays are written as raw glsl shaders, which you probably don't want to try to edit. In particular, the counts exploration visualizer hard codes eight textures corresponding to exploration maps. This exceeds the number of allowable textures. I will look into fixing this into future if there is significant demand. If you happen to be a shader wizard with spare time, feel free to submit a PR.

## ![][ags] Authorship

This client is a collaboration between myself (Joseph Suarez) and Clare Zhu. It was originally created as follow-up work for the paper and blog post, but we ended up merging it in. This is also the reason that the project is split into two repositories.
45 changes: 45 additions & 0 deletions client.js
Expand Up @@ -10,6 +10,30 @@ var client, counts, values, stats, box;
var CURRENT_VIEW = views.CLIENT;


THREE.Object3D.prototype.rotateAroundWorldAxis = function() {

// rotate object around axis in world space (the axis passes through point)
// axis is assumed to be normalized
// assumes object does not have a rotated parent

var q = new THREE.Quaternion();

return function rotateAroundWorldAxis( point, axis, angle ) {

q.setFromAxisAngle( axis, angle );

this.applyQuaternion( q );

this.position.sub( point );
this.position.applyQuaternion( q );
this.position.add( point );

return this;

}

}();

class Client{
// interface for client, viewer, and counts
constructor (my_container) {
Expand All @@ -23,6 +47,18 @@ class Client{
var scope = this; // javascript quirk... don't touch this
function onMouseDown( event ) { scope.onMouseDown( event ); }
my_container.addEventListener( 'click', onMouseDown, false );

this.axPos = tileSz*nTiles/2
this.p = new THREE.Vector3(this.axPos, 0, this.axPos);
this.ax = new THREE.Vector3(0, 1, 0);
this.tick = 0
this.rotateTime = 0
this.r = 2750

this.controls = this.engine.controls
this.camera = this.engine.camera
this.camera.position.set(this.axPos, 4000, this.axPos)
this.controls.update()
}

update() {
Expand All @@ -31,8 +67,17 @@ class Client{
this.handler.updateFast();
this.updatePacket();

//this.engine.scene.rotateAroundWorldAxis(this.p, this.ax, 0.0025)
if (this.tick > 200) {
var x = this.axPos + this.r * Math.cos(this.rotateTime)
var z = this.axPos + this.r * Math.sin(this.rotateTime)
this.camera.position.set(x, 500, z)
this.rotateTime += 0.0025
}

var packet = this.packet;
if (packet) {
this.tick += 1
// Receive packet, begin translating based on the received position
packet = JSON.parse(packet);

Expand Down
6 changes: 3 additions & 3 deletions index.html
Expand Up @@ -56,10 +56,10 @@
<body>
<div id="blocker" style="display: block;">
<div id="instructions">
<span style="font-size:40px">Click to begin</span> <br>
<!-- <span style="font-size:40px">Click to begin</span> <br> -->
<span style="font-family:DragonSlapper;font-size:80px">
PROJEKT GODSWORD.</span> <br>
<b>WASD/middle mouse</b> pitch/yaw, <b>arrow keys</b> pan,
NEURAL MMO CLIENT</span> <br>
<!-- <b>WASD/middle mouse</b> pitch/yaw, <b>arrow keys</b> pan, -->
<b>scroll wheel</b> zoom<br/>
</div>
</div>
Expand Down
Binary file added resources/ags.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/env.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/fire_thumbnail.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions setup.sh
@@ -0,0 +1 @@
git clone https://github.com/mrdoob/three.js/
5 changes: 4 additions & 1 deletion twistedserver.py
Expand Up @@ -2,7 +2,7 @@
import numpy as np

from signal import signal, SIGINT
import sys, os, json, pickle
import sys, os, json, pickle, time
import ray

from twisted.internet import reactor
Expand Down Expand Up @@ -139,6 +139,9 @@ def announce(self):
uptime = np.round(self.tickRate*self.tick, 1)
print('Uptime: ', uptime, ', Tick: ', self.tick)

if self.tick == 5:
pass
#time.sleep(20)
self.step()
for client in self.clients:
client.sendUpdate()
Expand Down

0 comments on commit d37b4bc

Please sign in to comment.