Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

[RFR] Check single row alignement #1

Merged
merged 11 commits into from
Sep 22, 2016
Merged

Conversation

floo51
Copy link
Contributor

@floo51 floo51 commented Sep 22, 2016

  • Make it work
  • Factorize & test

@floo51 floo51 changed the title [WIP] Check single row alignement [RFR] Check single row alignement Sep 22, 2016
@floo51
Copy link
Contributor Author

floo51 commented Sep 22, 2016

Ready for review

[True, False, False, False],
[False, True, False, False],
[False, False, True, False],
[False, False, False, True]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a comma at each end of line



class TestStringMethods(unittest.TestCase):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

mask = tf.placeholder('bool', [4, 4])


def is_aligned():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can transform this from a function to a variable like this:

extract_chunk = tf.boolean_mask(board, mask)
is_aligned = tf.equal(tf.reduce_prod(extract_chunk), 1)

In this way:

  • you avoid to recreate variables each time you use this function
  • you save RAM
  • you can import extract_chunk from this module too

import unittest
import tensorflow as tf

from reward import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider import * is forbidden. Import each function at a time.

from reward import is_aligned

or use it directly from the module:

import reward

# Usage
reward.is_aligned

]

self.assertEqual(
session.run(is_aligned(), feed_dict={
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability purpose, put the session run result in a variable, then check it like:
this.assertEqual(result, True)

This will help you give name to things too.

@@ -0,0 +1,19 @@
import tensorflow as tf

from ai.bitmasks import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forbidden import *

@Kmaschta
Copy link
Contributor

Most of .gitignore content is useless. KISS

@Kmaschta
Copy link
Contributor

Kmaschta commented Sep 22, 2016

You don't have make install neither

Here is a Dockerfile that you can use for your project:

FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/

And the related Makefile commands:

install:
    docker build -t connectfour .

run:
    docker run --rm --it -v $(shell pwd):/code connectfour python connectfour.py

test:
    docker run --rm --it -v $(shell pwd):/code connectfour python -m unittest discover

You may change some things but the most of it is here.

@floo51 floo51 mentioned this pull request Sep 22, 2016
@floo51
Copy link
Contributor Author

floo51 commented Sep 22, 2016

Review applied

@Kmaschta Kmaschta merged commit ed14992 into master Sep 22, 2016
@Kmaschta Kmaschta deleted the check_single_row_alignement branch September 22, 2016 14:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants